(propertyName, equalityOrInequalityAsserter, mustOrMustNotReplace)
| 19 | }; |
| 20 | |
| 21 | function 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 | } |
no test coverage detected