Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /webidl/ecmascript-binding/global-immutable-prototype.any.html - WPT Dashboard Interop Dashboard
- /webidl/ecmascript-binding/global-immutable-prototype.any.serviceworker.html - WPT Dashboard Interop Dashboard
- /webidl/ecmascript-binding/global-immutable-prototype.any.sharedworker.html - WPT Dashboard Interop Dashboard
- /webidl/ecmascript-binding/global-immutable-prototype.any.worker.html - WPT Dashboard Interop Dashboard
// META: global=window,worker
// META: title=Immutability 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) {
assert_throws_js(TypeError, () => {
Object.setPrototypeOf(object, {});
});
}
}, "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");