Commit ee5b9bf7 authored by Chromium WPT Sync's avatar Chromium WPT Sync Committed by Commit Bot

Import wpt@8e668a6b63e5dbb68304c182fdc1f7b4e6edaf96

Using wpt-import in Chromium f4d53fb3.
With Chromium commits locally applied on WPT:
7dad0f17 "Added new Sec-Metadata Web Platform Tests."


Build: https://ci.chromium.org/buildbot/chromium.infra.cron/wpt-importer/22183

Note to sheriffs: This CL imports external tests and adds
expectations for those tests; if this CL is large and causes
a few new failures, please fix the failures by adding new
lines to TestExpectations rather than reverting. See:
https://chromium.googlesource.com/chromium/src/+/master/docs/testing/web_platform_tests.md

TBR=raphael.kubo.da.costa@intel.com

No-Export: true
Change-Id: I1a710e023cc5268ad365820e61d5a1f5cf453a2b
Reviewed-on: https://chromium-review.googlesource.com/1157346
Commit-Queue: Blink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Reviewed-by: default avatarBlink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579652}
parent b8129008
This is a testharness.js-based test.
FAIL document.open bailout should not have any side effects (ignore-opens-during-unload is greater than 0 during unload event) assert_not_equals: document nodes should not be cleared (ignore-opens-during-unload counter is greater than 0 during unload event) got disallowed value 0
FAIL document.open bailout should not have any side effects (ignore-opens-during-unload is greater than 0 during beforeunload event) assert_not_equals: document nodes should not be cleared (ignore-opens-during-unload counter is greater than 0 during beforeunload event) got disallowed value 0
FAIL document.open bailout should not have any side effects (ignore-opens-during-unload is greater than 0 during pagehide event) assert_not_equals: document nodes should not be cleared (ignore-opens-during-unload counter is greater than 0 during pagehide event) got disallowed value 0
Harness: the test ran to completion.
// META: script=resources/document-open-side-effects.js
for (const ev of ["unload", "beforeunload", "pagehide"]) {
async_test(t => {
const iframe = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => iframe.remove());
iframe.src = "/common/blank.html";
iframe.onload = t.step_func(() => {
iframe.contentWindow.addEventListener(ev, t.step_func_done(() => {
const origURL = iframe.contentDocument.URL;
assertDocumentIsReadyForSideEffectsTest(iframe.contentDocument, `ignore-opens-during-unload counter is greater than 0 during ${ev} event`);
iframe.contentDocument.open();
assertOpenHasNoSideEffects(iframe.contentDocument, origURL, `ignore-opens-during-unload counter is greater than 0 during ${ev} event`);
}));
iframe.src = "about:blank";
});
}, `document.open bailout should not have any side effects (ignore-opens-during-unload is greater than 0 during ${ev} event)`);
}
// META: script=/html/resources/common.js
// META: script=resources/document-open-side-effects.js
document.domain = "{{host}}";
testInIFrame("http://{{host}}:{{ports[http][1]}}/common/domain-setter.sub.html", (ctx) => {
const iframe = ctx.iframes[0];
const origURL = iframe.contentDocument.URL;
assertDocumentIsReadyForSideEffectsTest(iframe.contentDocument, "same origin-domain (but not same origin) document");
assert_throws("SecurityError", () => {
ctx.iframes[0].contentDocument.open();
}, "document.open() should throw a SecurityError on a same origin-domain (but not same origin) document");
assertOpenHasNoSideEffects(iframe.contentDocument, origURL, "same origin-domain (but not same origin) document");
}, "document.open bailout should not have any side effects (same origin-domain (but not same origin) document)");
// META: script=resources/document-open-side-effects.js
async_test(t => {
const iframe = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => iframe.remove());
self.testSynchronousScript = t.step_func_done(() => {
const origURL = iframe.contentDocument.URL;
assertDocumentIsReadyForSideEffectsTest(iframe.contentDocument, "active parser whose script nesting level is greater than 0");
iframe.contentDocument.open();
assertOpenHasNoSideEffects(iframe.contentDocument, origURL, "active parser whose script nesting level is greater than 0");
});
iframe.src = "resources/bailout-order-synchronous-script-frame.html";
}, "document.open bailout should not have any side effects (active parser whose script nesting level is greater than 0)");
// META: script=resources/document-open-side-effects.js
async_test(t => {
const iframe = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => iframe.remove());
iframe.src = "/common/dummy.xhtml";
iframe.onload = t.step_func_done(() => {
const origURL = iframe.contentDocument.URL;
assertDocumentIsReadyForSideEffectsTest(iframe.contentDocument, "XML document");
assert_throws("InvalidStateError", () => {
iframe.contentDocument.open();
}, "document.open() should throw on XML documents");
assertOpenHasNoSideEffects(iframe.contentDocument, origURL, "XML document");
});
}, "document.open bailout should not have any side effects (XML document)");
This is a testharness.js-based test.
FAIL document.open should bail out when ignore-opens-during-unload is greater than 0 during unload event assert_not_equals: got disallowed value 0
FAIL document.open should bail out when ignore-opens-during-unload is greater than 0 during beforeunload event assert_not_equals: got disallowed value 0
FAIL document.open should bail out when ignore-opens-during-unload is greater than 0 during pagehide event assert_not_equals: got disallowed value 0
Harness: the test ran to completion.
for (const ev of ["unload", "beforeunload", "pagehide"]) {
async_test(t => {
const iframe = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => iframe.remove());
iframe.src = "/common/blank.html";
iframe.onload = t.step_func(() => {
iframe.contentWindow.addEventListener(ev, t.step_func_done(() => {
assert_not_equals(iframe.contentDocument.childNodes.length, 0);
iframe.contentDocument.open();
assert_not_equals(iframe.contentDocument.childNodes.length, 0);
}));
iframe.src = "about:blank";
});
}, `document.open should bail out when ignore-opens-during-unload is greater than 0 during ${ev} event`);
}
function assertDocumentIsReadyForSideEffectsTest(doc, description) {
assert_not_equals(doc.childNodes.length, 0, `document should not be empty before side effects test (${description})`);
}
function assertOpenHasNoSideEffects(doc, originalURL, description) {
assert_not_equals(doc.childNodes.length, 0, `document nodes should not be cleared (${description})`);
assert_equals(doc.URL, originalURL, `The original URL should be kept (${description})`);
}
<!doctype html>
<meta charset="utf-8">
<title></title>
<body></body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var elements = ['body', 'frameset'];
var handlers = [
'load', 'resize', 'blur', 'focus', 'scroll',
'afterprint', 'beforeprint', 'beforeunload', 'hashchange',
'languagechange', 'message', 'offline', 'online', 'pagehide',
'pageshow', 'popstate', 'rejectionhandled', 'storage',
'unhandledrejection', 'unload'];
elements.forEach(function (elementName) {
handlers.forEach(function (eventName) {
var handlerName = "on" + eventName;
test(function() {
var windowHandler = function () { return "Handler attached to the window"; };
window[handlerName] = windowHandler;
var d = (new DOMParser).parseFromString('', 'text/html');
var b = d.createElement(elementName);
assert_equals(b[handlerName], null);
window[handlerName] = null;
}, "Return null when getting the " + eventName + " event handler of a windowless " + elementName);
test(function() {
var windowHandler = function () { return "Handler attached to the window"; };
window[handlerName] = windowHandler;
var d = (new DOMParser).parseFromString('', 'text/html');
var b = d.createElement(elementName);
b[handlerName] = function() { return "Handler attached to windowless element"; };
assert_equals(window[handlerName], windowHandler);
assert_equals(b[handlerName], null);
// Clean up window event handler
window[handlerName] = null;
}, "Ignore setting of " + eventName + " window event handlers on windowless " + elementName);
});
});
</script>
......@@ -3,32 +3,49 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="resources/event-handler-body.js"></script>
<div id="log"></div>
<body>
<script>
function f() {
return 0;
}
setup({ explicit_done: true });
var handlers = ['blur','error','focus','load','resize','scroll',
'afterprint','beforeprint','beforeunload','hashchange',
'languagechange','message','offline','online','pagehide',
'pageshow','popstate','storage','unload'];
handlers.forEach(function(handler) {
test(function() {
document.body['on' + handler] = f;
assert_equals(window['on' + handler], f);
}, handler);
});
handlersListPromise.then(({ shadowedHandlers, notShadowedHandlers }) => {
const createdBody = document.createElement("body");
for (const [description, body, altBody] of [
["document.body", document.body, createdBody],
['document.createElement("body")', createdBody, document.body]
]) {
const f = () => 0;
handlers.forEach(function(handler) {
document.body['on' + handler] = null;
});
shadowedHandlers.forEach(function(handler) {
test(function() {
body['on' + handler] = f;
assert_equals(window['on' + handler], f, "window should reflect");
assert_equals(altBody['on' + handler], f, "alternative body should reflect");
}, `shadowed ${handler} (${description})`);
});
notShadowedHandlers.forEach(function(handler) {
test(function() {
body['on' + handler] = f;
assert_equals(window['on' + handler], null, "window should reflect");
assert_equals(altBody['on' + handler], null, "alternative body should reflect");
}, `not shadowed ${handler} (${description})`);
});
[...shadowedHandlers, ...notShadowedHandlers].forEach(function(handler) {
body['on' + handler] = null;
});
shadowedHandlers.forEach(function(handler) {
test(function() {
assert_equals(body['on' + handler], null, "body should reflect changes to itself");
assert_equals(window['on' + handler], null, "window should reflect");
assert_equals(altBody['on' + handler], null, "alternative body should reflect");
}, `shadowed ${handler} removal (${description})`);
});
}
handlers.forEach(function(handler) {
test(function() {
assert_equals(document.body['on' + handler], null);
assert_equals(window['on' + handler], null);
}, handler + " removal");
done();
});
</script>
This is a testharness.js-based test.
Found 103 tests; 100 PASS, 3 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS shadowed blur
PASS shadowed error
PASS shadowed focus
PASS shadowed load
PASS shadowed resize
PASS shadowed scroll
PASS shadowed afterprint
PASS shadowed beforeprint
PASS shadowed beforeunload
PASS shadowed hashchange
PASS shadowed languagechange
PASS shadowed message
PASS shadowed messageerror
PASS shadowed offline
PASS shadowed online
PASS shadowed pagehide
PASS shadowed pageshow
PASS shadowed popstate
PASS shadowed rejectionhandled
PASS shadowed storage
PASS shadowed unhandledrejection
PASS shadowed unload
PASS not shadowed abort
PASS not shadowed auxclick
PASS not shadowed cancel
PASS not shadowed canplay
PASS not shadowed canplaythrough
PASS not shadowed change
PASS not shadowed click
PASS not shadowed close
PASS not shadowed contextmenu
PASS not shadowed cuechange
PASS not shadowed dblclick
PASS not shadowed drag
PASS not shadowed dragend
PASS not shadowed dragenter
FAIL not shadowed dragexit assert_equals: document.body should reflect expected (object) null but got (undefined) undefined
PASS not shadowed dragleave
PASS not shadowed dragover
PASS not shadowed dragstart
PASS not shadowed drop
PASS not shadowed durationchange
PASS not shadowed emptied
PASS not shadowed ended
PASS not shadowed input
PASS not shadowed invalid
PASS not shadowed keydown
PASS not shadowed keypress
PASS not shadowed keyup
PASS not shadowed loadeddata
PASS not shadowed loadedmetadata
FAIL not shadowed loadend assert_equals: document.body should reflect expected (object) null but got (undefined) undefined
PASS not shadowed loadstart
PASS not shadowed mousedown
PASS not shadowed mouseenter
PASS not shadowed mouseleave
PASS not shadowed mousemove
PASS not shadowed mouseout
PASS not shadowed mouseover
PASS not shadowed mouseup
PASS not shadowed wheel
PASS not shadowed pause
PASS not shadowed play
PASS not shadowed playing
PASS not shadowed progress
PASS not shadowed ratechange
PASS not shadowed reset
FAIL not shadowed securitypolicyviolation assert_equals: document.body should reflect expected (object) null but got (undefined) undefined
PASS not shadowed seeked
PASS not shadowed seeking
PASS not shadowed select
PASS not shadowed stalled
PASS not shadowed submit
PASS not shadowed suspend
PASS not shadowed timeupdate
PASS not shadowed toggle
PASS not shadowed volumechange
PASS not shadowed waiting
PASS not shadowed copy
PASS not shadowed cut
PASS not shadowed paste
PASS shadowed blur removal
PASS shadowed error removal
PASS shadowed focus removal
PASS shadowed load removal
PASS shadowed resize removal
PASS shadowed scroll removal
PASS shadowed afterprint removal
PASS shadowed beforeprint removal
PASS shadowed beforeunload removal
PASS shadowed hashchange removal
PASS shadowed languagechange removal
PASS shadowed message removal
PASS shadowed messageerror removal
PASS shadowed offline removal
PASS shadowed online removal
PASS shadowed pagehide removal
PASS shadowed pageshow removal
PASS shadowed popstate removal
PASS shadowed rejectionhandled removal
PASS shadowed storage removal
PASS shadowed unhandledrejection removal
PASS shadowed unload removal
Harness: the test ran to completion.
......@@ -3,32 +3,47 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="resources/event-handler-body.js"></script>
<div id="log"></div>
<body>
<script>
setup({ explicit_done: true });
function f() {
return 0;
}
var handlers = ['blur','error','focus','load','resize','scroll',
'afterprint','beforeprint','beforeunload','hashchange',
'languagechange','message','offline','online','pagehide',
'pageshow','popstate','storage','unload'];
handlers.forEach(function(handler) {
test(function() {
window['on' + handler] = f;
assert_equals(document.body['on' + handler], f);
}, handler);
});
handlersListPromise.then(({ shadowedHandlers, notShadowedHandlers }) => {
const body = document.createElement("body");
shadowedHandlers.forEach(function(handler) {
test(function() {
window['on' + handler] = f;
assert_equals(document.body['on' + handler], f, "document.body should reflect");
assert_equals(body['on' + handler], f, "document.createElement('body') should reflect");
}, `shadowed ${handler}`);
});
notShadowedHandlers.forEach(function(handler) {
test(function() {
window['on' + handler] = f;
assert_equals(document.body['on' + handler], null, "document.body should reflect");
assert_equals(body['on' + handler], null, "document.createElement('body') should reflect");
}, `not shadowed ${handler}`);
});
handlers.forEach(function(handler) {
[...shadowedHandlers, ...notShadowedHandlers].forEach(function(handler) {
window['on' + handler] = null;
});
});
shadowedHandlers.forEach(function(handler) {
test(function() {
assert_equals(window['on' + handler], null, "window should reflect changes to itself");
assert_equals(document.body['on' + handler], null, "document.body should reflect");
assert_equals(body['on' + handler], null, "document.createElement('body') should reflect");
}, `shadowed ${handler} removal`);
});
handlers.forEach(function(handler) {
test(function() {
assert_equals(window['on' + handler], null);
assert_equals(document.body['on' + handler], null);
}, handler + " removal");
done();
});
</script>
<!doctype html>
<meta charset="utf-8">
<title></title>
<body></body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="resources/event-handler-body.js"></script>
<script>
setup({ explicit_done: true });
const elements = ['body', 'frameset'];
handlersListPromise.then(({ shadowedHandlers, notShadowedHandlers }) => {
elements.forEach(function (elementName) {
shadowedHandlers.forEach(function (eventName) {
var handlerName = "on" + eventName;
test(function() {
var windowHandler = function () { return "Handler attached to the window"; };
window[handlerName] = windowHandler;
var d = (new DOMParser).parseFromString('', 'text/html');
var b = d.createElement(elementName);
assert_equals(b[handlerName], null);
window[handlerName] = null;
}, "Return null when getting the " + eventName + " event handler of a windowless " + elementName);
test(function() {
var windowHandler = function () { return "Handler attached to the window"; };
window[handlerName] = windowHandler;
var d = (new DOMParser).parseFromString('', 'text/html');
var b = d.createElement(elementName);
b[handlerName] = function() { return "Handler attached to windowless element"; };
assert_equals(window[handlerName], windowHandler);
assert_equals(b[handlerName], null);
// Clean up window event handler
window[handlerName] = null;
}, "Ignore setting of " + eventName + " window event handlers on windowless " + elementName);
});
notShadowedHandlers.forEach(function (eventName) {
var handlerName = "on" + eventName;
test(function() {
var windowHandler = function () { return "Handler attached to the window"; };
window[handlerName] = windowHandler;
var d = (new DOMParser).parseFromString('', 'text/html');
var b = d.createElement(elementName);
assert_equals(b[handlerName], null);
var elementHandler = function () { return "Handler attached to the element"; };
b[handlerName] = elementHandler;
assert_equals(window[handlerName], windowHandler);
assert_equals(b[handlerName], elementHandler);
// Clean up window event handler
window[handlerName] = null;
}, eventName + " is unaffected on a windowless " + elementName);
});
});
done();
});
</script>
test(() => {
var i = 0;
var uncalled = "assert_unreached('First event handler.');"
var button = document.createElement('button');
button.addEventListener('click', () => { assert_equals(++i, 1); }, false);
button.setAttribute('onclick', uncalled); // event handler is activated here
button.addEventListener('click', () => { assert_equals(++i, 2); }, false);
button.onclick = null; // but de-activated here
button.addEventListener('click', () => { assert_equals(++i, 3); }, false);
button.onclick = () => { assert_equals(++i, 4); }; // and re-activated here
button.addEventListener('click', () => { assert_equals(++i, 5); }, false);
button.click()
assert_equals(button.getAttribute("onclick"), uncalled)
assert_equals(i, 5);
}, "Event handler set through content attribute should be removed when they are set to null.");
let happened = 0;
test(() => {
var script = "happened++;";
var button = document.createElement('button');
button.setAttribute('onclick', script); // event handler is activated here
button.onclick = null; // but de-activated here
assert_equals(button.getAttribute("onclick"), script)
button.setAttribute('onclick', script); // and re-activated here
button.click()
assert_equals(happened, 1);
}, "Event handler set through content attribute should be re-activated even if content is the same.");
test(() => {
var i = 0;
var uncalled = "assert_unreached('First event handler.');"
var button = document.createElement('button');
button.addEventListener('click', () => { assert_equals(++i, 1); }, false);
button.setAttribute('onclick', uncalled); // event handler is activated here
button.addEventListener('click', () => { assert_equals(++i, 2); }, false);
button.removeAttribute('onclick'); // but de-activated here
button.addEventListener('click', () => { assert_equals(++i, 3); }, false);
button.onclick = () => { assert_equals(++i, 4); }; // and re-activated here
button.addEventListener('click', () => { assert_equals(++i, 5); }, false);
button.click()
assert_equals(i, 5);
}, "Event handler set through content attribute should be deactivated when the content attribute is removed.");
test(t => {
var i = 0;
var uncalled = "assert_unreached('First event handler.');"
var button = document.createElement('button');
button.addEventListener('click', () => { assert_equals(++i, 1); }, false);
button.onclick = t.unreached_func('First event handler.'); // event handler is activated here
button.addEventListener('click', () => { assert_equals(++i, 2); }, false);
button.onclick = null; // but de-activated here
button.addEventListener('click', () => { assert_equals(++i, 3); }, false);
button.onclick = () => { assert_equals(++i, 4); }; // and re-activated here
button.addEventListener('click', () => { assert_equals(++i, 5); }, false);
button.click()
assert_equals(i, 5);
}, "Event handler set through IDL should be deactivated when the IDL attribute is set to null.");
test(t => {
var i = 0;
var uncalled = "assert_unreached('First event handler.');"
var button = document.createElement('button');
button.addEventListener('click', () => { assert_equals(++i, 1) }, false);
button.onclick = t.unreached_func('First event handler.'); // event handler is activated here
button.addEventListener('click', () => { assert_equals(++i, 3) }, false);
button.removeAttribute('onclick'); // but de-activated here
button.addEventListener('click', () => { assert_equals(++i, 4) }, false);
button.onclick = () => { assert_equals(++i, 2); }; // and re-activated here
button.addEventListener('click', () => { assert_equals(++i, 5) }, false);
button.click()
assert_equals(i, 5);
}, "Event handler set through IDL should NOT be deactivated when the content attribute is removed.");
<!DOCTYPE html>
<title>Event handler invocation order</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var objects = [{}, function() {}, new Number(42), new String()];
var primitives = [42, null, undefined, ""];
objects.forEach(function(object) {
var t = async_test("Event handler listeners should be registered when they " +
"are first set to an object value (" +
format_value(object) + ").");
t.step(function() {
test(function() {
var i = 0;
var uncalled = "t.step(function() { assert_unreached('First event handler.') })"
var uncalled = "assert_unreached('First event handler.');"
var button = document.createElement('button');
button.onclick = object; // event handler listener is registered here
assert_equals(button.onclick, object);
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 2) }), false);
button.addEventListener('click', function () { assert_equals(++i, 2) }, false);
button.setAttribute('onclick', uncalled);
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 3) }), false);
button.onclick = t.step_func(function () { assert_equals(++i, 1); });
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 4) }), false);
button.addEventListener('click', function () { assert_equals(++i, 3) }, false);
button.onclick = function () { assert_equals(++i, 1); };
button.addEventListener('click', function () { assert_equals(++i, 4) }, false);
button.click()
assert_equals(button.getAttribute("onclick"), uncalled)
assert_equals(i, 4);
t.done()
});
}, "Event handler listeners should be registered when they are first set to an object value " +
"(" + format_value(object) + ").");
});
primitives.forEach(function(primitive) {
var t = async_test("Event handler listeners should be registered when they " +
"are first set to an object value (" +
format_value(primitive) + ").");
t.step(function() {
test(function() {
var i = 0;
var uncalled = "t.step(function() { assert_unreached('First event handler.') })"
var uncalled = "assert_unreached('First event handler.');"
var button = document.createElement('button');
button.onclick = primitive;
assert_equals(button.onclick, null);
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 1) }), false);
button.addEventListener('click', function () { assert_equals(++i, 1) }, false);
button.setAttribute('onclick', uncalled); // event handler listener is registered here
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 3) }), false);
button.onclick = t.step_func(function () { assert_equals(++i, 2); });
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 4) }), false);
button.addEventListener('click', function () { assert_equals(++i, 3) }, false);
button.onclick = function () { assert_equals(++i, 2); };
button.addEventListener('click', function () { assert_equals(++i, 4) }, false);
button.click()
assert_equals(button.getAttribute("onclick"), uncalled)
assert_equals(i, 4);
t.done()
});
}, "Event handler listeners should be registered when they are first set to an object value " +
"(" + format_value(primitive) + ").");
});
var t = async_test("Event handler listeners should be registered when they " +
"are first set to an object value.");
t.step(function() {
test(function() {
var i = 0;
var uncalled = "t.step(function() { assert_unreached('First event handler.') })"
var uncalled = "assert_unreached('First event handler.');"
var button = document.createElement('button');
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 1) }), false);
button.addEventListener('click', function () { assert_equals(++i, 1) }, false);
button.setAttribute('onclick', uncalled); // event handler listener is registered here
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 3) }), false);
button.onclick = t.step_func(function () { assert_equals(++i, 2); });
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 4) }), false);
button.addEventListener('click', function () { assert_equals(++i, 3) }, false);
button.onclick = function () { assert_equals(++i, 2); };
button.addEventListener('click', function () { assert_equals(++i, 4) }, false);
button.click()
assert_equals(button.getAttribute("onclick"), uncalled)
assert_equals(i, 4);
t.done()
});
</script>
}, "Event handler listeners should be registered when they are first set to an object value.");
<!doctype html>
<meta charset="utf-8">
<title>Invalid uncompiled raw handlers should only be compiled when about to call them.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
setup({ allow_uncaught_exception: true });
test(function() {
......@@ -20,6 +13,4 @@ test(function() {
div.dispatchEvent(new Event("click"));
assert_equals(div.onclick, null);
assert_array_equals(events, ["click 1", "error", "click 2"]);
});
</script>
</body>
}, "Invalid uncompiled raw handlers should only be compiled when about to call them");
<!doctype html>
<meta charset="utf-8">
<title>Invalid uncompiled raw handlers should only be compiled once.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
setup({ allow_uncaught_exception: true });
var errors = 0;
......@@ -18,6 +11,4 @@ test(function() {
assert_equals(e.onclick, null);
assert_equals(e.onclick, null);
assert_equals(errors, 1);
});
</script>
</body>
}, "Invalid uncompiled raw handlers should only be compiled once");
setup({ allow_uncaught_exception: true });
test(function() {
var events = [];
window.onerror = function() {
events.push("error");
};
var div = document.createElement("div");
div.addEventListener("click", function (e) { events.push("click 1"); });
div.setAttribute("onclick", "}");
div.addEventListener("click", function (e) { events.push("click 3"); });
assert_equals(div.onclick, null);
assert_array_equals(events, ["error"]);
events = [];
div.onclick = function (e) { events.push("click 2"); };
div.dispatchEvent(new Event("click"));
assert_array_equals(events, ["click 1", "click 2", "click 3"]);
}, "Compiling invalid uncompiled raw handlers should keep the position in event listener list");
const windowReflectingBodyElementEventHandlerSet =
new Set(['blur', 'error', 'focus', 'load', 'resize', 'scroll']);
function handlersInInterface(mainIDL, name) {
return mainIDL.find(idl => idl.name === name).members.map(member => member.name.slice(2));
}
const handlersListPromise = fetch("/interfaces/html.idl").then(res => res.text()).then(htmlIDL => {
const parsedHTMLIDL = WebIDL2.parse(htmlIDL);
const windowEventHandlers = handlersInInterface(parsedHTMLIDL, "WindowEventHandlers");
const globalEventHandlers = handlersInInterface(parsedHTMLIDL, "GlobalEventHandlers");
const documentAndElementEventHandlers = handlersInInterface(parsedHTMLIDL, "DocumentAndElementEventHandlers");
const shadowedHandlers = [
...windowReflectingBodyElementEventHandlerSet,
...windowEventHandlers
];
const notShadowedHandlers = [
...globalEventHandlers.filter(name => !windowReflectingBodyElementEventHandlerSet.has(name)),
...documentAndElementEventHandlers
];
return {
shadowedHandlers,
notShadowedHandlers
};
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment