Bug 1282660 - Part 1: Make the devtools uses nodePrincipal instead of the system principal when fetching stylesheets. r=gl, a=sledru
authorTim Huang <tihuang@mozilla.com>
Wed, 13 Jul 2016 02:37:00 +0200
changeset 340086 72f41d45c4ded1784ab9634c48c0eecbd139e5c4
parent 340085 cff908fa53dc70ded390832f107c3fcd1262155b
child 340087 9b0f979295b744d510b6b679a7c3a89f57e94ffd
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl, sledru
bugs1282660
milestone49.0a2
Bug 1282660 - Part 1: Make the devtools uses nodePrincipal instead of the system principal when fetching stylesheets. r=gl, a=sledru
devtools/server/actors/stylesheets.js
--- a/devtools/server/actors/stylesheets.js
+++ b/devtools/server/actors/stylesheets.js
@@ -436,20 +436,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