mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +00:00
LibJS: Throw TypeError on write to non-writable property in strict mode
This commit is contained in:
parent
31534055e4
commit
2a8f4f097c
Notes:
sideshowbarker
2024-07-18 15:40:57 +09:00
Author: https://github.com/IdanHo
Commit: 2a8f4f097c
Pull-request: https://github.com/SerenityOS/serenity/pull/7825
Reviewed-by: https://github.com/linusg
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