Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WebIDL] Default toJSON() method should create result object in its r…
…ealm https://bugs.webkit.org/show_bug.cgi?id=244939 Reviewed by NOBODY (OOPS!). Per ECMA-262 [1], %Object.prototype% notation points to current realm, which is the realm of toJSON() function [2], and not the relevant one. Aligns WebKit with Blink and Gecko. [1] https://tc39.es/ecma262/#sec-well-known-intrinsic-objects (paragraph 2) [2] https://webidl.spec.whatwg.org/#default-tojson-steps (step 4) * LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/default-toJSON-cross-realm-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/default-toJSON-cross-realm.html: Added. * Source/WebCore/bindings/scripts/CodeGeneratorJS.pm: (GenerateDefaultToJSONOperationDefinition): * Source/WebCore/bindings/scripts/test/JS/*: Updated.
- Loading branch information
1 parent
79593cc
commit b72b25a
Showing
8 changed files
with
35 additions
and
6 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
.../w3c/web-platform-tests/WebIDL/ecmascript-binding/default-toJSON-cross-realm-expected.txt
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 @@ | ||
|
||
PASS Cross-realm [Default] toJSON() creates result object in its realm | ||
PASS Cross-realm [Default] toJSON() converts its interface attributes to ECMAScript values of correct realm | ||
|
25 changes: 25 additions & 0 deletions
25
...imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/default-toJSON-cross-realm.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,25 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Cross-realm [Default] toJSON() creates result object in its realm</title> | ||
<link rel="help" href="https://webidl.spec.whatwg.org/#default-tojson-steps"> | ||
|
||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support/create-realm.js"></script> | ||
|
||
<body> | ||
<script> | ||
promise_test(async t => { | ||
const other = await createRealm(t); | ||
const json = other.DOMRectReadOnly.prototype.toJSON.call(new DOMRectReadOnly()); | ||
|
||
assert_equals(Object.getPrototypeOf(json), other.Object.prototype); | ||
}, "Cross-realm [Default] toJSON() creates result object in its realm"); | ||
|
||
promise_test(async t => { | ||
const other = await createRealm(t); | ||
const json = other.DOMQuad.prototype.toJSON.call(new DOMQuad()); | ||
|
||
assert_equals(Object.getPrototypeOf(json.p1), DOMPoint.prototype); | ||
}, "Cross-realm [Default] toJSON() converts its interface attributes to ECMAScript values of correct realm"); | ||
</script> |
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
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