From 4a49c8412c6742f37edb429047429c6d85d4f0af Mon Sep 17 00:00:00 2001 From: Jack Karamanian Date: Sat, 30 May 2020 01:11:44 -0500 Subject: [PATCH] LibJS: Add tests ensuring the |this| value can't be set for arrow functions in Function.prototype.{call,apply} --- Libraries/LibJS/Tests/Function.prototype.apply.js | 2 ++ Libraries/LibJS/Tests/Function.prototype.call.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Libraries/LibJS/Tests/Function.prototype.apply.js b/Libraries/LibJS/Tests/Function.prototype.apply.js index f3e20d3fb2..54451e3446 100644 --- a/Libraries/LibJS/Tests/Function.prototype.apply.js +++ b/Libraries/LibJS/Tests/Function.prototype.apply.js @@ -47,6 +47,8 @@ try { var multiply = function (x, y) { return x * y; }; assert(multiply.apply(null, [3, 4]) === 12); + assert((() => this).apply("foo") === globalThis); + console.log("PASS"); } catch (e) { console.log("FAIL: " + e); diff --git a/Libraries/LibJS/Tests/Function.prototype.call.js b/Libraries/LibJS/Tests/Function.prototype.call.js index 29eb153ea5..485e4645c2 100644 --- a/Libraries/LibJS/Tests/Function.prototype.call.js +++ b/Libraries/LibJS/Tests/Function.prototype.call.js @@ -47,6 +47,8 @@ try { var multiply = function (x, y) { return x * y; }; assert(multiply.call(null, 3, 4) === 12); + assert((() => this).call("foo") === globalThis); + console.log("PASS"); } catch (e) { console.log("FAIL: " + e);