Update web-platform-tests to revision 132d12daea699ce266324e79eecbe59b10e56502

This commit is contained in:
WPT Sync Bot 2018-06-08 21:05:21 -04:00
parent 527d874bc1
commit fe00a63040
1004 changed files with 18598 additions and 92770 deletions

View file

@ -18,11 +18,11 @@ window.onload = t.step_func(function () {
location.hash = 'foo';
window.onhashchange = t.step_func(function (e) {
assert_true(e.isTrusted);
assert_equals(e.target, window);
assert_equals(e.type, "hashchange");
assert_true(e instanceof HashChangeEvent);
assert_true(e.bubbles, "bubble");
assert_true(e.isTrusted, "isTrusted");
assert_equals(e.target, window, "target");
assert_equals(e.type, "hashchange", "type");
assert_true(e instanceof HashChangeEvent, "is HashChangeEvent");
assert_false(e.bubbles, "bubbles");
assert_false(e.cancelable, "cancelable");
oldURLs.push(e.oldURL);
newURLs.push(e.newURL);

View file

@ -15,6 +15,13 @@ window.onload = t.step_func(function () {
history.back();
window.onpopstate = t.step_func(function (e) {
assert_true(e.isTrusted, "isTrusted");
assert_equals(e.target, window, "target");
assert_equals(e.type, "popstate", "type");
assert_true(e instanceof PopStateEvent, "is PopStateEvent");
assert_false(e.bubbles, "bubbles");
assert_false(e.cancelable, "cancelable");
states.push(e.state);
if (states.length === 2) {

View file

@ -0,0 +1,22 @@
<!doctype html>
<title>beforeunload and unload events fire after window.close() in script-closeable browsing context</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
beforeunload_fired = false;
var t = async_test();
onload = t.step_func(function() {
window.close();
});
onbeforeunload = t.step_func(function() {
beforeunload_fired = true;
});
onunload = t.step_func(function() {
assert_true(beforeunload_fired);
t.done()
});
</script>

View file

@ -0,0 +1,10 @@
<!doctype html>
script-uncloseable-1
<script>
onbeforeunload = function() {
parent.beforeunload_fired = true;
};
onunload = function() {
parent.unload_fired = true;
};
</script>

View file

@ -0,0 +1,24 @@
<!doctype html>
<title>beforeunload and unload events do not fire after window.close() in script-uncloseable browsing context</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var beforeunload_fired = false;
var unload_fired = false;
var t = async_test();
onload = t.step_func(function() {
var iframe = document.getElementsByTagName("iframe")[0]
iframe.onload = t.step_func(function() {
iframe.contentWindow.close()
t.step_timeout(function() {
assert_false(beforeunload_fired);
assert_false(unload_fired);
t.done();
}, 1000);
});
iframe.src = "prompt-and-unload-script-uncloseable-1.html";
});
</script>
<iframe></iframe>

View file

@ -0,0 +1,28 @@
<!doctype html>
004-1
<script>
var handleBeforeUnload = function() {
parent.beforeunload_fired = true;
removeListener();
setTimeout(function() {
parent.timeout_fired = true;
}, 1000);
}
var removeListener = function() {
assert_true(window.removeEventListener('beforeunload', handleBeforeUnload, false));
}
window.addEventListener('beforeunload', handleBeforeUnload, false);
onload = function() {
if (!parent.loaded) {
parent.loaded = true;
location="004-2.html?" + Math.random();
}
}
</script>
// child frame with no onbeforeunload listener. Should leave the parent as unsalvageable.
// Adding the iframe prevents potential implementation bugs where the the recursive steps of #prompt-to-unload-a-document
// would overwrite the salvageable state of the parent.
<iframe></iframe>

View file

@ -0,0 +1,5 @@
<!doctype html>
004-2
<script>
onload = function() {setTimeout(parent.t.step_func(function() {parent.start_test(); history.go(-1)}), 100)}
</script>

View file

@ -0,0 +1,29 @@
<!doctype html>
<title>salvagable state of document after setting beforeunload listener</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var t = async_test();
var loaded = false;
var beforeunload_fired = false;
var timeout_fired = false;
function start_test() {
step_timeout(
t.step_func(function() {
assert_true(beforeunload_fired);
assert_false(timeout_fired);
t.done()
}), 1000);
}
onload = function() {
var iframe = document.getElementsByTagName("iframe")[0]
onload = null;
iframe.src="004-1.html?" + Math.random();
};
</script>
<iframe></iframe>

View file

@ -1,6 +1,12 @@
<!doctype html>
<meta charset=utf-8>
<title>window.open() with "noopener" tests</title>
<meta name="variant" content="?indexed">
<meta name="variant" content="?_self">
<meta name="variant" content="?_parent">
<meta name="variant" content="?_top">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
@ -28,7 +34,6 @@ var testData = [
shouldReuse: false },
];
var tests = [];
/**
* Loop over our testData array and kick off an async test for each entry. Each
* async test opens a window using window.open() with some per-test unique name,
@ -39,56 +44,59 @@ var tests = [];
* cases and non-null in the cases when the existing window gets reused) and so
* forth.
*/
for (var i = 0; i < testData.length; ++i) {
var test = testData[i];
var t = async_test(test.testDescription);
tests.push(t);
t.secondWindowFeatureString = test.secondWindowFeatureString;
t.windowName = "someuniquename" + i;
function indexedTests() {
var tests = [];
for(var i = 0; i < testData.length; ++i) {
var test = testData[i];
var t = async_test(test.testDescription);
tests.push(t);
t.secondWindowFeatureString = test.secondWindowFeatureString;
t.windowName = "someuniquename" + i;
if (test.shouldReuse) {
t.step(function() {
var windowName = this.windowName;
if (test.shouldReuse) {
t.step(function() {
var windowName = this.windowName;
var w1 = window.open("", windowName);
this.add_cleanup(function() { w1.close(); });
var w1 = window.open("", windowName);
this.add_cleanup(function() { w1.close(); });
assert_equals(w1.opener, window);
var w2 = window.open("", windowName, this.secondWindowFeatureString);
assert_equals(w2, w1);
assert_equals(w2.opener, w1.opener);
assert_equals(w2.opener, window);
this.done();
});
} else {
t.step(function() {
var w1;
this.add_cleanup(function() {
w1.close();
channel.postMessage(null);
});
var windowName = this.windowName;
var channel = new BroadcastChannel(windowName);
channel.onmessage = this.step_func_done(function(e) {
var data = e.data;
assert_equals(data.name, windowName, "Should have the right name");
assert_equals(data.haveOpener, false, "Should not have opener");
assert_equals(w1.opener, window);
assert_equals(w1.location.href, "about:blank");
var w2 = window.open("", windowName, this.secondWindowFeatureString);
assert_equals(w2, w1);
assert_equals(w2.opener, w1.opener);
assert_equals(w2.opener, window);
this.done();
});
} else {
t.step(function() {
var w1;
this.add_cleanup(function() {
w1.close();
channel.postMessage(null);
});
w1 = window.open("", windowName);
assert_equals(w1.opener, window);
var windowName = this.windowName;
var channel = new BroadcastChannel(windowName);
var w2 = window.open("support/noopener-target.html?" + windowName,
windowName, this.secondWindowFeatureString);
assert_equals(w2, null);
channel.onmessage = this.step_func_done(function(e) {
var data = e.data;
assert_equals(data.name, windowName, "Should have the right name");
assert_equals(data.haveOpener, false, "Should not have opener");
assert_equals(w1.opener, window);
assert_equals(w1.location.href, "about:blank");
});
assert_equals(w1.opener, window);
});
w1 = window.open("", windowName);
assert_equals(w1.opener, window);
var w2 = window.open("support/noopener-target.html?" + windowName,
windowName, this.secondWindowFeatureString);
assert_equals(w2, null);
assert_equals(w1.opener, window);
});
}
}
}
@ -96,13 +104,27 @@ for (var i = 0; i < testData.length; ++i) {
* Loop over the special targets that ignore noopener and check that doing a
* window.open() with those targets correctly reuses the existing window.
*/
for (var target of ["_self", "_parent", "_top"]) {
var t = async_test("noopener window.open targeting " + target);
tests.push(t);
t.openedWindow = window.open(`javascript:var w2 = window.open("", "${target}", "noopener"); this.checkValues(w2); this.close(); void(0);`);
assert_equals(t.openedWindow.opener, window);
t.openedWindow.checkValues = t.step_func_done(function(win) {
assert_equals(win, this.openedWindow);
});
function specialTargetTest(target) {
if (["_self", "_parent", "_top"].includes(target)) {
var t = async_test("noopener window.open targeting " + target);
t.openedWindow = window.open(`javascript:var w2 = window.open("", "${target}", "noopener"); this.checkValues(w2); this.close(); void(0);`);
assert_equals(t.openedWindow.opener, window);
t.openedWindow.checkValues = t.step_func_done(function(win) {
assert_equals(win, this.openedWindow);
});
} else {
throw 'testError: special target must be one of: _self, _parent, _top'
}
}
/**
* Parse the Query string, check if it matches keyword 'indexed' to run the indexed tests,
* otherwise test it as a special target
*/
var variant = window.location.href.split("?")[1]
if(variant == "indexed") {
indexedTests();
} else {
specialTargetTest(variant);
}
</script>