mirror of
https://github.com/servo/servo.git
synced 2025-08-08 15:05:35 +01:00
Update web-platform-tests to revision 58eb04cecbbec2e18531ab440225e38944a9c444
This commit is contained in:
parent
25e8bf69e6
commit
665817d2a6
35333 changed files with 1818077 additions and 16036 deletions
|
@ -11,43 +11,82 @@
|
|||
<script>
|
||||
"use strict";
|
||||
|
||||
async_test(t => {
|
||||
promise_test(t => {
|
||||
let onbeforeunloadHappened = false;
|
||||
window.onbeforeunload = t.step_func(() => {
|
||||
onbeforeunloadHappened = true;
|
||||
return "cancel me";
|
||||
});
|
||||
|
||||
const listener = t.step_func(e => {
|
||||
const eventWatcher = new EventWatcher(t, window, "beforeunload");
|
||||
const promise = eventWatcher.wait_for("beforeunload").then(e => {
|
||||
assert_true(onbeforeunloadHappened, "CustomEvent must be able to trigger the event handler");
|
||||
assert_false(e.defaultPrevented, "The event must not have been canceled");
|
||||
window.onbeforeunload = null;
|
||||
t.done();
|
||||
});
|
||||
|
||||
window.addEventListener("beforeunload", listener);
|
||||
|
||||
window.dispatchEvent(new CustomEvent("beforeunload"));
|
||||
|
||||
return promise;
|
||||
}, "Returning a string must not cancel the event: CustomEvent, non-cancelable");
|
||||
|
||||
async_test(t => {
|
||||
promise_test(t => {
|
||||
let onbeforeunloadHappened = false;
|
||||
window.onbeforeunload = t.step_func(() => {
|
||||
onbeforeunloadHappened = true;
|
||||
return "cancel me";
|
||||
});
|
||||
|
||||
const listener = t.step_func(e => {
|
||||
const eventWatcher = new EventWatcher(t, window, "beforeunload");
|
||||
const promise = eventWatcher.wait_for("beforeunload").then(e => {
|
||||
assert_true(onbeforeunloadHappened, "CustomEvent must be able to trigger the event handler");
|
||||
assert_false(e.defaultPrevented, "The event must not have been canceled");
|
||||
window.onbeforeunload = null;
|
||||
t.done();
|
||||
});
|
||||
|
||||
window.addEventListener("beforeunload", listener);
|
||||
window.dispatchEvent(new CustomEvent("beforeunload", { cancelable: true }));
|
||||
|
||||
return promise;
|
||||
}, "Returning a string must not cancel the event: CustomEvent, cancelable");
|
||||
|
||||
promise_test(t => {
|
||||
let onbeforeunloadHappened = false;
|
||||
window.onbeforeunload = t.step_func(() => {
|
||||
onbeforeunloadHappened = true;
|
||||
return false;
|
||||
});
|
||||
|
||||
const eventWatcher = new EventWatcher(t, window, "beforeunload");
|
||||
const promise = eventWatcher.wait_for("beforeunload").then(e => {
|
||||
assert_true(onbeforeunloadHappened, "CustomEvent must be able to trigger the event handler");
|
||||
assert_false(e.defaultPrevented, "The event must not have been canceled");
|
||||
window.onbeforeunload = null;
|
||||
t.done();
|
||||
});
|
||||
|
||||
window.dispatchEvent(new CustomEvent("beforeunload", { cancelable: true }));
|
||||
}, "Returning a string must not cancel the event: CustomEvent, cancelable");
|
||||
|
||||
return promise;
|
||||
}, "Returning false must not cancel the event, because it's coerced to the DOMString \"false\" which does not cancel " +
|
||||
"CustomEvents: CustomEvent, cancelable");
|
||||
|
||||
// This test can be removed if we update the DOM Standard to disallow createEvent("BeforeUnloadEvent"). Browser support
|
||||
// is inconsistent. https://github.com/whatwg/dom/issues/362
|
||||
promise_test(t => {
|
||||
const eventWatcher = new EventWatcher(t, window, "click");
|
||||
const promise = eventWatcher.wait_for("click").then(e => {
|
||||
assert_false(e.defaultPrevented, "The event must not have been canceled");
|
||||
window.onbeforeunload = null;
|
||||
t.done();
|
||||
});
|
||||
|
||||
const ev = document.createEvent("BeforeUnloadEvent");
|
||||
ev.initEvent("click", false, true);
|
||||
window.dispatchEvent(ev);
|
||||
|
||||
return promise;
|
||||
}, "Returning a string must not cancel the event: BeforeUnloadEvent with type \"click\", cancelable");
|
||||
|
||||
const testCases = [
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue