-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTML: document.open() and global variables (#10815)
For whatwg/html#3918. Several tests were removed as they no longer apply after the change in HTML. The expectations were reversed and moved to the new no-new-global.window.js file. Co-authored-by: Timothy Gu <timothygu99@gmail.com>
- Loading branch information
Showing
9 changed files
with
65 additions
and
78 deletions.
There are no files selected for viewing
20 changes: 0 additions & 20 deletions
20
html/webappapis/dynamic-markup-insertion/opening-the-input-stream/001.html
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
html/webappapis/dynamic-markup-insertion/opening-the-input-stream/document.open-03.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
html/webappapis/dynamic-markup-insertion/opening-the-input-stream/no-new-global.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// In an earlier version of the HTML Standard, document open steps created a | ||
// new JavaScript realm and migrated the existing objects to use the new realm. | ||
// Test that this no longer happens. | ||
|
||
async_test(t => { | ||
const frame = document.body.appendChild(document.createElement("iframe")); | ||
// Ensure a load event gets dispatched to unblock testharness | ||
t.add_cleanup(() => frame.remove()); | ||
frame.src = "resources/global-variables-frame.html"; | ||
frame.onload = t.step_func_done(() => { | ||
assert_equals(frame.contentWindow.hey, "You", "precondition"); | ||
frame.contentDocument.open(); | ||
assert_equals(frame.contentWindow.hey, "You", "actual check"); | ||
}); | ||
}, "Obtaining a variable from a global whose document had open() invoked"); | ||
|
||
function testIdentity(desc, frameToObject, frameToConstructor) { | ||
async_test(t => { | ||
const frame = document.body.appendChild(document.createElement("iframe")); | ||
// Ensure a load event gets dispatched to unblock testharness | ||
t.add_cleanup(() => frame.remove()); | ||
frame.src = "/common/blank.html"; | ||
frame.onload = t.step_func_done(() => { | ||
const obj = frameToObject(frame); | ||
frame.contentDocument.open(); | ||
assert_equals(frameToObject(frame), obj); | ||
}); | ||
}, `${desc} maintains object identity through open()`); | ||
|
||
async_test(t => { | ||
const frame = document.body.appendChild(document.createElement("iframe")); | ||
// Ensure a load event gets dispatched to unblock testharness | ||
t.add_cleanup(() => frame.remove()); | ||
frame.src = "/common/blank.html"; | ||
frame.onload = t.step_func_done(() => { | ||
const obj = frameToObject(frame); | ||
const origProto = Object.getPrototypeOf(obj); | ||
const origCtor = frameToConstructor(frame); | ||
const sym = Symbol(); | ||
obj[sym] = "foo"; | ||
frame.contentDocument.open(); | ||
assert_equals(frameToObject(frame)[sym], "foo"); | ||
assert_true(frameToObject(frame) instanceof origCtor); | ||
assert_equals(Object.getPrototypeOf(frameToObject(frame)), origProto); | ||
assert_equals(frameToConstructor(frame), origCtor); | ||
}); | ||
}, `${desc} maintains its prototype and properties through open()`); | ||
} | ||
|
||
testIdentity("Document", frame => frame.contentDocument, frame => frame.contentWindow.Document); | ||
testIdentity("WindowProxy", frame => frame.contentWindow, frame => frame.contentWindow.Window); | ||
testIdentity("BarProp", frame => frame.contentWindow.locationbar, frame => frame.contentWindow.BarProp); | ||
testIdentity("History", frame => frame.contentWindow.history, frame => frame.contentWindow.History); | ||
testIdentity("localStorage", frame => frame.contentWindow.localStorage, frame => frame.contentWindow.Storage); | ||
testIdentity("Location", frame => frame.contentWindow.location, frame => frame.contentWindow.Location); | ||
testIdentity("sessionStorage", frame => frame.contentWindow.sessionStorage, frame => frame.contentWindow.Storage); | ||
testIdentity("Navigator", frame => frame.contentWindow.navigator, frame => frame.contentWindow.Navigator); |
4 changes: 4 additions & 0 deletions
4
...s/dynamic-markup-insertion/opening-the-input-stream/resources/global-variables-frame.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!doctype html> | ||
<script> | ||
hey = "You"; | ||
</script> |