-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This updates the tests and the status file via running `git node wpt dom/events`. PR-URL: #46051 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
- Loading branch information
1 parent
3f4c0c0
commit 7e1462d
Showing
66 changed files
with
1,883 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
test/fixtures/wpt/dom/events/Body-FrameSet-Event-Handlers.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<title>HTMLBodyElement and HTMLFrameSetElement Event Handler Tests</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<script> | ||
function getObject(interface) { | ||
switch(interface) { | ||
case "Element": | ||
var e = document.createElementNS("http://example.com/", "example"); | ||
assert_true(e instanceof Element); | ||
assert_false(e instanceof HTMLElement); | ||
assert_false(e instanceof SVGElement); | ||
return e; | ||
case "HTMLElement": | ||
var e = document.createElement("html"); | ||
assert_true(e instanceof HTMLElement); | ||
return e; | ||
case "HTMLBodyElement": | ||
var e = document.createElement("body"); | ||
assert_true(e instanceof HTMLBodyElement); | ||
return e; | ||
case "HTMLFormElement": | ||
var e = document.createElement("form"); | ||
assert_true(e instanceof HTMLFormElement); | ||
return e; | ||
case "HTMLFrameSetElement": | ||
var e = document.createElement("frameset"); | ||
assert_true(e instanceof HTMLFrameSetElement); | ||
return e; | ||
case "SVGElement": | ||
var e = document.createElementNS("http://www.w3.org/2000/svg", "rect"); | ||
assert_true(e instanceof SVGElement); | ||
return e; | ||
case "Document": | ||
assert_true(document instanceof Document); | ||
return document; | ||
case "Window": | ||
assert_true(window instanceof Window); | ||
return window; | ||
} | ||
assert_unreached(); | ||
} | ||
|
||
function testSet(interface, attribute) { | ||
test(function() { | ||
var object = getObject(interface); | ||
function nop() {} | ||
assert_equals(object[attribute], null, "Initially null"); | ||
object[attribute] = nop; | ||
assert_equals(object[attribute], nop, "Return same function"); | ||
object[attribute] = ""; | ||
assert_equals(object[attribute], null, "Return null after setting string"); | ||
object[attribute] = null; | ||
assert_equals(object[attribute], null, "Finally null"); | ||
}, "Set " + interface + "." + attribute); | ||
} | ||
|
||
function testReflect(interface, attribute) { | ||
test(function() { | ||
var element = getObject(interface); | ||
assert_false(element.hasAttribute(attribute), "Initially missing"); | ||
element.setAttribute(attribute, "return"); | ||
assert_equals(element.getAttribute(attribute), "return", "Return same string"); | ||
assert_equals(typeof element[attribute], "function", "Convert to function"); | ||
element.removeAttribute(attribute); | ||
}, "Reflect " + interface + "." + attribute); | ||
} | ||
|
||
function testForwardToWindow(interface, attribute) { | ||
test(function() { | ||
var element = getObject(interface); | ||
window[attribute] = null; | ||
element.setAttribute(attribute, "return"); | ||
assert_equals(typeof window[attribute], "function", "Convert to function"); | ||
assert_equals(window[attribute], element[attribute], "Forward content attribute"); | ||
function nop() {} | ||
element[attribute] = nop; | ||
assert_equals(window[attribute], nop, "Forward IDL attribute"); | ||
window[attribute] = null; | ||
}, "Forward " + interface + "." + attribute + " to Window"); | ||
} | ||
|
||
// Object.propertyIsEnumerable cannot be used because it doesn't | ||
// work with properties inherited through the prototype chain. | ||
function getEnumerable(interface) { | ||
var enumerable = {}; | ||
for (var attribute in getObject(interface)) { | ||
enumerable[attribute] = true; | ||
} | ||
return enumerable; | ||
} | ||
|
||
var enumerableCache = {}; | ||
function testEnumerate(interface, attribute) { | ||
if (!(interface in enumerableCache)) { | ||
enumerableCache[interface] = getEnumerable(interface); | ||
} | ||
test(function() { | ||
assert_true(enumerableCache[interface][attribute]); | ||
}, "Enumerate " + interface + "." + attribute); | ||
} | ||
|
||
[ | ||
"onblur", | ||
"onerror", | ||
"onfocus", | ||
"onload", | ||
"onscroll", | ||
"onresize" | ||
].forEach(function(attribute) { | ||
testSet("HTMLBodyElement", attribute); | ||
testEnumerate("HTMLBodyElement", attribute); | ||
testReflect("HTMLBodyElement", attribute); | ||
testForwardToWindow("HTMLBodyElement", attribute); | ||
testSet("HTMLFrameSetElement", attribute); | ||
testEnumerate("HTMLFrameSetElement", attribute); | ||
testReflect("HTMLFrameSetElement", attribute); | ||
testForwardToWindow("HTMLFrameSetElement", attribute); | ||
}); | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
test/fixtures/wpt/dom/events/event-global-is-still-set-when-reporting-exception-onerror.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>window.onerror handler restores window.event after it reports an exception</title> | ||
<link rel="help" href="https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<body> | ||
<iframe src="resources/empty-document.html"></iframe> | ||
<iframe src="resources/empty-document.html"></iframe> | ||
|
||
<script> | ||
setup({ allow_uncaught_exception: true }); | ||
|
||
async_test(t => { | ||
window.onload = t.step_func_done(onLoadEvent => { | ||
frames[0].onerror = new frames[1].Function(` | ||
top.eventDuringSecondOnError = top.window.event; | ||
top.frames[0].eventDuringSecondOnError = top.frames[0].event; | ||
top.frames[1].eventDuringSecondOnError = top.frames[1].event; | ||
`); | ||
|
||
window.onerror = new frames[0].Function(` | ||
top.eventDuringFirstOnError = top.window.event; | ||
top.frames[0].eventDuringFirstOnError = top.frames[0].event; | ||
top.frames[1].eventDuringFirstOnError = top.frames[1].event; | ||
foo; // cause second onerror | ||
`); | ||
|
||
const myEvent = new ErrorEvent("error", { error: new Error("myError") }); | ||
window.dispatchEvent(myEvent); | ||
|
||
assert_equals(top.eventDuringFirstOnError, onLoadEvent); | ||
assert_equals(frames[0].eventDuringFirstOnError, myEvent); | ||
assert_equals(frames[1].eventDuringFirstOnError, undefined); | ||
|
||
assert_equals(top.eventDuringSecondOnError, onLoadEvent); | ||
assert_equals(frames[0].eventDuringSecondOnError, myEvent); | ||
assert_equals(frames[1].eventDuringSecondOnError.error.name, "ReferenceError"); | ||
}); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<title>Script created MouseEvent properly retargets and adjusts offsetX</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<style> | ||
body { | ||
margin: 8px; | ||
padding: 0; | ||
} | ||
</style> | ||
|
||
<div id="target">Hello</div> | ||
|
||
<script> | ||
async_test(t => { | ||
target.addEventListener('click', ev => { | ||
t.step(() => assert_equals(ev.offsetX, 42)); | ||
t.done(); | ||
}); | ||
|
||
const ev = new MouseEvent('click', { clientX: 50 }); | ||
target.dispatchEvent(ev); | ||
}, "offsetX is correctly adjusted"); | ||
</script> |
80 changes: 80 additions & 0 deletions
80
test/fixtures/wpt/dom/events/no-focus-events-at-clicking-editable-content-in-link.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta chareset="utf-8"> | ||
<title>Clicking editable content in link shouldn't cause redundant focus related events</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-actions.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
</head> | ||
<body> | ||
<a href="#"><span contenteditable>Hello</span></a> | ||
<a href="#" contenteditable><span>Hello</span></a> | ||
<script> | ||
function promiseTicks() { | ||
return new Promise(resolve => { | ||
requestAnimationFrame(() => { | ||
requestAnimationFrame(resolve); | ||
}); | ||
}); | ||
} | ||
|
||
async function clickElementAndCollectFocusEvents(x, y, options) { | ||
await promiseTicks(); | ||
let events = []; | ||
for (const eventType of ["focus", "blur", "focusin", "focusout"]) { | ||
document.addEventListener(eventType, event => { | ||
events.push(`type: ${event.type}, target: ${event.target.nodeName}`); | ||
}, {capture: true}); | ||
} | ||
|
||
const waitForClickEvent = new Promise(resolve => { | ||
addEventListener("click", resolve, {capture: true, once: true}); | ||
}); | ||
|
||
await new test_driver | ||
.Actions() | ||
.pointerMove(x, y, options) | ||
.pointerDown() | ||
.pointerUp() | ||
.send(); | ||
|
||
await waitForClickEvent; | ||
await promiseTicks(); | ||
return events; | ||
} | ||
|
||
promise_test(async t => { | ||
document.activeElement?.blur(); | ||
const editingHost = document.querySelector("span[contenteditable]"); | ||
editingHost.blur(); | ||
const focusEvents = | ||
await clickElementAndCollectFocusEvents(5, 5, {origin: editingHost}); | ||
assert_array_equals( | ||
focusEvents, | ||
[ | ||
"type: focus, target: SPAN", | ||
"type: focusin, target: SPAN", | ||
], | ||
"Click event shouldn't cause redundant focus events"); | ||
}, "Click editable element in link"); | ||
|
||
promise_test(async t => { | ||
document.activeElement?.blur(); | ||
const editingHost = document.querySelector("a[contenteditable]"); | ||
editingHost.blur(); | ||
const focusEvents = | ||
await clickElementAndCollectFocusEvents(5, 5, {origin: editingHost}); | ||
assert_array_equals( | ||
focusEvents, | ||
[ | ||
"type: focus, target: A", | ||
"type: focusin, target: A", | ||
], | ||
"Click event shouldn't cause redundant focus events"); | ||
}, "Click editable link"); | ||
</script> | ||
</body> | ||
</html> |
19 changes: 19 additions & 0 deletions
19
...dom/events/non-cancelable-when-passive/non-passive-mousewheel-event-listener-on-body.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<title>non-passive mousewheel event listener on body</title> | ||
<link rel="help" href="https://w3c.github.io/uievents/#cancelability-of-wheel-events"> | ||
<link rel="help" href="https://github.com/w3c/uievents/issues/331"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-actions.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script src="resources/scrolling.js"></script> | ||
<div class=remove-on-cleanup style="height: 200vh"></div> | ||
<script> | ||
document.body.onload = () => runTest({ | ||
target: document.body, | ||
eventName: 'mousewheel', | ||
passive: false, | ||
expectCancelable: true, | ||
}); | ||
</script> |
35 changes: 35 additions & 0 deletions
35
.../dom/events/non-cancelable-when-passive/non-passive-mousewheel-event-listener-on-div.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<title>non-passive mousewheel event listener on div</title> | ||
<link rel="help" href="https://w3c.github.io/uievents/#cancelability-of-wheel-events"> | ||
<link rel="help" href="https://github.com/w3c/uievents/issues/331"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-actions.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script src="resources/scrolling.js"></script> | ||
<style> | ||
html, body { | ||
overflow: hidden; | ||
margin: 0; | ||
} | ||
#div { | ||
position: fixed; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
overflow: scroll; | ||
} | ||
</style> | ||
<div class=remove-on-cleanup id=div> | ||
<div style="height: 200vh"></div> | ||
</div> | ||
<script> | ||
document.body.onload = () => runTest({ | ||
target: document.getElementById('div'), | ||
eventName: 'mousewheel', | ||
passive: false, | ||
expectCancelable: true, | ||
}); | ||
</script> |
19 changes: 19 additions & 0 deletions
19
...events/non-cancelable-when-passive/non-passive-mousewheel-event-listener-on-document.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<title>non-passive mousewheel event listener on document</title> | ||
<link rel="help" href="https://w3c.github.io/uievents/#cancelability-of-wheel-events"> | ||
<link rel="help" href="https://github.com/w3c/uievents/issues/331"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-actions.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script src="resources/scrolling.js"></script> | ||
<div class=remove-on-cleanup style="height: 200vh"></div> | ||
<script> | ||
document.body.onload = () => runTest({ | ||
target: document, | ||
eventName: 'mousewheel', | ||
passive: false, | ||
expectCancelable: true, | ||
}); | ||
</script> |
19 changes: 19 additions & 0 deletions
19
...dom/events/non-cancelable-when-passive/non-passive-mousewheel-event-listener-on-root.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<title>non-passive mousewheel event listener on root</title> | ||
<link rel="help" href="https://w3c.github.io/uievents/#cancelability-of-wheel-events"> | ||
<link rel="help" href="https://github.com/w3c/uievents/issues/331"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-actions.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script src="resources/scrolling.js"></script> | ||
<div class=remove-on-cleanup style="height: 200vh"></div> | ||
<script> | ||
document.body.onload = () => runTest({ | ||
target: document.documentElement, | ||
eventName: 'mousewheel', | ||
passive: false, | ||
expectCancelable: true, | ||
}); | ||
</script> |
Oops, something went wrong.