mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision bf42dca1ce568ce559d5a4cad507239035b91dcb
This commit is contained in:
parent
91d2bd3d64
commit
20e57b5c74
81 changed files with 3616 additions and 289 deletions
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<iframe id="iframe" width="200" height="100"></iframe>
|
||||
|
||||
<script>
|
||||
iframe.src =
|
||||
get_host_info().ORIGIN + "/html/semantics/forms/autofocus/resources/grand-child-autofocus.html";
|
||||
window.addEventListener("message", event => {
|
||||
if (event.data == "grand_child_loaded") {
|
||||
parent.postMessage("ready", "*");
|
||||
} else if (event.data == "report_focus_state") {
|
||||
frames[0].postMessage("report_focus_state", "*");
|
||||
} else if (event.data == "grand_child_is_focused" ||
|
||||
event.data == "grand_child_is_not_focused") {
|
||||
parent.postMessage(event.data, "*");
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<input id="target" value="This should be focused!" autofocus></input>
|
||||
|
||||
<script>
|
||||
let got_focus = false;
|
||||
target.addEventListener("focus", () => got_focus = true);
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
parent.postMessage("grand_child_loaded", "*");
|
||||
});
|
||||
|
||||
window.addEventListener("message", event => {
|
||||
if (event.data == "report_focus_state") {
|
||||
let msg = got_focus ? "grand_child_is_focused" : "grand_child_is_not_focused";
|
||||
parent.postMessage(msg, "*");
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,46 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8>
|
||||
<meta name="assert" content="`autofocus` should work in the same origin iframe even if there is a cross-origin iframe between the parent and the same origin iframe">
|
||||
<title>autofocus in the same origin grand child iframe</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Autofocus should work in the same origin grand child iframe.</h1>
|
||||
<iframe id="child" width="200" height="100"></iframe>
|
||||
<script>
|
||||
let parent_loaded = false;
|
||||
let grand_child_loaded = false;
|
||||
|
||||
async_test(function(t) {
|
||||
function pingChildIfBothFramesLoaded() {
|
||||
if (parent_loaded && grand_child_loaded)
|
||||
frames[0].postMessage("report_focus_state", "*");
|
||||
}
|
||||
|
||||
window.addEventListener("load", t.step_func(event => {
|
||||
parent_loaded = true;
|
||||
pingChildIfBothFramesLoaded();
|
||||
}));
|
||||
|
||||
window.addEventListener("message", t.step_func(event => {
|
||||
if (event.data == "ready") {
|
||||
grand_child_loaded = true;
|
||||
pingChildIfBothFramesLoaded();
|
||||
} else if (event.data == "grand_child_is_focused") {
|
||||
t.done();
|
||||
} else if (event.data == "grand_child_is_not_focused") {
|
||||
assert_unreached("The iframe shouldn't get focus");
|
||||
}
|
||||
}));
|
||||
document.getElementById("child").src =
|
||||
get_host_info().HTTP_NOTSAMESITE_ORIGIN + "/html/semantics/forms/autofocus/resources/child-iframe.html";
|
||||
}, "Autofocus should work in the same origin grand child iframe");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -8,11 +8,19 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
promise_test(async () => {
|
||||
let doc = document.cloneNode(false);
|
||||
doc.appendChild(doc.createElement('html'))
|
||||
doc.firstChild.innerHTML = '<body><input autofocus/></body>';
|
||||
await waitUntilStableAutofocusState();
|
||||
assert_equals(doc.activeElement, doc.body);
|
||||
}, 'Autofocus element in not-fully-active document should not be queued.');
|
||||
|
||||
promise_test(async () => {
|
||||
let iframe = document.querySelector('iframe');
|
||||
let iframeDocument = iframe.contentDocument;
|
||||
await waitForLoad(window);
|
||||
assert_not_equals(document.activeElement, iframe);
|
||||
assert_equals(iframeDocument.activeElement, iframeDocument.body);
|
||||
}, 'Autofocus element in not-fully-active document should be skipped.');
|
||||
}, 'Autofocus element in not-fully-active document should be skipped while flusing.');
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue