default-toJSON-cross-realm.html (1003B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Cross-realm [Default] toJSON() creates result object in its realm</title> 4 <link rel="help" href="https://webidl.spec.whatwg.org/#default-tojson-steps"> 5 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="support/create-realm.js"></script> 9 10 <body> 11 <script> 12 promise_test(async t => { 13 const other = await createRealm(t); 14 const json = other.DOMRectReadOnly.prototype.toJSON.call(new DOMRectReadOnly()); 15 16 assert_equals(Object.getPrototypeOf(json), other.Object.prototype); 17 }, "Cross-realm [Default] toJSON() creates result object in its realm"); 18 19 promise_test(async t => { 20 const other = await createRealm(t); 21 const json = other.DOMQuad.prototype.toJSON.call(new DOMQuad()); 22 23 assert_equals(Object.getPrototypeOf(json.p1), DOMPoint.prototype); 24 }, "Cross-realm [Default] toJSON() converts its interface attributes to ECMAScript values of correct realm"); 25 </script> 26 </body>