summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/decorators/decorator-this.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/decorators/decorator-this.js')
-rw-r--r--js/src/jit-test/tests/decorators/decorator-this.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/decorators/decorator-this.js b/js/src/jit-test/tests/decorators/decorator-this.js
new file mode 100644
index 0000000000..b545729ca4
--- /dev/null
+++ b/js/src/jit-test/tests/decorators/decorator-this.js
@@ -0,0 +1,36 @@
+// |jit-test| skip-if: !getBuildConfiguration("decorators")
+
+load(libdir + "asserts.js");
+
+let globalDecCalled = false;
+function globalDec(value, context) {
+ globalDecCalled = true;
+ assertEq(this, globalThis);
+}
+
+// Forward declare c to be able to check it inside of C when running decorators.
+let c;
+let classDecCalled = false;
+class C {
+ classDec(value, context) {
+ classDecCalled = true;
+ // At this point, `this` is an instance of C
+ assertEq(c, this);
+ return function(initialValue) {
+ // At this point, `this` is an instance of D
+ assertEq(this instanceof D, true);
+ return initialValue;
+ }
+ }
+}
+
+c = new C();
+
+class D {
+ @globalDec x1;
+ @c.classDec x2;
+}
+
+let d = new D();
+assertEq(globalDecCalled, true);
+assertEq(classDecCalled, true);