mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-25 19:51:59 +00:00
LibJS: Throw in strict mode when assigning property to primitive value
This commit is contained in:
parent
5f2632f121
commit
8ff4587f65
Notes:
sideshowbarker
2024-07-19 06:01:27 +09:00
Author: https://github.com/linusg
Commit: 8ff4587f65
Pull-request: https://github.com/SerenityOS/serenity/pull/2429
3 changed files with 25 additions and 5 deletions
18
Libraries/LibJS/Tests/strict-mode-errors.js
Normal file
18
Libraries/LibJS/Tests/strict-mode-errors.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
"use strict";
|
||||
|
||||
load("test-common.js")
|
||||
|
||||
try {
|
||||
[true, false, "foo", 123].forEach(primitive => {
|
||||
assertThrowsError(() => {
|
||||
primitive.foo = "bar";
|
||||
}, {
|
||||
error: TypeError,
|
||||
message: "Can't assign property foo to primitive value"
|
||||
});
|
||||
});
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue