1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:48:10 +00:00

LibJS: Fix functions binding this to global object in strict mode

This fixes an issue where this would be bound to the global object
by default when operating in strict mode.

According to the specification, the expected value for |this| when
no binding is provided is undefined.
This commit is contained in:
Ryan Chandler 2021-06-04 11:52:20 +01:00 committed by Linus Groh
parent 1b083392fa
commit c66b281856
2 changed files with 15 additions and 0 deletions

View file

@ -58,3 +58,12 @@ test('only the string "use strict" yields strict mode code', () => {
"use stric";
expect(isStrictMode()).toBeFalse();
});
test("strict mode does not apply global object to |this|", () => {
"use strict";
let functionThis;
(function () {
functionThis = this;
})();
expect(functionThis).toBeUndefined();
});