dom: expose browser window constructor identity
This commit is contained in:
1 parent
37f6c93af9
commit
9dfc67af74
2 files changed
+28
No files matched your search
Vendored
+11
@@ -3715,6 +3715,17 @@ Object.defineProperty(globalThis.Window, Symbol.hasInstance, {
|
||||
value(obj) { return obj === globalThis || (obj && obj.window === obj); },
|
||||
configurable: true,
|
||||
});
|
||||
// A browser global is a Window object, not merely an object accepted by
|
||||
// `Window[Symbol.hasInstance]`. Framework environment gates (including Ember's)
|
||||
// also require the direct identity `self.constructor === Window`; leaving the
|
||||
// inherited Object constructor makes them enter their server-rendering path
|
||||
// and hand string selectors to DOM render operations.
|
||||
Object.defineProperty(globalThis, 'constructor', {
|
||||
value: globalThis.Window,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
});
|
||||
|
||||
|
||||
// Remove the static _iframeRegistry and replace with dynamic getters.
|
||||
|
||||
@@ -1809,6 +1809,23 @@ mod tests {
|
||||
assert_eq!(title, serde_json::json!("Test Page"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn global_window_has_browser_constructor_identity() {
|
||||
let mut rt = setup_runtime("<html><body></body></html>");
|
||||
let result = rt
|
||||
.evaluate(
|
||||
"return [window === self, self.constructor === Window,\
|
||||
window instanceof Window, self.document === document,\
|
||||
self.location === location, self.history === history,\
|
||||
self.navigator === navigator];",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
result,
|
||||
serde_json::json!([true, true, true, true, true, true, true])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_viewport_is_distinct_from_fingerprinted_screen() {
|
||||
let dom = parse_html("<html><body></body></html>");
|
||||
|
||||
Reference in new issue
Block a user