mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibJS: Throw TypeError on write to non-writable property in strict mode
This commit is contained in:
committed by
Linus Groh
parent
31534055e4
commit
2a8f4f097c
Notes:
sideshowbarker
2024-07-18 15:40:57 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/2a8f4f097c3 Pull-request: https://github.com/SerenityOS/serenity/pull/7825 Reviewed-by: https://github.com/linusg
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'");
|
||||
});
|
||||
Reference in New Issue
Block a user