Bug 1484826 [wpt PR 12577] - Don't allow popups during page unloading times., a=testonly

Automatic update from web-platform-testsDon't allow popups during page unloading times.

Precisely, this disallows them when the event loop's
termination nesting level is nonzero.

This is now part of the spec,
https://html.spec.whatwg.org/#apis-for-creating-and-navigating-browsing-contexts-by-name

> The window open steps, given a string url, a string target, and a string features, are as follows:
> 1. If the event loop's termination nesting level is nonzero, return null.

BUG=844455

Change-Id: I85fb003063f5ed051049c7c263391835421902ac
Reviewed-on: https://chromium-review.googlesource.com/c/1180296
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Nate Chapin <japhet@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605025}

--

wpt-commits: ffeba23ebd16b9adb2e0e2b5fe6923fef9bb9e5e
wpt-pr: 12577
This commit is contained in:
Avi Drissman 2018-11-09 17:25:43 +00:00 коммит произвёл moz-wptsync-bot
Родитель 61c9346f74
Коммит 3682c4249e
1 изменённых файлов: 113 добавлений и 0 удалений

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

@ -0,0 +1,113 @@
test(function() {
var test_window = window.open('', '', 'height=1,width=1');
var test_document = test_window.document;
var frame = test_document.createElement('iframe');
test_document.body.appendChild(frame);
frame.contentWindow.onpagehide = function(evt) {
assert_equals(frame.contentWindow.open('', '', 'height=1,width=1'), null,
"expected no popup during pagehide");
};
frame.contentDocument.onvisibilitychange = function(evt) {
assert_equals(frame.contentWindow.open('', '', 'height=1,width=1'), null,
"expected no popup during visibilitychange");
};
frame.contentWindow.onbeforeunload = function(evt) {
assert_equals(frame.contentWindow.open('', '', 'height=1,width=1'), null,
"expected no popup during beforeunload");
};
frame.contentWindow.onunload = function(evt) {
assert_equals(frame.contentWindow.open('', '', 'height=1,width=1'), null,
"expected no popup during unload");
};
frame.remove();
}, 'no popups with frame removal');
async_test(function(t) {
var test_window = window.open('', '', 'height=1,width=1');
var test_document = test_window.document;
var frame = test_document.createElement('iframe');
test_document.body.appendChild(frame);
frame.contentWindow.onpagehide = t.step_func(function(evt) {
assert_equals(frame.contentWindow.open('', '', 'height=1,width=1'), null,
"expected no popup during pagehide");
});
frame.contentDocument.onvisibilitychange = t.step_func(function(evt) {
assert_equals(frame.contentWindow.open('', '', 'height=1,width=1'), null,
"expected no popup during visibilitychange");
});
frame.contentWindow.onbeforeunload = t.step_func(function(evt) {
assert_equals(frame.contentWindow.open('', '', 'height=1,width=1'), null,
"expected no popup during beforeunload");
});
frame.contentWindow.onunload = t.step_func(function(evt) {
assert_equals(frame.contentWindow.open('', '', 'height=1,width=1'), null,
"expected no popup during unload");
});
frame.onload = t.step_func_done();
frame.contentWindow.location.href = "about:blank";
}, 'no popups with frame navigation');
async_test(function(t) {
var test_window = window.open('', '', 'height=1,width=1');
var test_document = test_window.document;
var frame = test_document.createElement('iframe');
test_document.body.appendChild(frame);
frame.contentWindow.onpagehide = t.step_func(function(evt) {
assert_equals(test_window.open('', '', 'height=1,width=1'), null,
"expected no popup during pagehide");
});
frame.contentDocument.onvisibilitychange = t.step_func(function(evt) {
assert_equals(test_window.open('', '', 'height=1,width=1'), null,
"expected no popup during visibilitychange");
});
frame.contentWindow.onbeforeunload = t.step_func(function(evt) {
assert_equals(test_window.open('', '', 'height=1,width=1'), null,
"expected no popup during beforeunload");
});
frame.contentWindow.onunload = t.step_func(function(evt) {
assert_equals(test_window.open('', '', 'height=1,width=1'), null,
"expected no popup during unload");
});
frame.onload = t.step_func_done();
frame.contentWindow.location.href = "about:blank";
}, 'no popups from synchronously reachable window');
async_test(function(t) {
var test_window = window.open('', '', 'height=1,width=1');
var test_document = test_window.document;
var frame = test_document.createElement('iframe');
test_document.body.appendChild(frame);
frame.contentWindow.onpagehide = t.step_func(function(evt) {
assert_equals(window.open('', '', 'height=1,width=1'), null,
"expected no popup during pagehide");
});
frame.contentDocument.onvisibilitychange = t.step_func(function(evt) {
assert_equals(window.open('', '', 'height=1,width=1'), null,
"expected no popup during visibilitychange");
});
frame.contentWindow.onbeforeunload = t.step_func(function(evt) {
assert_equals(window.open('', '', 'height=1,width=1'), null,
"expected no popup during beforeunload");
});
frame.contentWindow.onunload = t.step_func(function(evt) {
assert_equals(window.open('', '', 'height=1,width=1'), null,
"expected no popup during unload");
});
frame.onload = t.step_func_done();
frame.contentWindow.location.href = "about:blank";
}, 'no popups from another synchronously reachable window');