зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 5eacf74bc04f (bug 1643450) for causing android mochitest failures in test_window_open_from_closing.html
CLOSED TREE
This commit is contained in:
Родитель
1f2fddbde8
Коммит
67eecb03bf
|
@ -1739,19 +1739,8 @@ bool BrowsingContext::RemoveRootFromBFCacheSync() {
|
|||
|
||||
nsresult BrowsingContext::CheckSandboxFlags(nsDocShellLoadState* aLoadState) {
|
||||
const auto& sourceBC = aLoadState->SourceBrowsingContext();
|
||||
if (sourceBC.IsNull()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// We might be called after the source BC has been discarded, but before we've
|
||||
// destroyed our in-process instance of the BrowsingContext object in some
|
||||
// situations (e.g. after creating a new pop-up with window.open while the
|
||||
// window is being closed). In these situations we want to still perform the
|
||||
// sandboxing check against our in-process copy. If we've forgotten about the
|
||||
// context already, assume it is sanboxed. (bug 1643450)
|
||||
BrowsingContext* bc = sourceBC.GetMaybeDiscarded();
|
||||
if (!bc || bc->IsSandboxedFrom(this)) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
if (sourceBC.IsDiscarded() || (sourceBC && sourceBC->IsSandboxedFrom(this))) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<h1>file_broadcast_load.html</h1>
|
||||
<script>
|
||||
let channel = new BroadcastChannel("test");
|
||||
channel.onmessage = function(e) {
|
||||
console.log("file_broadcast_load.html got message:", e.data);
|
||||
if (e.data == "close") {
|
||||
window.close();
|
||||
}
|
||||
};
|
||||
|
||||
addEventListener("load", function() {
|
||||
console.log("file_broadcast_load.html loaded");
|
||||
channel.postMessage("load");
|
||||
});
|
||||
</script>
|
|
@ -1,20 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<script>
|
||||
console.log("loading file_window_close_and_open.html");
|
||||
addEventListener("load", function() {
|
||||
console.log("got load event!");
|
||||
let link = document.querySelector("a");
|
||||
if (window.location.hash === "#noopener") {
|
||||
link.setAttribute("rel", "noopener");
|
||||
} else if (window.location.hash === "#opener") {
|
||||
link.setAttribute("rel", "opener");
|
||||
}
|
||||
link.click();
|
||||
});
|
||||
</script>
|
||||
<body>
|
||||
<h1>close and re-open popup</h1>
|
||||
<a href="file_broadcast_load.html" target="_blank" onclick="window.close()">close and open</a>
|
||||
</body>
|
||||
</html>
|
|
@ -610,7 +610,3 @@ support-files =
|
|||
[test_nestediframe.html]
|
||||
skip-if = sessionHistoryInParent
|
||||
[test_multipleFilePicker.html]
|
||||
[test_window_open_from_closing.html]
|
||||
support-files =
|
||||
file_window_close_and_open.html
|
||||
file_broadcast_load.html
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.open from a window being closed</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>window.open from a window being closed</h1>
|
||||
<script>
|
||||
add_task(async function() {
|
||||
const RELS = ["", "#noopener", "#opener"];
|
||||
const FEATURES = [
|
||||
"",
|
||||
"noopener",
|
||||
"width=300",
|
||||
"width=300,noopener",
|
||||
];
|
||||
|
||||
let resolver;
|
||||
let channel = new BroadcastChannel("test");
|
||||
channel.onmessage = function(e) {
|
||||
info("message from broadcastchannel: " + e.data);
|
||||
if (e.data == "load") {
|
||||
resolver();
|
||||
}
|
||||
};
|
||||
|
||||
for (let rel of RELS) {
|
||||
for (let feature of FEATURES) {
|
||||
info(`running test: rel=${rel}, feature=${feature}`);
|
||||
|
||||
let loadPromise = new Promise(r => { resolver = r; });
|
||||
window.open("file_window_close_and_open.html" + rel, "_blank", feature);
|
||||
await loadPromise;
|
||||
ok(true, "popup opened successfully - closing...");
|
||||
channel.postMessage("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -5292,9 +5292,8 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindow(
|
|||
}
|
||||
});
|
||||
|
||||
// Don't continue to try to create a new window if we've been fully discarded.
|
||||
RefPtr<BrowsingContext> parent = aParent.GetMaybeDiscarded();
|
||||
if (NS_WARN_IF(!parent)) {
|
||||
// Don't continue to try to create a new window if we've been discarded.
|
||||
if (aParent.IsDiscarded()) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
return IPC_OK();
|
||||
}
|
||||
|
@ -5305,8 +5304,8 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindow(
|
|||
return IPC_FAIL(this, "Missing BrowsingContext for new tab");
|
||||
}
|
||||
|
||||
uint64_t newBCOpenerId = newBC->GetOpenerId();
|
||||
if (newBCOpenerId != 0 && parent->Id() != newBCOpenerId) {
|
||||
RefPtr<BrowsingContext> newBCOpener = newBC->GetOpener();
|
||||
if (newBCOpener && aParent.get() != newBCOpener) {
|
||||
return IPC_FAIL(this, "Invalid opener BrowsingContext for new tab");
|
||||
}
|
||||
if (newBC->GetParent() != nullptr) {
|
||||
|
@ -5337,7 +5336,7 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindow(
|
|||
nsCOMPtr<nsIRemoteTab> newRemoteTab;
|
||||
int32_t openLocation = nsIBrowserDOMWindow::OPEN_NEWWINDOW;
|
||||
mozilla::ipc::IPCResult ipcResult = CommonCreateWindow(
|
||||
aThisTab, parent, newBCOpenerId != 0, aChromeFlags, aCalledFromJS,
|
||||
aThisTab, aParent.get(), !!newBCOpener, aChromeFlags, aCalledFromJS,
|
||||
aWidthSpecified, aForPrinting, aForPrintPreview, aURIToLoad, aFeatures,
|
||||
aFullZoom, newTab, VoidString(), rv, newRemoteTab, &cwi.windowOpened(),
|
||||
openLocation, aTriggeringPrincipal, aReferrerInfo, /* aLoadUri = */ false,
|
||||
|
@ -5376,9 +5375,8 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindowInDifferentProcess(
|
|||
nsIReferrerInfo* aReferrerInfo, const OriginAttributes& aOriginAttributes) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(!nsContentUtils::IsSpecialName(aName));
|
||||
|
||||
// Don't continue to try to create a new window if we've been fully discarded.
|
||||
RefPtr<BrowsingContext> parent = aParent.GetMaybeDiscarded();
|
||||
if (NS_WARN_IF(!parent)) {
|
||||
// Don't continue to try to create a new window if we've been discarded.
|
||||
if (NS_WARN_IF(aParent.IsDiscarded())) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -5413,8 +5411,8 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindowInDifferentProcess(
|
|||
|
||||
nsresult rv;
|
||||
mozilla::ipc::IPCResult ipcResult = CommonCreateWindow(
|
||||
aThisTab, parent, /* aSetOpener = */ false, aChromeFlags, aCalledFromJS,
|
||||
aWidthSpecified, /* aForPrinting = */ false,
|
||||
aThisTab, aParent.get(), /* aSetOpener = */ false, aChromeFlags,
|
||||
aCalledFromJS, aWidthSpecified, /* aForPrinting = */ false,
|
||||
/* aForPrintPreview = */ false, aURIToLoad, aFeatures, aFullZoom,
|
||||
/* aNextRemoteBrowser = */ nullptr, aName, rv, newRemoteTab, &windowIsNew,
|
||||
openLocation, aTriggeringPrincipal, aReferrerInfo,
|
||||
|
|
Загрузка…
Ссылка в новой задаче