mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
LibJS: Disallow escape sequence/line continuation in use strict directive
https://tc39.es/ecma262/#sec-directive-prologues-and-the-use-strict-directive A Use Strict Directive is an ExpressionStatement in a Directive Prologue whose StringLiteral is either of the exact code point sequences "use strict" or 'use strict'. A Use Strict Directive may not contain an EscapeSequence or LineContinuation.
This commit is contained in:
parent
4fb96afafc
commit
2adcabb6b3
Notes:
sideshowbarker
2024-07-19 01:46:26 +09:00
Author: https://github.com/linusg
Commit: 2adcabb6b3
Pull-request: https://github.com/SerenityOS/serenity/pull/3834
2 changed files with 53 additions and 4 deletions
48
Libraries/LibJS/Tests/use-strict-directive.js
Normal file
48
Libraries/LibJS/Tests/use-strict-directive.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
test("valid 'use strict; directive", () => {
|
||||
expect(
|
||||
(() => {
|
||||
"use strict";
|
||||
return isStrictMode();
|
||||
})()
|
||||
).toBeTrue();
|
||||
expect(
|
||||
(() => {
|
||||
'use strict';
|
||||
return isStrictMode();
|
||||
})()
|
||||
).toBeTrue();
|
||||
});
|
||||
|
||||
test("invalid 'use strict; directive", () => {
|
||||
expect(
|
||||
(() => {
|
||||
" use strict ";
|
||||
return isStrictMode();
|
||||
})()
|
||||
).toBeFalse();
|
||||
expect(
|
||||
(() => {
|
||||
`use strict`;
|
||||
return isStrictMode();
|
||||
})()
|
||||
).toBeFalse();
|
||||
expect(
|
||||
(() => {
|
||||
"use\
|
||||
strict";
|
||||
return isStrictMode();
|
||||
})()
|
||||
).toBeFalse();
|
||||
expect(
|
||||
(() => {
|
||||
"use\ strict";
|
||||
return isStrictMode();
|
||||
})()
|
||||
).toBeFalse();
|
||||
expect(
|
||||
(() => {
|
||||
"use \163trict";
|
||||
return isStrictMode();
|
||||
})()
|
||||
).toBeFalse();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue