mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
LibJS: Throw TypeError on write to non-writable property in strict mode
This commit is contained in:
parent
31534055e4
commit
2a8f4f097c
3 changed files with 15 additions and 0 deletions
12
Userland/Libraries/LibJS/Tests/non-writable-assignment.js
Normal file
12
Userland/Libraries/LibJS/Tests/non-writable-assignment.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
test("normal mode", () => {
|
||||
expect(() => {
|
||||
NaN = 5; // NaN is a non-writable global variable
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
test("strict mode", () => {
|
||||
expect(() => {
|
||||
"use strict";
|
||||
NaN = 5; // NaN is a non-writable global variable
|
||||
}).toThrowWithMessage(TypeError, "Cannot write to non-writable property 'NaN'");
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue