Update web-platform-tests to revision b'8a99353217938b6f1da31a9a108da3d501cee58b'

This commit is contained in:
WPT Sync Bot 2023-01-20 01:38:13 +00:00
parent 62ec0f1ec7
commit 92be0baf34
211 changed files with 5373 additions and 2272 deletions

View file

@ -9,28 +9,41 @@ function processQueryParams() {
};
}
function CreateFrameAndRunTests(setUpFrame) {
// Create an iframe element, set it up using `setUpFrame`, and optionally fetch
// tests in it. Returns the created frame, after it has loaded.
function CreateFrameHelper(setUpFrame, fetchTests) {
const frame = document.createElement('iframe');
const promise = new Promise((resolve, reject) => {
frame.onload = resolve;
frame.onload = () => resolve(frame);
frame.onerror = reject;
});
setUpFrame(frame);
fetch_tests_from_window(frame.contentWindow);
if (fetchTests) {
fetch_tests_from_window(frame.contentWindow);
}
return promise;
}
function RunTestsInIFrame(sourceURL) {
return CreateFrameAndRunTests((frame) => {
// Create an iframe element with content loaded from `sourceURL`, append it to
// the document, and optionally fetch tests. Returns the loaded frame, once
// ready.
function CreateFrame(sourceURL, fetchTests = false) {
return CreateFrameHelper((frame) => {
frame.src = sourceURL;
document.body.appendChild(frame);
});
}, fetchTests);
}
// Create a new iframe with content loaded from `sourceURL`, and fetches tests.
// Returns the loaded frame, once ready.
function RunTestsInIFrame(sourceURL) {
return CreateFrame(sourceURL, true);
}
function RunTestsInNestedIFrame(sourceURL) {
return CreateFrameAndRunTests((frame) => {
return CreateFrameHelper((frame) => {
document.body.appendChild(frame);
frame.contentDocument.write(`
<script src="/resources/testharness.js"></script>
@ -41,7 +54,7 @@ function RunTestsInNestedIFrame(sourceURL) {
</script>
`);
frame.contentDocument.close();
});
}, true);
}
function RunRequestStorageAccessInDetachedFrame() {
@ -61,3 +74,61 @@ function RunRequestStorageAccessViaDomParser() {
function RunCallbackWithGesture(callback) {
return test_driver.bless('run callback with user gesture', callback);
}
// Sends a message to the given target window, and waits for the provided
// promise to resolve.
function PostMessageAndAwait(message, targetWindow, promise) {
targetWindow.postMessage(message, "*");
return promise;
}
// Returns a promise that resolves when the next "reply" is received via
// postMessage.
function ReplyPromise() {
return new Promise((resolve) => {
window.addEventListener("message", (event) => {
resolve(event.data);
}, { once: true });
});
}
// Returns a promise that resolves when the given frame fires its load event.
function ReloadPromise(frame) {
return new Promise((resolve) => {
frame.addEventListener("load", (event) => {
resolve();
}, { once: true });
});
}
// Reads cookies via document.cookie in the given frame.
function GetJSCookiesFromFrame(frame) {
return PostMessageAndAwait({ command: "document.cookie" }, frame.contentWindow, ReplyPromise());
}
// Reads cookies via the `httpCookies` variable in the given frame.
function GetHTTPCookiesFromFrame(frame) {
return PostMessageAndAwait({ command: "httpCookies" }, frame.contentWindow, ReplyPromise());
}
// Executes document.hasStorageAccess in the given frame.
function FrameHasStorageAccess(frame) {
return PostMessageAndAwait({ command: "hasStorageAccess" }, frame.contentWindow, ReplyPromise());
}
// Executes document.requestStorageAccess in the given frame.
function RequestStorageAccessInFrame(frame) {
return PostMessageAndAwait({ command: "requestStorageAccess" }, frame.contentWindow, ReplyPromise());
}
// Executes test_driver.set_permission in the given frame, with the provided
// arguments.
function SetPermissionInFrame(frame, args = []) {
return PostMessageAndAwait({ command: "set_permission", args }, frame.contentWindow, ReplyPromise());
}
// Executes `location.reload()` in the given frame. The returned promise
// resolves when the frame has finished reloading.
function FrameInitiatedReload(frame) {
return PostMessageAndAwait({ command: "reload" }, frame.contentWindow, ReloadPromise(frame));
}