Bug 1319070 - Match against the principal. r=kmag, a=abillings
authorTomislav Jovanovic <tomica@gmail.com>
Sun, 04 Dec 2016 00:04:46 +0100
changeset 359209 0ef9b3667a0664b6496f565b567f9705e0c6e462
parent 359208 cb96747de8e2c07860854003d32dac005514f70f
child 359210 be751ea19d464d51be7d36bd2a0fd6a72029dc02
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag, abillings
bugs1319070
milestone51.0
Bug 1319070 - Match against the principal. r=kmag, a=abillings MozReview-Commit-ID: Jjgv2ODDH1Y
addon-sdk/source/test/addons/embedded-webextension/main.js
toolkit/components/extensions/ExtensionContent.jsm
--- a/addon-sdk/source/test/addons/embedded-webextension/main.js
+++ b/addon-sdk/source/test/addons/embedded-webextension/main.js
@@ -130,17 +130,17 @@ exports.testEmbeddedWebExtensionContentS
         port.onDisconnect.addListener(() => {
           assert.equal(numExpectedMessages, 0, "Got the epected number of port messages");
           resolve();
         });
       };
       browser.runtime.onConnect.addListener(portListener);
     });
 
-    let url = "data:text/html;charset=utf-8,<h1>Test Page</h1>";
+    let url = "http://example.org/";
 
     var openedTab;
     tabs.once('open', function onOpen(tab) {
       openedTab = tab;
     });
     tabs.open(url);
 
     yield Promise.all([
--- a/toolkit/components/extensions/ExtensionContent.jsm
+++ b/toolkit/components/extensions/ExtensionContent.jsm
@@ -129,16 +129,21 @@ Script.prototype = {
     let uri = window.document.documentURIObject;
 
     // If mozAddonManager is present on this page, don't allow
     // content scripts.
     if (window.navigator.mozAddonManager !== undefined) {
       return false;
     }
 
+    // Documents from data: URIs inherit the principal.
+    if (Services.netUtils.URIChainHasFlags(uri, Ci.nsIProtocolHandler.URI_INHERITS_SECURITY_CONTEXT)) {
+      uri = window.document.nodePrincipal.URI;
+    }
+
     if (!(this.matches_.matches(uri) || this.matches_host_.matchesIgnoringPath(uri))) {
       return false;
     }
 
     if (this.exclude_matches_.matches(uri)) {
       return false;
     }