Update web-platform-tests to revision 4052654d786236b493d2df3cb80b9d3d1d0a8354

This commit is contained in:
WPT Sync Bot 2018-12-12 21:08:47 -05:00
parent eab848df3e
commit 3b6ddd885a
116 changed files with 4255 additions and 821 deletions

View file

@ -11,40 +11,7 @@
setup({ explicit_done: true });
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;
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})`);
});
}
eventHandlerTest(shadowedHandlers, notShadowedHandlers, "body");
done();
});

View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>event handlers</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<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 });
handlersListPromise.then(({ shadowedHandlers, notShadowedHandlers }) => {
eventHandlerTest(shadowedHandlers, notShadowedHandlers, "frameset");
// The testharness framework appends test results to document.body,
// show test results in frame after test done.
add_completion_callback(() => {
const log_elem = document.getElementById("log");
const frame_elem = document.querySelector("frame");
frame_elem.contentDocument.body.innerHTML = log_elem.innerHTML;
});
done();
});
</script>
<frameset>
<frame src="/common/blank.html" />
</frameset>

View file

@ -1,49 +0,0 @@
<!DOCTYPE html>
<title>HTMLBodyElement event handlers</title>
<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;
}
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}`);
});
[...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`);
});
done();
});
</script>

View file

@ -24,3 +24,42 @@ const handlersListPromise = fetch("/interfaces/html.idl").then(res => res.text()
notShadowedHandlers
};
});
function eventHandlerTest(shadowedHandlers, notShadowedHandlers, element) {
const altBody = document.createElement(element);
for (const [des, obj1, obj2, obj3, des1, des2, des3] of [
["document.body", document.body, altBody, window, "body", "alternative body", "window"],
[`document.createElement("${element}")`, altBody, document.body, window, "alternative body", "body", "window"],
["window", window, document.body, altBody, "window", "body", "alternative body"]
]) {
const f = () => 0;
shadowedHandlers.forEach(handler => {
const eventHandler = obj1['on' + handler];
test(() => {
obj1['on' + handler] = f;
assert_equals(obj2['on' + handler], f, `${des2} should reflect`);
assert_equals(obj3['on' + handler], f, `${des3} should reflect`);
}, `shadowed ${handler} (${des})`);
obj1['on' + handler] = eventHandler;
});
notShadowedHandlers.forEach(handler => {
const eventHandler = obj1['on' + handler];
test(() => {
obj1['on' + handler] = f;
assert_equals(obj2['on' + handler], null, `${des2} should reflect`);
assert_equals(obj3['on' + handler], null, `${des3} should reflect`);
}, `not shadowed ${handler} (${des})`);
obj1['on' + handler] = eventHandler;
});
shadowedHandlers.forEach(handler => {
test(() => {
assert_equals(obj1['on' + handler], null, `${des1} should reflect changes to itself`);
assert_equals(obj2['on' + handler], null, `${des2} should reflect`);
assert_equals(obj3['on' + handler], null, `${des3} should reflect`);
}, `shadowed ${handler} removal (${des})`);
});
}
}