Bug 1282660 - Part 1 : Make the devtools uses nodePrincipal instead of the system principal when fetching stylesheets. r=gl
authorTim Huang <tihuang@mozilla.com>
Wed, 13 Jul 2016 02:37:00 +0200
changeset 305236 f57d23de8ac2b6645624f120b2508c8542eca412
parent 305235 f52c26d677b09dd07a3967d1b294776e2c4559e3
child 305237 1d657d984bed365b1c2bdc499532cf34c60b1edd
push id79519
push usercbook@mozilla.com
push dateSun, 17 Jul 2016 08:15:20 +0000
treeherdermozilla-inbound@1d657d984bed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1282660
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1282660 - Part 1 : Make the devtools uses nodePrincipal instead of the system principal when fetching stylesheets. r=gl
devtools/server/actors/stylesheets.js
--- a/devtools/server/actors/stylesheets.js
+++ b/devtools/server/actors/stylesheets.js
@@ -447,20 +447,29 @@ var StyleSheetActor = protocol.ActorClas
       let content = this.ownerNode.textContent;
       this.text = content;
       return promise.resolve(content);
     }
 
     let options = {
       loadFromCache: true,
       policy: Ci.nsIContentPolicy.TYPE_INTERNAL_STYLESHEET,
-      window: this.window,
       charset: this._getCSSCharset()
     };
 
+    // Bug 1282660 - We use the system principal to load the default internal
+    // stylesheets instead of the content principal since such stylesheets
+    // require system principal to load. At meanwhile, we strip the loadGroup
+    // for preventing the assertion of the userContextId mismatching.
+    // The default internal stylesheets load from the 'resource:' URL.
+    if (!/^resource:\/\//.test(this.href)) {
+      options.window = this.window;
+      options.principal = this.document.nodePrincipal;
+    }
+
     return fetch(this.href, options).then(({ content }) => {
       this.text = content;
       return content;
     });
   },
 
   /**
    * Protocol method to get the original source (actors) for this