Update web-platform-tests to revision b'b728032f59a396243864b0f8584e7211e3632005'

This commit is contained in:
WPT Sync Bot 2022-11-10 01:22:36 +00:00
parent ace9b32b1c
commit df68c4e5d1
15632 changed files with 514865 additions and 155000 deletions

View file

@ -1,19 +1,48 @@
"use strict";
// For now this only has per-Window tests, but we could expand it to also test per-Document
// This is for testing whether an object (e.g., a global property) is associated with Window, or
// with Document. Recall that Window and Document are 1:1 except when doing a same-origin navigation
// away from the initial about:blank. In that case the Window object gets reused for the new
// Document.
//
// So:
// - If something is per-Window, then it should maintain its identity across an about:blank
// navigation.
// - If something is per-Document, then it should be recreated across an about:blank navigation.
/**
* Run tests for window[propertyName] after discarding the browsing context, navigating, etc.
* @param {string} propertyName
*/
window.testIsPerWindow = propertyName => {
test(t => {
runTests(propertyName, assert_equals, "must not");
};
window.testIsPerDocument = propertyName => {
runTests(propertyName, assert_not_equals, "must");
};
function runTests(propertyName, equalityOrInequalityAsserter, mustOrMustNotReplace) {
async_test(t => {
const iframe = document.createElement("iframe");
document.body.appendChild(iframe);
const frame = iframe.contentWindow;
const before = frame[propertyName];
assert_true(before !== undefined && before !== null, `window.${propertyName} must be implemented`);
assert_implements(before, `window.${propertyName} must be implemented`);
iframe.onload = t.step_func_done(() => {
const after = frame[propertyName];
equalityOrInequalityAsserter(after, before);
});
iframe.src = "/common/blank.html";
}, `Navigating from the initial about:blank ${mustOrMustNotReplace} replace window.${propertyName}`);
// Per spec, discarding a browsing context should not change any of the global objects.
test(() => {
const iframe = document.createElement("iframe");
document.body.appendChild(iframe);
const frame = iframe.contentWindow;
const before = frame[propertyName];
assert_implements(before, `window.${propertyName} must be implemented`);
iframe.remove();
@ -21,38 +50,15 @@ window.testIsPerWindow = propertyName => {
assert_equals(after, before, `window.${propertyName} should not change after iframe.remove()`);
}, `Discarding the browsing context must not change window.${propertyName}`);
async_test(t => {
const iframe = document.createElement("iframe");
document.body.appendChild(iframe);
const frame = iframe.contentWindow;
const before = frame[propertyName];
assert_true(before !== undefined && before !== null, `window.${propertyName} must be implemented`);
// Note: cannot use step_func_done for this because it might be called twice, per the below comment.
iframe.onload = t.step_func(() => {
if (frame.location.href === "about:blank") {
// Browsers are not reliable on whether about:blank fires the load event; see
// https://github.com/whatwg/html/issues/490
return;
}
const after = frame[propertyName];
assert_equals(after, before);
t.done();
});
iframe.src = "/common/blank.html";
}, `Navigating from the initial about:blank must not replace window.${propertyName}`);
// Per spec, document.open() should not change any of the Window state.
// Per spec, document.open() should not change any of the global objects. In historical versions
// of the spec, it did, so we test here.
async_test(t => {
const iframe = document.createElement("iframe");
iframe.onload = t.step_func_done(() => {
const frame = iframe.contentWindow;
const before = frame[propertyName];
assert_true(before !== undefined && before !== null, `window.${propertyName} must be implemented`);
assert_implements(before, `window.${propertyName} must be implemented`);
frame.document.open();
@ -64,5 +70,5 @@ window.testIsPerWindow = propertyName => {
iframe.src = "/common/blank.html";
document.body.appendChild(iframe);
}, `document.open() must replace window.${propertyName}`);
};
}, `document.open() must not replace window.${propertyName}`);
}