Bug 1312690: Add some stupid microoptimizations. r?aswan
MozReview-Commit-ID: 4qoNuG2k0KS
--- a/toolkit/components/extensions/ExtensionContent.jsm
+++ b/toolkit/components/extensions/ExtensionContent.jsm
@@ -205,21 +205,21 @@ Script.prototype = {
* change.
* @param {string} when
* The document's current load state, or if triggered by a
* document state change, the new document state that triggered
* the injection.
*/
tryInject(window, sandbox, shouldRun, when) {
if (shouldRun("document_start")) {
- let winUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindowUtils);
-
let {cssURLs} = this;
if (cssURLs.length > 0) {
+ let winUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils);
+
let method = this.remove_css ? winUtils.removeSheetUsingURIString : winUtils.loadSheetUsingURIString;
for (let url of cssURLs) {
runSafeSyncWithoutClone(method, url, winUtils.AUTHOR_SHEET);
}
this.deferred.resolve();
}
}
--- a/toolkit/components/extensions/ExtensionManagement.jsm
+++ b/toolkit/components/extensions/ExtensionManagement.jsm
@@ -234,18 +234,17 @@ var Service = {
// API Levels Helpers
// Find the add-on associated with this document via the
// principal's originAttributes. This value is computed by
// extensionURIToAddonID, which ensures that we don't inject our
// API into webAccessibleResources or remote web pages.
function getAddonIdForWindow(window) {
- let principal = window.document.nodePrincipal;
- return principal.originAttributes.addonId;
+ return Cu.getObjectPrincipal(window).originAttributes.addonId;
}
const API_LEVELS = Object.freeze({
NO_PRIVILEGES: 0,
CONTENTSCRIPT_PRIVILEGES: 1,
FULL_PRIVILEGES: 2,
});