MCPcopy Create free account
hub / github.com/nodejs/node / runTests

Function runTests

test/fixtures/wpt/common/object-association.js:21–74  ·  view source on GitHub ↗
(propertyName, equalityOrInequalityAsserter, mustOrMustNotReplace)

Source from the content-addressed store, hash-verified

19};
20
21function runTests(propertyName, equalityOrInequalityAsserter, mustOrMustNotReplace) {
22 async_test(t => {
23 const iframe = document.createElement("iframe");
24 document.body.appendChild(iframe);
25 const frame = iframe.contentWindow;
26
27 const before = frame[propertyName];
28 assert_implements(before, `window.${propertyName} must be implemented`);
29
30 iframe.onload = t.step_func_done(() => {
31 const after = frame[propertyName];
32 equalityOrInequalityAsserter(after, before);
33 });
34
35 iframe.src = "/common/blank.html";
36 }, `Navigating from the initial about:blank ${mustOrMustNotReplace} replace window.${propertyName}`);
37
38 // Per spec, discarding a browsing context should not change any of the global objects.
39 test(() => {
40 const iframe = document.createElement("iframe");
41 document.body.appendChild(iframe);
42 const frame = iframe.contentWindow;
43
44 const before = frame[propertyName];
45 assert_implements(before, `window.${propertyName} must be implemented`);
46
47 iframe.remove();
48
49 const after = frame[propertyName];
50 assert_equals(after, before, `window.${propertyName} should not change after iframe.remove()`);
51 }, `Discarding the browsing context must not change window.${propertyName}`);
52
53 // Per spec, document.open() should not change any of the global objects. In historical versions
54 // of the spec, it did, so we test here.
55 async_test(t => {
56 const iframe = document.createElement("iframe");
57
58 iframe.onload = t.step_func_done(() => {
59 const frame = iframe.contentWindow;
60 const before = frame[propertyName];
61 assert_implements(before, `window.${propertyName} must be implemented`);
62
63 frame.document.open();
64
65 const after = frame[propertyName];
66 assert_equals(after, before);
67
68 frame.document.close();
69 });
70
71 iframe.src = "/common/blank.html";
72 document.body.appendChild(iframe);
73 }, `document.open() must not replace window.${propertyName}`);
74}

Callers 1

Calls 8

createElementMethod · 0.80
openMethod · 0.65
closeMethod · 0.65
async_testFunction · 0.50
assert_implementsFunction · 0.50
testFunction · 0.50
assert_equalsFunction · 0.50
removeMethod · 0.45

Tested by

no test coverage detected