author | Tomislav Jovanovic <tomica@gmail.com> |
Wed, 23 Nov 2016 18:46:10 +0100 | |
changeset 327610 | 6ccd471984affe783a0fcf511389821dea59dcd6 |
parent 327609 | f215191778e94ac20503b57491bb05dd203631f1 |
child 327611 | 26052518754c2f45bb4f6d2ebf3c6b7a162807cc |
push id | 31139 |
push user | ryanvm@gmail.com |
push date | Fri, 30 Dec 2016 15:04:57 +0000 |
treeherder | mozilla-central@9104708cc3ac [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | kmag |
bugs | 1319070 |
milestone | 53.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
|
--- 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 @@ -138,33 +138,43 @@ Script.prototype = { urls.push(url); } return urls; }, matches(window) { let uri = window.document.documentURIObject; + let principal = window.document.nodePrincipal; // If mozAddonManager is present on this page, don't allow // content scripts. if (window.navigator.mozAddonManager !== undefined) { return false; } - if (this.match_about_blank && ["about:blank", "about:srcdoc"].includes(uri.spec)) { - const principal = window.document.nodePrincipal; - + if (this.match_about_blank) { // When matching top-level about:blank documents, // allow loading into any with a NullPrincipal. - if (window === window.top && principal.isNullPrincipal) { + if (uri.spec === "about:blank" && window === window.top && principal.isNullPrincipal) { return true; } + // When matching about:blank/srcdoc iframes, the checks below // need to be performed against the "owner" document's URI. + if (["about:blank", "about:srcdoc"].includes(uri.spec)) { + uri = principal.URI; + } + } + + // Documents from data: URIs also inherit the principal. + if (Services.netUtils.URIChainHasFlags(uri, Ci.nsIProtocolHandler.URI_INHERITS_SECURITY_CONTEXT)) { + if (!this.match_about_blank) { + return false; + } uri = principal.URI; } if (!(this.matches_.matches(uri) || this.matches_host_.matchesIgnoringPath(uri))) { return false; } if (this.exclude_matches_.matches(uri)) {