From cf006cd593d9b4b9d5dcdff252172ab06f025a97 Mon Sep 17 00:00:00 2001 From: Andrew Osmond Date: Fri, 10 Aug 2018 09:30:24 -0400 Subject: [PATCH 01/40] Bug 1446309 - Store a shared surface's dirty rect update if we cannot process it immediately. r=nical Multiple tabs in the same process could be viewing the same image. If it is an image we are taking some time to download from the network, it may not be displayed all at once. As a result, it could generate several dirty rects for the newly decoded lines each time we paint. Since we only apply the dirty rect to the active tab, and forget it afterwards, then when one returns to the other tab(s), it may not reupload all of the modified image data. Now we save the dirty rect and accumulate it for the handles which weren't able to be updated immediately. --- gfx/layers/ipc/SharedSurfacesChild.cpp | 36 +++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/gfx/layers/ipc/SharedSurfacesChild.cpp b/gfx/layers/ipc/SharedSurfacesChild.cpp index a6585071d994..78ab4aa2638c 100644 --- a/gfx/layers/ipc/SharedSurfacesChild.cpp +++ b/gfx/layers/ipc/SharedSurfacesChild.cpp @@ -30,20 +30,39 @@ public: ImageKeyData(ImageKeyData&& aOther) : mManager(std::move(aOther.mManager)) + , mDirtyRect(std::move(aOther.mDirtyRect)) , mImageKey(aOther.mImageKey) { } ImageKeyData& operator=(ImageKeyData&& aOther) { mManager = std::move(aOther.mManager); + mDirtyRect = std::move(aOther.mDirtyRect); mImageKey = aOther.mImageKey; return *this; } + void MergeDirtyRect(const Maybe& aDirtyRect) + { + if (mDirtyRect) { + if (aDirtyRect) { + mDirtyRect->UnionRect(mDirtyRect.ref(), aDirtyRect.ref()); + } + } else { + mDirtyRect = aDirtyRect; + } + } + + Maybe TakeDirtyRect() + { + return std::move(mDirtyRect); + } + ImageKeyData(const ImageKeyData&) = delete; ImageKeyData& operator=(const ImageKeyData&) = delete; RefPtr mManager; + Maybe mDirtyRect; wr::ImageKey mImageKey; }; @@ -143,14 +162,23 @@ public: bool ownsKey = wrBridge->GetNamespace() == entry.mImageKey.mNamespace; if (!ownsKey) { entry.mImageKey = wrBridge->GetNextImageKey(); + entry.TakeDirtyRect(); aResources.AddExternalImage(mId, entry.mImageKey); - } else if (aDirtyRect) { - aResources.UpdateExternalImage(mId, entry.mImageKey, - ViewAs(aDirtyRect.ref())); + } else { + entry.MergeDirtyRect(aDirtyRect); + Maybe dirtyRect = entry.TakeDirtyRect(); + if (dirtyRect) { + aResources.UpdateExternalImage(mId, entry.mImageKey, + ViewAs(dirtyRect.ref())); + } } key = entry.mImageKey; found = true; + } else { + // We don't have the resource update queue for this manager, so just + // accumulate the dirty rects until it is requested. + entry.MergeDirtyRect(aDirtyRect); } } @@ -316,7 +344,7 @@ SharedSurfacesChild::Share(SourceSurfaceSharedData* aSurface, // Each time the surface changes, the producers of SourceSurfaceSharedData // surfaces promise to increment the invalidation counter each time the // surface has changed. We can use this counter to determine whether or not - // we should upate our paired ImageKey. + // we should update our paired ImageKey. Maybe dirtyRect = aSurface->TakeDirtyRect(); SharedUserData* data = nullptr; nsresult rv = SharedSurfacesChild::ShareInternal(aSurface, &data); From b30de56ba9dd0cbe41e82a76e98562e5d52c5fda Mon Sep 17 00:00:00 2001 From: Andrew Osmond Date: Fri, 10 Aug 2018 09:33:31 -0400 Subject: [PATCH 02/40] Backed out changeset 3f41992ab77e (bug 1446309) because wrong bug number. r=backout --- gfx/layers/ipc/SharedSurfacesChild.cpp | 36 +++----------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/gfx/layers/ipc/SharedSurfacesChild.cpp b/gfx/layers/ipc/SharedSurfacesChild.cpp index 78ab4aa2638c..a6585071d994 100644 --- a/gfx/layers/ipc/SharedSurfacesChild.cpp +++ b/gfx/layers/ipc/SharedSurfacesChild.cpp @@ -30,39 +30,20 @@ public: ImageKeyData(ImageKeyData&& aOther) : mManager(std::move(aOther.mManager)) - , mDirtyRect(std::move(aOther.mDirtyRect)) , mImageKey(aOther.mImageKey) { } ImageKeyData& operator=(ImageKeyData&& aOther) { mManager = std::move(aOther.mManager); - mDirtyRect = std::move(aOther.mDirtyRect); mImageKey = aOther.mImageKey; return *this; } - void MergeDirtyRect(const Maybe& aDirtyRect) - { - if (mDirtyRect) { - if (aDirtyRect) { - mDirtyRect->UnionRect(mDirtyRect.ref(), aDirtyRect.ref()); - } - } else { - mDirtyRect = aDirtyRect; - } - } - - Maybe TakeDirtyRect() - { - return std::move(mDirtyRect); - } - ImageKeyData(const ImageKeyData&) = delete; ImageKeyData& operator=(const ImageKeyData&) = delete; RefPtr mManager; - Maybe mDirtyRect; wr::ImageKey mImageKey; }; @@ -162,23 +143,14 @@ public: bool ownsKey = wrBridge->GetNamespace() == entry.mImageKey.mNamespace; if (!ownsKey) { entry.mImageKey = wrBridge->GetNextImageKey(); - entry.TakeDirtyRect(); aResources.AddExternalImage(mId, entry.mImageKey); - } else { - entry.MergeDirtyRect(aDirtyRect); - Maybe dirtyRect = entry.TakeDirtyRect(); - if (dirtyRect) { - aResources.UpdateExternalImage(mId, entry.mImageKey, - ViewAs(dirtyRect.ref())); - } + } else if (aDirtyRect) { + aResources.UpdateExternalImage(mId, entry.mImageKey, + ViewAs(aDirtyRect.ref())); } key = entry.mImageKey; found = true; - } else { - // We don't have the resource update queue for this manager, so just - // accumulate the dirty rects until it is requested. - entry.MergeDirtyRect(aDirtyRect); } } @@ -344,7 +316,7 @@ SharedSurfacesChild::Share(SourceSurfaceSharedData* aSurface, // Each time the surface changes, the producers of SourceSurfaceSharedData // surfaces promise to increment the invalidation counter each time the // surface has changed. We can use this counter to determine whether or not - // we should update our paired ImageKey. + // we should upate our paired ImageKey. Maybe dirtyRect = aSurface->TakeDirtyRect(); SharedUserData* data = nullptr; nsresult rv = SharedSurfacesChild::ShareInternal(aSurface, &data); From c24e0873da252804d966de0508244636c0a41ea6 Mon Sep 17 00:00:00 2001 From: Jonathan Kingston Date: Mon, 16 Jul 2018 10:17:51 +0100 Subject: [PATCH 03/40] Bug 1466801 - Flipping disallowInheritPrincipal to be allow. r=ckerschb r=gijs --HG-- rename : browser/base/content/test/general/browser_utilityOverlay.js => browser/base/content/test/contextMenu/browser_utilityOverlay.js extra : source : a7bdcc1e1373724effb0bec2d80eb9c63ae782a1 --- browser/base/content/browser.js | 16 ++++-- browser/base/content/nsContextMenu.js | 13 ++--- browser/base/content/tabbrowser.js | 9 ++-- .../base/content/test/contextMenu/browser.ini | 2 + .../browser_utilityOverlay.js | 2 +- .../browser_utilityOverlayPrincipal.js | 54 +++++++++++++++++++ browser/base/content/test/general/browser.ini | 2 - browser/base/content/urlbarBindings.xml | 2 +- browser/base/content/utilityOverlay.js | 9 ++-- .../components/extensions/parent/ext-tabs.js | 7 ++- .../components/sessionstore/SessionStore.jsm | 1 + browser/modules/ContentClick.jsm | 2 + .../BrowserTestUtils/BrowserTestUtils.jsm | 3 ++ .../autoplay-with-broken-track.html.ini | 3 +- .../event_pause_noautoplay.html.ini | 3 ++ .../paused_true_during_pause.html.ini | 3 ++ .../ready-states/autoplay.html.ini | 3 ++ 17 files changed, 107 insertions(+), 27 deletions(-) rename browser/base/content/test/{general => contextMenu}/browser_utilityOverlay.js (99%) create mode 100644 browser/base/content/test/contextMenu/browser_utilityOverlayPrincipal.js create mode 100644 testing/web-platform/meta/html/semantics/embedded-content/media-elements/event_pause_noautoplay.html.ini create mode 100644 testing/web-platform/meta/html/semantics/embedded-content/media-elements/paused_true_during_pause.html.ini create mode 100644 testing/web-platform/meta/html/semantics/embedded-content/media-elements/ready-states/autoplay.html.ini diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 008e94f3b625..38683ae83fa9 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1695,7 +1695,10 @@ var gBrowserInit = { window.arguments[4] || false, referrerPolicy, userContextId, // pass the origin principal (if any) and force its use to create // an initial about:blank viewer if present: - window.arguments[7], !!window.arguments[7], window.arguments[8]); + window.arguments[7], !!window.arguments[7], window.arguments[8], + // TODO fix allowInheritPrincipal + // (this is required by javascript: drop to the new window) Bug 1475201 + true); window.focus(); } else { // Note: loadOneOrMoreURIs *must not* be called if window.arguments.length >= 3. @@ -2384,7 +2387,7 @@ function BrowserTryToCloseWindow() { function loadURI(uri, referrer, postData, allowThirdPartyFixup, referrerPolicy, userContextId, originPrincipal, forceAboutBlankViewerInCurrent, - triggeringPrincipal) { + triggeringPrincipal, allowInheritPrincipal = false) { try { openLinkIn(uri, "current", { referrerURI: referrer, @@ -2395,6 +2398,7 @@ function loadURI(uri, referrer, postData, allowThirdPartyFixup, referrerPolicy, originPrincipal, triggeringPrincipal, forceAboutBlankViewerInCurrent, + allowInheritPrincipal, }); } catch (e) {} } @@ -3563,6 +3567,9 @@ var newTabButtonObserver = { let data = await getShortcutOrURIAndPostData(link.url); // Allow third-party services to fixup this URL. openNewTabWith(data.url, shiftKey, { + // TODO fix allowInheritPrincipal + // (this is required by javascript: drop to the new window) Bug 1475201 + allowInheritPrincipal: true, postData: data.postData, allowThirdPartyFixup: true, triggeringPrincipal, @@ -3595,6 +3602,9 @@ var newWindowButtonObserver = { let data = await getShortcutOrURIAndPostData(link.url); // Allow third-party services to fixup this URL. openNewWindowWith(data.url, { + // TODO fix allowInheritPrincipal + // (this is required by javascript: drop to the new window) Bug 1475201 + allowInheritPrincipal: true, postData: data.postData, allowThirdPartyFixup: true, triggeringPrincipal, @@ -6096,7 +6106,7 @@ function middleMousePaste(event) { lastLocationChange == gBrowser.selectedBrowser.lastLocationChange) { openUILink(data.url, event, { ignoreButton: true, - disallowInheritPrincipal: !data.mayInheritPrincipal, + allowInheritPrincipal: data.mayInheritPrincipal, triggeringPrincipal: gBrowser.selectedBrowser.contentPrincipal, }); } diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index 89f6c928b91f..c0a3df65feed 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -855,7 +855,6 @@ nsContextMenu.prototype = { Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT); let referrer = gContextMenuContentData.referrer; openWebLinkIn(gContextMenuContentData.docLocation, "current", { - disallowInheritPrincipal: true, referrerURI: referrer ? makeURI(referrer) : null, triggeringPrincipal: this.browser.contentPrincipal, }); @@ -913,8 +912,7 @@ nsContextMenu.prototype = { urlSecurityCheck(this.imageDescURL, this.principal, Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT); - openUILink(this.imageDescURL, e, { disallowInheritPrincipal: true, - referrerURI: gContextMenuContentData.documentURIObject, + openUILink(this.imageDescURL, e, { referrerURI: gContextMenuContentData.documentURIObject, triggeringPrincipal: this.principal, }); }, @@ -952,16 +950,14 @@ nsContextMenu.prototype = { let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal(); if (this.onCanvas) { this._canvasToBlobURL(this.target).then(function(blobURL) { - openUILink(blobURL, e, { disallowInheritPrincipal: true, - referrerURI, + openUILink(blobURL, e, { referrerURI, triggeringPrincipal: systemPrincipal}); }, Cu.reportError); } else { urlSecurityCheck(this.mediaURL, this.principal, Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT); - openUILink(this.mediaURL, e, { disallowInheritPrincipal: true, - referrerURI, + openUILink(this.mediaURL, e, { referrerURI, forceAllowDataURI: true, triggeringPrincipal: this.principal, }); @@ -1018,8 +1014,7 @@ nsContextMenu.prototype = { this.principal, Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT); - openUILink(this.bgImageURL, e, { disallowInheritPrincipal: true, - referrerURI: gContextMenuContentData.documentURIObject, + openUILink(this.bgImageURL, e, { referrerURI: gContextMenuContentData.documentURIObject, triggeringPrincipal: this.principal, }); }, diff --git a/browser/base/content/tabbrowser.js b/browser/base/content/tabbrowser.js index 46001b928624..ee1a357b9b74 100644 --- a/browser/base/content/tabbrowser.js +++ b/browser/base/content/tabbrowser.js @@ -1330,6 +1330,7 @@ window._gBrowser = { var aReferrerPolicy; var aFromExternal; var aRelatedToCurrent; + var aAllowInheritPrincipal; var aAllowMixedContent; var aSkipAnimation; var aForceNotRemote; @@ -1357,6 +1358,7 @@ window._gBrowser = { aAllowThirdPartyFixup = params.allowThirdPartyFixup; aFromExternal = params.fromExternal; aRelatedToCurrent = params.relatedToCurrent; + aAllowInheritPrincipal = !!params.allowInheritPrincipal; aAllowMixedContent = params.allowMixedContent; aSkipAnimation = params.skipAnimation; aForceNotRemote = params.forceNotRemote; @@ -1389,6 +1391,7 @@ window._gBrowser = { charset: aCharset, postData: aPostData, ownerTab: owner, + allowInheritPrincipal: aAllowInheritPrincipal, allowThirdPartyFixup: aAllowThirdPartyFixup, fromExternal: aFromExternal, relatedToCurrent: aRelatedToCurrent, @@ -2165,12 +2168,12 @@ window._gBrowser = { // eslint-disable-next-line complexity addTab(aURI, { + allowInheritPrincipal, allowMixedContent, allowThirdPartyFixup, bulkOrderedOpen, charset, createLazyBrowser, - disallowInheritPrincipal, eventDetail, focusUrlBar, forceNotRemote, @@ -2472,7 +2475,7 @@ window._gBrowser = { // If we didn't swap docShells with a preloaded browser // then let's just continue loading the page normally. - if (!usingPreloadedContent && (!uriIsAboutBlank || disallowInheritPrincipal)) { + if (!usingPreloadedContent && (!uriIsAboutBlank || !allowInheritPrincipal)) { // pretend the user typed this so it'll be available till // the document successfully loads if (aURI && !gInitialPages.includes(aURI)) { @@ -2490,7 +2493,7 @@ window._gBrowser = { if (allowMixedContent) { flags |= Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_MIXED_CONTENT; } - if (disallowInheritPrincipal) { + if (!allowInheritPrincipal) { flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL; } try { diff --git a/browser/base/content/test/contextMenu/browser.ini b/browser/base/content/test/contextMenu/browser.ini index 916fa378934d..9bdb5afbf377 100644 --- a/browser/base/content/test/contextMenu/browser.ini +++ b/browser/base/content/test/contextMenu/browser.ini @@ -7,3 +7,5 @@ support-files = [browser_contextmenu_touch.js] skip-if = !(os == 'win' && os_version == '10.0') [browser_contextmenu_linkopen.js] +[browser_utilityOverlay.js] +[browser_utilityOverlayPrincipal.js] diff --git a/browser/base/content/test/general/browser_utilityOverlay.js b/browser/base/content/test/contextMenu/browser_utilityOverlay.js similarity index 99% rename from browser/base/content/test/general/browser_utilityOverlay.js rename to browser/base/content/test/contextMenu/browser_utilityOverlay.js index 15301f3d5611..f3733de5ed4f 100644 --- a/browser/base/content/test/general/browser_utilityOverlay.js +++ b/browser/base/content/test/contextMenu/browser_utilityOverlay.js @@ -7,7 +7,7 @@ const gTests = [ test_getTopWin, test_getBoolPref, test_openNewTabWith, - test_openUILink + test_openUILink, ]; function test() { diff --git a/browser/base/content/test/contextMenu/browser_utilityOverlayPrincipal.js b/browser/base/content/test/contextMenu/browser_utilityOverlayPrincipal.js new file mode 100644 index 000000000000..48bc095ca2e2 --- /dev/null +++ b/browser/base/content/test/contextMenu/browser_utilityOverlayPrincipal.js @@ -0,0 +1,54 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const gTests = [ + test_openUILink_checkPrincipal, +]; + +function test() { + waitForExplicitFinish(); + executeSoon(runNextTest); +} + +function runNextTest() { + if (gTests.length) { + let testFun = gTests.shift(); + info("Running " + testFun.name); + testFun(); + } else { + finish(); + } +} + +function test_openUILink_checkPrincipal() { + let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "http://example.com/"); // remote tab + BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(async function() { + is(tab.linkedBrowser.currentURI.spec, "http://example.com/", "example.com loaded"); + + await ContentTask.spawn(tab.linkedBrowser, null, function() { + let channel = content.docShell.currentDocumentChannel; + + const loadingPrincipal = channel.loadInfo.loadingPrincipal; + is(loadingPrincipal, null, "sanity: correct loadingPrincipal"); + const triggeringPrincipal = channel.loadInfo.triggeringPrincipal; + ok(Services.scriptSecurityManager.isSystemPrincipal(triggeringPrincipal), + "sanity: correct triggeringPrincipal"); + const principalToInherit = channel.loadInfo.principalToInherit; + ok(principalToInherit.isNullPrincipal, "sanity: correct principalToInherit"); + ok(content.document.nodePrincipal.isCodebasePrincipal, + "sanity: correct doc.nodePrincipal"); + is(content.document.nodePrincipal.URI.asciiSpec, "http://example.com/", + "sanity: correct doc.nodePrincipal URL"); + }); + + gBrowser.removeCurrentTab(); + runNextTest(); + + }); + + // Ensure we get the correct default of "allowInheritPrincipal: false" from openUILink + openUILink("http://example.com", null, { + triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal({}), + }); // defaults to "current" +} diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index eabc6b1ea451..ab156c36162c 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -472,8 +472,6 @@ support-files = # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. [browser_unloaddialogs.js] # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. -[browser_utilityOverlay.js] -# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. [browser_viewSourceInTabOnViewSource.js] # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. [browser_visibleFindSelection.js] diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml index 9dff48d9a3b3..fb653f6e6e69 100644 --- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -932,7 +932,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. params.targetBrowser = browser; params.indicateErrorPageLoad = true; params.allowPinnedTabHostChange = true; - params.disallowInheritPrincipal = !mayInheritPrincipal; + params.allowInheritPrincipal = mayInheritPrincipal; params.allowPopups = url.startsWith("javascript:"); } else { params.initiatingDoc = document; diff --git a/browser/base/content/utilityOverlay.js b/browser/base/content/utilityOverlay.js index 76b6899dede5..829659156bba 100644 --- a/browser/base/content/utilityOverlay.js +++ b/browser/base/content/utilityOverlay.js @@ -282,10 +282,10 @@ function openLinkIn(url, where, params) { var aReferrerPolicy = ("referrerPolicy" in params ? params.referrerPolicy : Ci.nsIHttpChannel.REFERRER_POLICY_UNSET); var aRelatedToCurrent = params.relatedToCurrent; + var aAllowInheritPrincipal = !!params.allowInheritPrincipal; var aAllowMixedContent = params.allowMixedContent; var aForceAllowDataURI = params.forceAllowDataURI; var aInBackground = params.inBackground; - var aDisallowInheritPrincipal = params.disallowInheritPrincipal; var aInitiatingDoc = params.initiatingDoc; var aIsPrivate = params.private; var aSkipTabAnimation = params.skipTabAnimation; @@ -482,12 +482,10 @@ function openLinkIn(url, where, params) { flags |= Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; flags |= Ci.nsIWebNavigation.LOAD_FLAGS_FIXUP_SCHEME_TYPOS; } - // LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL isn't supported for javascript URIs, // i.e. it causes them not to load at all. Callers should strip - // "javascript:" from pasted strings to protect users from malicious URIs - // (see stripUnsafeProtocolOnPaste). - if (aDisallowInheritPrincipal && !(uriObj && uriObj.schemeIs("javascript"))) { + // "javascript:" from pasted strings to prevent blank tabs + if (!aAllowInheritPrincipal) { flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL; } @@ -545,6 +543,7 @@ function openLinkIn(url, where, params) { userContextId: aUserContextId, originPrincipal: aPrincipal, triggeringPrincipal: aTriggeringPrincipal, + allowInheritPrincipal: aAllowInheritPrincipal, focusUrlBar, }); targetBrowser = tabUsedForLoad.linkedBrowser; diff --git a/browser/components/extensions/parent/ext-tabs.js b/browser/components/extensions/parent/ext-tabs.js index 5ee04ac5580e..1e4ce81073c4 100644 --- a/browser/components/extensions/parent/ext-tabs.js +++ b/browser/components/extensions/parent/ext-tabs.js @@ -572,7 +572,7 @@ this.tabs = class extends ExtensionAPI { } else { url = window.BROWSER_NEW_TAB_URL; } - // Only set disallowInheritPrincipal on non-discardable urls as it + // Only set allowInheritPrincipal on discardable urls as it // will override creating a lazy browser. Setting triggeringPrincipal // will ensure other cases are handled, but setting it may prevent // creating about and data urls. @@ -580,12 +580,15 @@ this.tabs = class extends ExtensionAPI { if (!discardable) { // Make sure things like about:blank and data: URIs never inherit, // and instead always get a NullPrincipal. - options.disallowInheritPrincipal = true; + options.allowInheritPrincipal = false; // Falling back to codebase here as about: requires it, however is safe. principal = Services.scriptSecurityManager.createCodebasePrincipal(Services.io.newURI(url), { userContextId: options.userContextId, privateBrowsingId: PrivateBrowsingUtils.isBrowserPrivate(window.gBrowser) ? 1 : 0, }); + } else { + options.allowInheritPrincipal = true; + options.triggeringPrincipal = context.principal; } tabListener.initTabReady(); diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.jsm index 3605f5663287..87bb0d5dae19 100644 --- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.jsm @@ -3498,6 +3498,7 @@ var SessionStoreInternal = { tab = tabbrowser.addTrustedTab(url, { createLazyBrowser, skipAnimation: true, + allowInheritPrincipal: true, noInitialLabel: true, userContextId, skipBackgroundNotify: true, diff --git a/browser/modules/ContentClick.jsm b/browser/modules/ContentClick.jsm index 9f3176abcf77..7445d5992f33 100644 --- a/browser/modules/ContentClick.jsm +++ b/browser/modules/ContentClick.jsm @@ -77,6 +77,8 @@ var ContentClick = { params.userContextId = json.originAttributes.userContextId; } + params.allowInheritPrincipal = true; + window.openLinkIn(json.href, where, params); } }; diff --git a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm index ff078c1bf359..d1c340d5a768 100644 --- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm +++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm @@ -1785,6 +1785,9 @@ var BrowserTestUtils = { if (!params.triggeringPrincipal) { params.triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal(); } + if (!params.allowInheritPrincipal) { + params.allowInheritPrincipal = true; + } if (beforeLoadFunc) { let window = tabbrowser.ownerGlobal; window.addEventListener("TabOpen", function(e) { diff --git a/testing/web-platform/meta/html/semantics/embedded-content/media-elements/autoplay-with-broken-track.html.ini b/testing/web-platform/meta/html/semantics/embedded-content/media-elements/autoplay-with-broken-track.html.ini index 885fa3c85e82..1df69d7c033f 100644 --- a/testing/web-platform/meta/html/semantics/embedded-content/media-elements/autoplay-with-broken-track.html.ini +++ b/testing/web-platform/meta/html/semantics/embedded-content/media-elements/autoplay-with-broken-track.html.ini @@ -1,8 +1,9 @@ [autoplay-with-broken-track.html] expected: TIMEOUT + disabled: + if debug and (os == "linux") and (processor == "x86") and (bits == 32): https://bugzilla.mozilla.org/show_bug.cgi?id=1482405 [