Skip to content

Commit

Permalink
Add a test for the mutability of the ShadowRealm global prototype chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Jan 19, 2024
1 parent edd5eee commit b8bca44
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions webidl/ecmascript-binding/global-mutable-prototype.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// META: global=shadowrealm
// META: title=Mutability of the global prototype chain

const objects = [];
setup(() => {
for (let object = self; object; object = Object.getPrototypeOf(object)) {
objects.push(object);
}
});

test(() => {
for (const object of objects) {
const proto = Object.getPrototypeOf(object);
const plainObject = {};
Object.setPrototypeOf(object, plainObject);
assert_equals(Object.getPrototypeOf(object), plainObject);
Object.setPrototypeOf(object, proto);
}
}, "Setting to a different prototype");

test(() => {
for (const object of objects) {
const expected = Object.getPrototypeOf(object);
Object.setPrototypeOf(object, expected);
assert_equals(Object.getPrototypeOf(object), expected);
}
}, "Setting to the same prototype");

0 comments on commit b8bca44

Please sign in to comment.