Update web-platform-tests to revision 345300fad3945a5f1441fb2b2001109ca48f36e8

This commit is contained in:
WPT Sync Bot 2019-02-08 20:38:29 -05:00
parent 71ba247942
commit 05db47be0f
109 changed files with 2576 additions and 1228 deletions

View file

@ -1,82 +0,0 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<!-- SEKRITS! -->
<input id="sekrit" value="omg!">
<script>
function postMessageToFrame(frame, message) {
return new Promise(resolve => {
var c = new MessageChannel();
c.port1.onmessage = e => {
resolve({ data: e.data, frame: frame })
};
frame.contentWindow.postMessage(message, '*', [c.port2]);
});
}
function createFrame() {
return new Promise(resolve => {
var i = document.createElement('iframe');
i.src = "./support/document_domain_frame.html";
window.addEventListener('message', m => {
if (m.source == i.contentWindow)
resolve(i);
});
document.body.appendChild(i);
});
}
promise_test(t => {
return createFrame()
.then(f => postMessageToFrame(f, 'poke-at-parent'))
.then(result => {
assert_equals(result.data, document.querySelector('#sekrit').value);
result.frame.remove();
});
}, "Access allowed with no 'document.domain' modification. (Sanity check)");
promise_test(t => {
return createFrame()
.then(f => postMessageToFrame(f, { domain: null }))
.then(result => {
assert_equals(result.data, 'Done');
return postMessageToFrame(result.frame, 'poke-at-parent')
.then(result => {
assert_equals(result.data, 'SecurityError');
result.frame.remove();
});
});
}, "No access when frame sets a `null` 'document.domain'.");
promise_test(t => {
return createFrame()
.then(f => {
document.domain = null;
assert_equals(document.domain, "null");
return postMessageToFrame(f, 'poke-at-parent');
})
.then(result => {
assert_equals(result.data, 'SecurityError');
result.frame.remove();
});
}, "No access when parent sets a `null` 'document.domain'.");
promise_test(t => {
return createFrame()
.then(f => {
document.domain = null;
assert_equals(document.domain, "null");
return postMessageToFrame(f, { domain: null });
})
.then(result => {
assert_equals(result.data, 'Done');
return postMessageToFrame(result.frame, 'poke-at-parent')
.then(result => {
assert_equals(result.data, 'SecurityError');
result.frame.remove();
});
});
}, "No access when both sides set a `null` 'document.domain'.");
</script>

View file

@ -1,21 +0,0 @@
<!DOCTYPE html>
<script>
window.addEventListener('message', e => {
if (e.data.domain !== undefined) {
try {
document.domain = e.data.domain;
e.ports[0].postMessage('Done');
} catch(error) {
e.ports[0].postMessage(error.name);
}
} else if (e.data == 'poke-at-parent') {
try {
var sekrit = window.parent.document.body.querySelector('#sekrit').value;
e.ports[0].postMessage(sekrit);
} catch(error) {
e.ports[0].postMessage(error.name);
}
}
});
window.parent.postMessage('Hi!', '*');
</script>

View file

@ -1,5 +1,6 @@
<!doctype html>
<meta charset={{GET[encoding]}}> <!-- ends up as <meta charset> by default which is windows-1252 -->
<meta name=variant content="?encoding=windows-1252">
<meta name=variant content="?encoding=x-cp1251">
<meta name=variant content="?encoding=utf8">
<script src=/resources/testharness.js></script>

View file

@ -1,5 +1,6 @@
<!doctype html>
<meta charset={{GET[encoding]}}> <!-- ends up as <meta charset> by default which is windows-1252 -->
<meta name=variant content="?encoding=windows-1252">
<meta name=variant content="?encoding=x-cp1251">
<meta name=variant content="?encoding=utf8">
<script src=/resources/testharness.js></script>

View file

@ -1,5 +1,6 @@
<!doctype html>
<meta charset={{GET[encoding]}}> <!-- ends up as <meta charset> by default which is windows-1252 -->
<meta name=variant content="?encoding=windows-1252">
<meta name=variant content="?encoding=x-cp1251">
<meta name=variant content="?encoding=utf8">
<script src=/resources/testharness.js></script>

View file

@ -1 +1,2 @@
// import()s in a dynamically created function are resolved relative to the script.
Function(`import('../../imports-a.js?label=' + window.label).then(window.continueTest, window.errorTest)`)();

View file

@ -1 +1,2 @@
// import()s in eval are resolved relative to the script.
eval(`import('../../imports-a.js?label=' + window.label).then(window.continueTest, window.errorTest)`);

View file

@ -1,2 +1,3 @@
window.dummyDiv.setAttribute("onclick", `import('../../imports-a.js?label=' + window.label).then(window.continueTest, window.errorTest)`);
// import()s in an event handler are resolved relative to the document base.
window.dummyDiv.setAttribute("onclick", `import('../imports-a.js?label=' + window.label).then(window.continueTest, window.errorTest)`);
window.dummyDiv.click(); // different from **on**click()

