Browse Source

LibJS: Add tests ensuring the |this| value can't be set for arrow
functions in Function.prototype.{call,apply}

Jack Karamanian 5 years ago
parent
commit
4a49c8412c

+ 2 - 0
Libraries/LibJS/Tests/Function.prototype.apply.js

@@ -47,6 +47,8 @@ try {
     var multiply = function (x, y) { return x * y; };
     var multiply = function (x, y) { return x * y; };
     assert(multiply.apply(null, [3, 4]) === 12);
     assert(multiply.apply(null, [3, 4]) === 12);
 
 
+    assert((() => this).apply("foo") === globalThis);
+
     console.log("PASS");
     console.log("PASS");
 } catch (e) {
 } catch (e) {
     console.log("FAIL: " + e);
     console.log("FAIL: " + e);

+ 2 - 0
Libraries/LibJS/Tests/Function.prototype.call.js

@@ -47,6 +47,8 @@ try {
     var multiply = function (x, y) { return x * y; };
     var multiply = function (x, y) { return x * y; };
     assert(multiply.call(null, 3, 4) === 12);
     assert(multiply.call(null, 3, 4) === 12);
 
 
+    assert((() => this).call("foo") === globalThis);
+
     console.log("PASS");
     console.log("PASS");
 } catch (e) {
 } catch (e) {
     console.log("FAIL: " + e);
     console.log("FAIL: " + e);