Bug 1312690: Add some stupid microoptimizations. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Tue, 01 Nov 2016 16:56:21 -0700
changeset 347520 5e3d6fb19a2b91400d3baa26c868da621df8e700
parent 347519 12ef342043e97b556c794efc3cf6f2f4bdf46a5d
child 347521 dcb9ea438c0146ecc96754940884aeb852909d01
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1312690
milestone52.0a1
Bug 1312690: Add some stupid microoptimizations. r=aswan MozReview-Commit-ID: 4qoNuG2k0KS
toolkit/components/extensions/ExtensionContent.jsm
toolkit/components/extensions/ExtensionManagement.jsm
--- a/toolkit/components/extensions/ExtensionContent.jsm
+++ b/toolkit/components/extensions/ExtensionContent.jsm
@@ -210,21 +210,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,
 });