Update web-platform-tests to revision d7afcb8708eac08a614d161d5622a48172daf7e3

This commit is contained in:
WPT Sync Bot 2019-05-15 10:40:54 -04:00 committed by Josh Matthews
parent 6f8bb4dd40
commit edff458e23
791 changed files with 17647 additions and 10322 deletions

View file

@ -0,0 +1,74 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/common.js"></script>
<title> 'focus-without-user-activation' Policy : Correctly block automatic focus when policy disabled
</title>
<body>
<input onblur="did_blur();" autofocus/>
<script>
"use strict"
const url = "http://{{hosts[alt][www1]}}:{{ports[http][0]}}/feature-policy/experimental-features/resources/focus_steal.html";
let did_blur_ = false;
function did_blur() {
did_blur_ = true;
}
function short_delay(test_instance) {
// Long enough to allow focus to propagate correctly.
const SHORT_DELAY = 400;
return new Promise( (r) => test_instance.step_timeout(r, SHORT_DELAY));
}
function reset_focus() {
did_blur_ = false;
document.querySelector("input").focus();
}
promise_test( async (instance) => {
const frame = createIframe(document.body, {
sandbox: "allow-scripts allow-same-origin",
allow: "focus-without-user-activation 'none'",
src: url
});
await wait_for_load(frame);
await short_delay(instance);
assert_false(did_blur_, "'autofocus' should not work.");
frame.contentWindow.postMessage("focus-input", "*");
await short_delay(instance);
assert_false(did_blur_, "'element.focus' should not work.");
frame.contentWindow.postMessage("focus-window", "*");
await short_delay(instance);
assert_false(did_blur_, "'window.focus' should not work.");
}, "When the policy is disabled, 'autofocus' and scripted focus do not focus " +
"the document.");
promise_test( async (instance) => {
const frame = createIframe(document.body, {
sandbox: "allow-scripts allow-same-origin",
allow: "focus-without-user-activation *",
src: url
});
await wait_for_load(frame);
await short_delay(instance);
reset_focus();
frame.contentWindow.postMessage("focus-input", "*");
await short_delay(instance);
assert_true(did_blur_, "'element.focus' should work.");
did_blur_ = false;
reset_focus();
frame.contentWindow.postMessage("focus-window", "*");
await short_delay(instance);
assert_true(did_blur_, "'window.focus' should work.");
}, "When the policy is enabled, 'autofocus' and scripted focus do focus " +
"the document.");
</script>
</body>

View file

@ -0,0 +1,12 @@
<!doctype html>
<input autofocus/>
<script>
window.addEventListener("message", (e) => {
if (e.data === "focus-window") {
window.focus();
}
else if (e.data === "focus-input") {
document.querySelector("input").focus();
}
});
</script>

View file

@ -7,7 +7,13 @@
<body>
<div id='fs'></div>
<script>
var observer1;
var observer2;
var check_report_format = (reports, observer) => {
// Test that observer2 is notified, even if it is disconnected.
observer1.disconnect();
observer2.disconnect();
let report = reports[0];
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
@ -18,9 +24,19 @@ var check_report_format = (reports, observer) => {
assert_equals(report.body.disposition, "enforce");
};
var check_second_observer = (reports, observer) => {
let report = reports[0];
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.body.featureId, "fullscreen");
};
async_test(t => {
new ReportingObserver(t.step_func_done(check_report_format),
{types: ['feature-policy-violation']}).observe();
observer1 = new ReportingObserver(t.step_func(check_report_format),
{types: ['feature-policy-violation']});
observer1.observe();
observer2 = new ReportingObserver(t.step_func_done(check_second_observer),
{types: ['feature-policy-violation']});
observer2.observe();
document.getElementById('fs').requestFullscreen().then(t.unreached_func(
"Fullscreen should not be allowed in this document.")).catch(()=>{});
}, "Fullscreen Report Format");

View file

@ -1,9 +1,9 @@
<script>
"use strict";
Promise.resolve().then(async () => {
Promise.resolve().then(() => {
try {
const wakeLock = await navigator.getWakeLock("screen");
const wakeLock = new WakeLock("screen");
window.parent.postMessage({ enabled: true }, "*");
} catch (e) {
window.parent.postMessage({ enabled: false }, "*");