Bug 1591736 - Fix AddonManagerWebAPI::IsAPIEnabled in out-of-process iframes r=mixedpuppy

Differential Revision: https://phabricator.services.mozilla.com/D50713

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tomislav Jovanovic 2019-10-28 21:51:30 +00:00
Родитель 074c0fe3ca
Коммит c9669e07c3
4 изменённых файлов: 9 добавлений и 16 удалений

Просмотреть файл

@ -108,17 +108,20 @@ bool AddonManagerWebAPI::IsAPIEnabled(JSContext* aCx, JSObject* aGlobal) {
}
// Checks whether there is a parent frame of the same type. This won't cross
// mozbrowser or chrome boundaries.
// mozbrowser or chrome or fission/process boundaries.
nsCOMPtr<nsIDocShellTreeItem> parent;
nsresult rv = docShell->GetInProcessSameTypeParent(getter_AddRefs(parent));
if (NS_FAILED(rv)) {
return false;
}
// No parent means we've hit a mozbrowser or chrome or process boundary.
if (!parent) {
// No parent means we've hit a mozbrowser or chrome boundary so allow
// access to the API.
return true;
// With Fission, a cross-origin iframe has an out-of-process parent, but
// DocShell knows nothing about it. We need to ask BrowsingContext here,
// and only allow API access if AMO is actually at the top, not framed
// by evilleagueofevil.com.
return docShell->GetBrowsingContext()->IsTopContent();
}
Document* doc = win->GetDoc();

Просмотреть файл

@ -108,12 +108,9 @@ skip-if = verify
support-files =
head_abuse_report.js
[browser_webapi_access.js]
skip-if = fission
[browser_webapi_addon_listener.js]
skip-if = fission
[browser_webapi_enable.js]
[browser_webapi_install.js]
skip-if = fission && debug
[browser_webapi_install_disabled.js]
[browser_webapi_theme.js]
[browser_webapi_uninstall.js]

Просмотреть файл

@ -7,17 +7,11 @@ registerCleanupFunction(() => {
});
function check_frame_availability(browser) {
return ContentTask.spawn(browser, null, async function() {
let frame = content.document.getElementById("frame");
return (
frame.contentWindow.document.getElementById("result").textContent ==
"true"
);
});
return check_availability(browser.browsingContext.getChildren()[0]);
}
function check_availability(browser) {
return ContentTask.spawn(browser, null, async function() {
return SpecialPowers.spawn(browser, [], async function() {
return content.document.getElementById("result").textContent == "true";
});
}

Просмотреть файл

@ -81,6 +81,5 @@ skip-if = require_signing
[browser_unsigned_trigger_iframe.js]
skip-if = require_signing
[browser_unsigned_trigger_xorigin.js]
skip-if = fission
[browser_unsigned_url.js]
skip-if = require_signing