| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,7 @@ Last update: | |||
| 13 | 13 | - common: https://github.com/web-platform-tests/wpt/tree/03c5072aff/common | |
| 14 | 14 | - console: https://github.com/web-platform-tests/wpt/tree/767ae35464/console | |
| 15 | 15 | - dom/abort: https://github.com/web-platform-tests/wpt/tree/8fadb38120/dom/abort | |
| 16 | - - dom/events: https://github.com/web-platform-tests/wpt/tree/f8821adb28/dom/events | ||
| 16 | + - dom/events: https://github.com/web-platform-tests/wpt/tree/ab8999891c/dom/events | ||
| 17 | 17 | - encoding: https://github.com/web-platform-tests/wpt/tree/779d175c40/encoding | |
| 18 | 18 | - fetch/data-urls/resources: https://github.com/web-platform-tests/wpt/tree/7c79d998ff/fetch/data-urls/resources | |
| 19 | 19 | - FileAPI: https://github.com/web-platform-tests/wpt/tree/3b279420d4/FileAPI | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,123 @@ | |||
| 1 | + <!DOCTYPE html> | ||
| 2 | + <html> | ||
| 3 | + <title>HTMLBodyElement and HTMLFrameSetElement Event Handler Tests</title> | ||
| 4 | + <script src="/resources/testharness.js"></script> | ||
| 5 | + <script src="/resources/testharnessreport.js"></script> | ||
| 6 | + | ||
| 7 | + <script> | ||
| 8 | + function getObject(interface) { | ||
| 9 | + switch(interface) { | ||
| 10 | + case "Element": | ||
| 11 | + var e = document.createElementNS("http://example.com/", "example"); | ||
| 12 | + assert_true(e instanceof Element); | ||
| 13 | + assert_false(e instanceof HTMLElement); | ||
| 14 | + assert_false(e instanceof SVGElement); | ||
| 15 | + return e; | ||
| 16 | + case "HTMLElement": | ||
| 17 | + var e = document.createElement("html"); | ||
| 18 | + assert_true(e instanceof HTMLElement); | ||
| 19 | + return e; | ||
| 20 | + case "HTMLBodyElement": | ||
| 21 | + var e = document.createElement("body"); | ||
| 22 | + assert_true(e instanceof HTMLBodyElement); | ||
| 23 | + return e; | ||
| 24 | + case "HTMLFormElement": | ||
| 25 | + var e = document.createElement("form"); | ||
| 26 | + assert_true(e instanceof HTMLFormElement); | ||
| 27 | + return e; | ||
| 28 | + case "HTMLFrameSetElement": | ||
| 29 | + var e = document.createElement("frameset"); | ||
| 30 | + assert_true(e instanceof HTMLFrameSetElement); | ||
| 31 | + return e; | ||
| 32 | + case "SVGElement": | ||
| 33 | + var e = document.createElementNS("http://www.w3.org/2000/svg", "rect"); | ||
| 34 | + assert_true(e instanceof SVGElement); | ||
| 35 | + return e; | ||
| 36 | + case "Document": | ||
| 37 | + assert_true(document instanceof Document); | ||
| 38 | + return document; | ||
| 39 | + case "Window": | ||
| 40 | + assert_true(window instanceof Window); | ||
| 41 | + return window; | ||
| 42 | + } | ||
| 43 | + assert_unreached(); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + function testSet(interface, attribute) { | ||
| 47 | + test(function() { | ||
| 48 | + var object = getObject(interface); | ||
| 49 | + function nop() {} | ||
| 50 | + assert_equals(object[attribute], null, "Initially null"); | ||
| 51 | + object[attribute] = nop; | ||
| 52 | + assert_equals(object[attribute], nop, "Return same function"); | ||
| 53 | + object[attribute] = ""; | ||
| 54 | + assert_equals(object[attribute], null, "Return null after setting string"); | ||
| 55 | + object[attribute] = null; | ||
| 56 | + assert_equals(object[attribute], null, "Finally null"); | ||
| 57 | + }, "Set " + interface + "." + attribute); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + function testReflect(interface, attribute) { | ||
| 61 | + test(function() { | ||
| 62 | + var element = getObject(interface); | ||
| 63 | + assert_false(element.hasAttribute(attribute), "Initially missing"); | ||
| 64 | + element.setAttribute(attribute, "return"); | ||
| 65 | + assert_equals(element.getAttribute(attribute), "return", "Return same string"); | ||
| 66 | + assert_equals(typeof element[attribute], "function", "Convert to function"); | ||
| 67 | + element.removeAttribute(attribute); | ||
| 68 | + }, "Reflect " + interface + "." + attribute); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + function testForwardToWindow(interface, attribute) { | ||
| 72 | + test(function() { | ||
| 73 | + var element = getObject(interface); | ||
| 74 | + window[attribute] = null; | ||
| 75 | + element.setAttribute(attribute, "return"); | ||
| 76 | + assert_equals(typeof window[attribute], "function", "Convert to function"); | ||
| 77 | + assert_equals(window[attribute], element[attribute], "Forward content attribute"); | ||
| 78 | + function nop() {} | ||
| 79 | + element[attribute] = nop; | ||
| 80 | + assert_equals(window[attribute], nop, "Forward IDL attribute"); | ||
| 81 | + window[attribute] = null; | ||
| 82 | + }, "Forward " + interface + "." + attribute + " to Window"); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + // Object.propertyIsEnumerable cannot be used because it doesn't | ||
| 86 | + // work with properties inherited through the prototype chain. | ||
| 87 | + function getEnumerable(interface) { | ||
| 88 | + var enumerable = {}; | ||
| 89 | + for (var attribute in getObject(interface)) { | ||
| 90 | + enumerable[attribute] = true; | ||
| 91 | + } | ||
| 92 | + return enumerable; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + var enumerableCache = {}; | ||
| 96 | + function testEnumerate(interface, attribute) { | ||
| 97 | + if (!(interface in enumerableCache)) { | ||
| 98 | + enumerableCache[interface] = getEnumerable(interface); | ||
| 99 | + } | ||
| 100 | + test(function() { | ||
| 101 | + assert_true(enumerableCache[interface][attribute]); | ||
| 102 | + }, "Enumerate " + interface + "." + attribute); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + [ | ||
| 106 | + "onblur", | ||
| 107 | + "onerror", | ||
| 108 | + "onfocus", | ||
| 109 | + "onload", | ||
| 110 | + "onscroll", | ||
| 111 | + "onresize" | ||
| 112 | + ].forEach(function(attribute) { | ||
| 113 | + testSet("HTMLBodyElement", attribute); | ||
| 114 | + testEnumerate("HTMLBodyElement", attribute); | ||
| 115 | + testReflect("HTMLBodyElement", attribute); | ||
| 116 | + testForwardToWindow("HTMLBodyElement", attribute); | ||
| 117 | + testSet("HTMLFrameSetElement", attribute); | ||
| 118 | + testEnumerate("HTMLFrameSetElement", attribute); | ||
| 119 | + testReflect("HTMLFrameSetElement", attribute); | ||
| 120 | + testForwardToWindow("HTMLFrameSetElement", attribute); | ||
| 121 | + }); | ||
| 122 | + </script> | ||
| 123 | + </html> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,11 @@ | |||
| 1 | 1 | // META: title=Event constructors | |
| 2 | 2 | ||
| 3 | + test(function() { | ||
| 4 | + assert_throws_js( | ||
| 5 | + TypeError, | ||
| 6 | + () => Event(""), | ||
| 7 | + "Calling Event constructor without 'new' must throw") | ||
| 8 | + }) | ||
| 3 | 9 | test(function() { | |
| 4 | 10 | assert_throws_js(TypeError, function() { | |
| 5 | 11 | new Event() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,43 @@ | |||
| 1 | + <!DOCTYPE html> | ||
| 2 | + <meta charset="utf-8"> | ||
| 3 | + <title>window.onerror handler restores window.event after it reports an exception</title> | ||
| 4 | + <link rel="help" href="https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke"> | ||
| 5 | + <script src="/resources/testharness.js"></script> | ||
| 6 | + <script src="/resources/testharnessreport.js"></script> | ||
| 7 | + | ||
| 8 | + <body> | ||
| 9 | + <iframe src="resources/empty-document.html"></iframe> | ||
| 10 | + <iframe src="resources/empty-document.html"></iframe> | ||
| 11 | + | ||
| 12 | + <script> | ||
| 13 | + setup({ allow_uncaught_exception: true }); | ||
| 14 | + | ||
| 15 | + async_test(t => { | ||
| 16 | + window.onload = t.step_func_done(onLoadEvent => { | ||
| 17 | + frames[0].onerror = new frames[1].Function(` | ||
| 18 | + top.eventDuringSecondOnError = top.window.event; | ||
| 19 | + top.frames[0].eventDuringSecondOnError = top.frames[0].event; | ||
| 20 | + top.frames[1].eventDuringSecondOnError = top.frames[1].event; | ||
| 21 | + `); | ||
| 22 | + | ||
| 23 | + window.onerror = new frames[0].Function(` | ||
| 24 | + top.eventDuringFirstOnError = top.window.event; | ||
| 25 | + top.frames[0].eventDuringFirstOnError = top.frames[0].event; | ||
| 26 | + top.frames[1].eventDuringFirstOnError = top.frames[1].event; | ||
| 27 | + | ||
| 28 | + foo; // cause second onerror | ||
| 29 | + `); | ||
| 30 | + | ||
| 31 | + const myEvent = new ErrorEvent("error", { error: new Error("myError") }); | ||
| 32 | + window.dispatchEvent(myEvent); | ||
| 33 | + | ||
| 34 | + assert_equals(top.eventDuringFirstOnError, onLoadEvent); | ||
| 35 | + assert_equals(frames[0].eventDuringFirstOnError, myEvent); | ||
| 36 | + assert_equals(frames[1].eventDuringFirstOnError, undefined); | ||
| 37 | + | ||
| 38 | + assert_equals(top.eventDuringSecondOnError, onLoadEvent); | ||
| 39 | + assert_equals(frames[0].eventDuringSecondOnError, myEvent); | ||
| 40 | + assert_equals(frames[1].eventDuringSecondOnError.error.name, "ReferenceError"); | ||
| 41 | + }); | ||
| 42 | + }); | ||
| 43 | + </script> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + <!DOCTYPE html> | ||
| 2 | + <html> | ||
| 3 | + <title>Script created MouseEvent properly retargets and adjusts offsetX</title> | ||
| 4 | + <script src="/resources/testharness.js"></script> | ||
| 5 | + <script src="/resources/testharnessreport.js"></script> | ||
| 6 | + | ||
| 7 | + <style> | ||
| 8 | + body { | ||
| 9 | + margin: 8px; | ||
| 10 | + padding: 0; | ||
| 11 | + } | ||
| 12 | + </style> | ||
| 13 | + | ||
| 14 | + <div id="target">Hello</div> | ||
| 15 | + | ||
| 16 | + <script> | ||
| 17 | + async_test(t => { | ||
| 18 | + target.addEventListener('click', ev => { | ||
| 19 | + t.step(() => assert_equals(ev.offsetX, 42)); | ||
| 20 | + t.done(); | ||
| 21 | + }); | ||
| 22 | + | ||
| 23 | + const ev = new MouseEvent('click', { clientX: 50 }); | ||
| 24 | + target.dispatchEvent(ev); | ||
| 25 | + }, "offsetX is correctly adjusted"); | ||
| 26 | + </script> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,80 @@ | |||
| 1 | + <!doctype html> | ||
| 2 | + <html> | ||
| 3 | + <head> | ||
| 4 | + <meta chareset="utf-8"> | ||
| 5 | + <title>Clicking editable content in link shouldn't cause redundant focus related events</title> | ||
| 6 | + <script src="/resources/testharness.js"></script> | ||
| 7 | + <script src="/resources/testharnessreport.js"></script> | ||
| 8 | + <script src="/resources/testdriver.js"></script> | ||
| 9 | + <script src="/resources/testdriver-actions.js"></script> | ||
| 10 | + <script src="/resources/testdriver-vendor.js"></script> | ||
| 11 | + </head> | ||
| 12 | + <body> | ||
| 13 | + <a href="#"><span contenteditable>Hello</span></a> | ||
| 14 | + <a href="#" contenteditable><span>Hello</span></a> | ||
| 15 | + <script> | ||
| 16 | + function promiseTicks() { | ||
| 17 | + return new Promise(resolve => { | ||
| 18 | + requestAnimationFrame(() => { | ||
| 19 | + requestAnimationFrame(resolve); | ||
| 20 | + }); | ||
| 21 | + }); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + async function clickElementAndCollectFocusEvents(x, y, options) { | ||
| 25 | + await promiseTicks(); | ||
| 26 | + let events = []; | ||
| 27 | + for (const eventType of ["focus", "blur", "focusin", "focusout"]) { | ||
| 28 | + document.addEventListener(eventType, event => { | ||
| 29 | + events.push(`type: ${event.type}, target: ${event.target.nodeName}`); | ||
| 30 | + }, {capture: true}); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + const waitForClickEvent = new Promise(resolve => { | ||
| 34 | + addEventListener("click", resolve, {capture: true, once: true}); | ||
| 35 | + }); | ||
| 36 | + | ||
| 37 | + await new test_driver | ||
| 38 | + .Actions() | ||
| 39 | + .pointerMove(x, y, options) | ||
| 40 | + .pointerDown() | ||
| 41 | + .pointerUp() | ||
| 42 | + .send(); | ||
| 43 | + | ||
| 44 | + await waitForClickEvent; | ||
| 45 | + await promiseTicks(); | ||
| 46 | + return events; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + promise_test(async t => { | ||
| 50 | + document.activeElement?.blur(); | ||
| 51 | + const editingHost = document.querySelector("span[contenteditable]"); | ||
| 52 | + editingHost.blur(); | ||
| 53 | + const focusEvents = | ||
| 54 | + await clickElementAndCollectFocusEvents(5, 5, {origin: editingHost}); | ||
| 55 | + assert_array_equals( | ||
| 56 | + focusEvents, | ||
| 57 | + [ | ||
| 58 | + "type: focus, target: SPAN", | ||
| 59 | + "type: focusin, target: SPAN", | ||
| 60 | + ], | ||
| 61 | + "Click event shouldn't cause redundant focus events"); | ||
| 62 | + }, "Click editable element in link"); | ||
| 63 | + | ||
| 64 | + promise_test(async t => { | ||
| 65 | + document.activeElement?.blur(); | ||
| 66 | + const editingHost = document.querySelector("a[contenteditable]"); | ||
| 67 | + editingHost.blur(); | ||
| 68 | + const focusEvents = | ||
| 69 | + await clickElementAndCollectFocusEvents(5, 5, {origin: editingHost}); | ||
| 70 | + assert_array_equals( | ||
| 71 | + focusEvents, | ||
| 72 | + [ | ||
| 73 | + "type: focus, target: A", | ||
| 74 | + "type: focusin, target: A", | ||
| 75 | + ], | ||
| 76 | + "Click event shouldn't cause redundant focus events"); | ||
| 77 | + }, "Click editable link"); | ||
| 78 | + </script> | ||
| 79 | + </body> | ||
| 80 | + </html> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,19 @@ | |||
| 1 | + <!DOCTYPE html> | ||
| 2 | + <title>non-passive mousewheel event listener on body</title> | ||
| 3 | + <link rel="help" href="https://w3c.github.io/uievents/#cancelability-of-wheel-events"> | ||
| 4 | + <link rel="help" href="https://github.com/w3c/uievents/issues/331"> | ||
| 5 | + <script src="/resources/testharness.js"></script> | ||
| 6 | + <script src="/resources/testharnessreport.js"></script> | ||
| 7 | + <script src="/resources/testdriver.js"></script> | ||
| 8 | + <script src="/resources/testdriver-actions.js"></script> | ||
| 9 | + <script src="/resources/testdriver-vendor.js"></script> | ||
| 10 | + <script src="resources/scrolling.js"></script> | ||
| 11 | + <div class=remove-on-cleanup style="height: 200vh"></div> | ||
| 12 | + <script> | ||
| 13 | + document.body.onload = () => runTest({ | ||
| 14 | + target: document.body, | ||
| 15 | + eventName: 'mousewheel', | ||
| 16 | + passive: false, | ||
| 17 | + expectCancelable: true, | ||
| 18 | + }); | ||
| 19 | + </script> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,35 @@ | |||
| 1 | + <!DOCTYPE html> | ||
| 2 | + <title>non-passive mousewheel event listener on div</title> | ||
| 3 | + <link rel="help" href="https://w3c.github.io/uievents/#cancelability-of-wheel-events"> | ||
| 4 | + <link rel="help" href="https://github.com/w3c/uievents/issues/331"> | ||
| 5 | + <script src="/resources/testharness.js"></script> | ||
| 6 | + <script src="/resources/testharnessreport.js"></script> | ||
| 7 | + <script src="/resources/testdriver.js"></script> | ||
| 8 | + <script src="/resources/testdriver-actions.js"></script> | ||
| 9 | + <script src="/resources/testdriver-vendor.js"></script> | ||
| 10 | + <script src="resources/scrolling.js"></script> | ||
| 11 | + <style> | ||
| 12 | + html, body { | ||
| 13 | + overflow: hidden; | ||
| 14 | + margin: 0; | ||
| 15 | + } | ||
| 16 | + #div { | ||
| 17 | + position: fixed; | ||
| 18 | + top: 0; | ||
| 19 | + right: 0; | ||
| 20 | + bottom: 0; | ||
| 21 | + left: 0; | ||
| 22 | + overflow: scroll; | ||
| 23 | + } | ||
| 24 | + </style> | ||
| 25 | + <div class=remove-on-cleanup id=div> | ||
| 26 | + <div style="height: 200vh"></div> | ||
| 27 | + </div> | ||
| 28 | + <script> | ||
| 29 | + document.body.onload = () => runTest({ | ||
| 30 | + target: document.getElementById('div'), | ||
| 31 | + eventName: 'mousewheel', | ||
| 32 | + passive: false, | ||
| 33 | + expectCancelable: true, | ||
| 34 | + }); | ||
| 35 | + </script> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,19 @@ | |||
| 1 | + <!DOCTYPE html> | ||
| 2 | + <title>non-passive mousewheel event listener on document</title> | ||
| 3 | + <link rel="help" href="https://w3c.github.io/uievents/#cancelability-of-wheel-events"> | ||
| 4 | + <link rel="help" href="https://github.com/w3c/uievents/issues/331"> | ||
| 5 | + <script src="/resources/testharness.js"></script> | ||
| 6 | + <script src="/resources/testharnessreport.js"></script> | ||
| 7 | + <script src="/resources/testdriver.js"></script> | ||
| 8 | + <script src="/resources/testdriver-actions.js"></script> | ||
| 9 | + <script src="/resources/testdriver-vendor.js"></script> | ||
| 10 | + <script src="resources/scrolling.js"></script> | ||
| 11 | + <div class=remove-on-cleanup style="height: 200vh"></div> | ||
| 12 | + <script> | ||
| 13 | + document.body.onload = () => runTest({ | ||
| 14 | + target: document, | ||
| 15 | + eventName: 'mousewheel', | ||
| 16 | + passive: false, | ||
| 17 | + expectCancelable: true, | ||
| 18 | + }); | ||
| 19 | + </script> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,19 @@ | |||
| 1 | + <!DOCTYPE html> | ||
| 2 | + <title>non-passive mousewheel event listener on root</title> | ||
| 3 | + <link rel="help" href="https://w3c.github.io/uievents/#cancelability-of-wheel-events"> | ||
| 4 | + <link rel="help" href="https://github.com/w3c/uievents/issues/331"> | ||
| 5 | + <script src="/resources/testharness.js"></script> | ||
| 6 | + <script src="/resources/testharnessreport.js"></script> | ||
| 7 | + <script src="/resources/testdriver.js"></script> | ||
| 8 | + <script src="/resources/testdriver-actions.js"></script> | ||
| 9 | + <script src="/resources/testdriver-vendor.js"></script> | ||
| 10 | + <script src="resources/scrolling.js"></script> | ||
| 11 | + <div class=remove-on-cleanup style="height: 200vh"></div> | ||
| 12 | + <script> | ||
| 13 | + document.body.onload = () => runTest({ | ||
| 14 | + target: document.documentElement, | ||
| 15 | + eventName: 'mousewheel', | ||
| 16 | + passive: false, | ||
| 17 | + expectCancelable: true, | ||
| 18 | + }); | ||
| 19 | + </script> | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments