[PATCH v4 6/6] mshtml/tests: Add a test for JS functions scope.
Paul Gofman
pgofman at codeweavers.com
Thu Jun 17 16:25:23 CDT 2021
Patch by Jacek Caban.
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
dlls/mshtml/tests/es5.js | 56 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js
index dd6ea76c77a..1915a743f56 100644
--- a/dlls/mshtml/tests/es5.js
+++ b/dlls/mshtml/tests/es5.js
@@ -1341,3 +1341,59 @@ sync_test("let scope instances", function() {
ok(f() == 2, "f() = " + f());
});
+
+sync_test("functions scope", function() {
+ function f(){ return 1; }
+ function f(){ return 2; }
+
+ var f0 = f, f1, f2, f3, i, o, a = [];
+ ok(f0() === 2, "f0() = " + f0());
+
+ {
+ f1 = f;
+ function f() { return 3; }
+ ok(f1 === f, "f1 != f");
+ ok(f0 != f1, "f0 == f1");
+ }
+ ok(f === f1, "f != f1");
+
+ for(i = 0; i < 3; i++) {
+ a[i] = f;
+ function f() {}
+ ok(f === a[i], "f != a[i]");
+ }
+ ok(a[0] != a[1], "a[0] == a[1]");
+ ok(a[1] != a[2], "a[1] == a[2]");
+ ok(f === a[2], "f != a[2]");
+
+ {
+ f2 = f;
+ ok(f() === 4, "f() = " + f());
+ function f() { return 4; }
+
+ {
+ f3 = f;
+ ok(f() === 5, "f() = " + f());
+ function f() { return 5;}
+ }
+ ok(f() === 4, "f() = " + f());
+ ok(f === f2, "f != f2");
+ }
+ ok(f === f3, "f != f3");
+
+ with(o = {f: 1}) {
+ ok(f === 1, "f != 1");
+ {
+ ok(f() === 6, "f() = " + f());
+ function f() { return 6; }
+ }
+ ok(f === 1, "f != 1");
+ delete o.f;
+ ok(f() === 6, "f() = " + f());
+ }
+
+ if(false) {
+ function f() { throw "unexpected call"; }
+ }
+ ok(f() === 6, "f() = " + f());
+});
--
2.31.1
More information about the wine-devel
mailing list