View file

@ -1,2 +1,3 @@
window.dummyDiv.setAttribute("onclick", `import('../../imports-a.js?label=' + window.label).then(window.continueTest, window.errorTest)`);
// import()s in an event handler are resolved relative to the document base.
window.dummyDiv.setAttribute("onclick", `import('../imports-a.js?label=' + window.label).then(window.continueTest, window.errorTest)`);
window.dummyDiv.onclick();

View file

@ -1 +1,2 @@
// import()s in a timeout handler are resolved relative to the script.
setTimeout(`import('../../imports-a.js?label=' + window.label).then(window.continueTest, window.errorTest)`, 0);

View file

@ -37,7 +37,7 @@ function assertSuccessful(module) {
promise_test(t => {
const promise = createTestPromise(t);
setTimeout(`import('../imports-a.js?label=setTimeout').then(window.unreached, window.continueTest)`, 0);
setTimeout(`import('../imports-a.js?label=setTimeout').then(window.continueTest, window.errorTest)`, 0);
return promise.then(assertSuccessful);
}, "setTimeout must inherit the nonce from the triggering script, thus execute");
@ -81,8 +81,8 @@ promise_test(t => {
);
dummyDiv.onclick();
return promise.then(assertSuccessful);
}, "reflected inline event handlers must inherit the nonce from the triggering script, thus execute");
return promise_rejects(t, new TypeError(), promise);
}, "reflected inline event handlers must not inherit the nonce from the triggering script, thus fail");
promise_test(t => {
t.add_cleanup(() => {
@ -99,6 +99,6 @@ promise_test(t => {
assert_equals(typeof dummyDiv.onclick, "function", "the browser must be able to parse a string containing the import() syntax into a function");
dummyDiv.click(); // different from **on**click()
return promise.then(assertSuccessful);
}, "inline event handlers triggered via UA code must inherit the nonce from the triggering script, thus execute");
return promise_rejects(t, new TypeError(), promise);
}, "inline event handlers triggered via UA code must not inherit the nonce from the triggering script, thus fail");
</script>

View file

@ -36,7 +36,7 @@ function assertSuccessful(module) {
promise_test(t => {
const promise = createTestPromise(t);
setTimeout(`import('../imports-a.js?label=setTimeout').then(window.unreached, window.continueTest)`, 0);
setTimeout(`import('../imports-a.js?label=setTimeout').then(window.continueTest, window.errorTest)`, 0);
return promise.then(assertSuccessful);
}, "setTimeout must inherit the nonce from the triggering script, thus execute");
@ -80,8 +80,8 @@ promise_test(t => {
);
dummyDiv.onclick();
return promise.then(assertSuccessful);
}, "reflected inline event handlers must inherit the nonce from the triggering script, thus execute");
return promise_rejects(t, new TypeError(), promise);
}, "reflected inline event handlers must not inherit the nonce from the triggering script, thus fail");
promise_test(t => {
t.add_cleanup(() => {
@ -98,6 +98,6 @@ promise_test(t => {
assert_equals(typeof dummyDiv.onclick, 'function', "the browser must be able to parse a string containing the import() syntax into a function");
dummyDiv.click(); // different from **on**click()
return promise.then(assertSuccessful);
}, "inline event handlers triggered via UA code must inherit the nonce from the triggering script, thus execute");
return promise_rejects(t, new TypeError(), promise);
}, "inline event handlers triggered via UA code must not inherit the nonce from the triggering script, thus fail");
</script>

View file

@ -26,14 +26,6 @@ function startTest() {
"the Function constructor"(x) {
otherWindow.Function(x)();
},
"reflected inline event handlers"(x) {
otherDiv.setAttribute("onclick", x);
otherDiv.onclick();
},
"inline event handlers triggered by JS"(x) {
otherDiv.setAttribute("onclick", x);
otherDiv.click(); // different from .**on**click()
}
};
for (const [label, evaluator] of Object.entries(evaluators)) {
@ -53,6 +45,35 @@ function startTest() {
});
}, label + " should successfully import");
};
const eventHandlerEvaluators = {
"reflected inline event handlers"(x) {
otherDiv.setAttribute("onclick", x);
otherDiv.onclick();
},
"inline event handlers triggered by JS"(x) {
otherDiv.setAttribute("onclick", x);
otherDiv.click(); // different from .**on**click()
}
};
for (const [label, evaluator] of Object.entries(eventHandlerEvaluators)) {
promise_test(t => {
t.add_cleanup(() => {
otherDiv.removeAttribute("onclick");
delete otherWindow.evaluated_imports_a;
});
const promise = createTestPromise();
evaluator(`import('../../imports-a.js?label=${label}').then(window.continueTest, window.errorTest);`);
return promise.then(module => {
assert_true(otherWindow.evaluated_imports_a, "The module must have been evaluated");
assert_equals(module.A.from, "imports-a.js", "The module namespace object must be correct");
});
}, label + " should successfully import");
};
}
</script>
<body onLoad="startTest()"></body>