mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibJS: Use correct this value for tagged template literals with members
Required by creepjs, which does Date().split` `[3] to get the current year.
This commit is contained in:
parent
5f33383a7b
commit
a588756105
Notes:
github-actions[bot]
2025-01-17 16:16:08 +00:00
Author: https://github.com/Lubrsi
Commit: a588756105
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3277
2 changed files with 119 additions and 3 deletions
|
@ -164,7 +164,7 @@ describe("tagged template literal functionality", () => {
|
|||
expect(firstResult).toBe(secondResult);
|
||||
});
|
||||
|
||||
test.xfail("this value of call comes from reference", () => {
|
||||
test("this value of call comes from reference for non-computed, non-super property", () => {
|
||||
let thisValue = null;
|
||||
const obj = {
|
||||
func() {
|
||||
|
@ -176,4 +176,106 @@ describe("tagged template literal functionality", () => {
|
|||
|
||||
expect(thisValue).toBe(obj);
|
||||
});
|
||||
|
||||
test("this value of call comes from reference for computed, non-super property", () => {
|
||||
let thisValue = null;
|
||||
const obj = {
|
||||
func() {
|
||||
thisValue = this;
|
||||
},
|
||||
};
|
||||
|
||||
obj["func"]``;
|
||||
|
||||
expect(thisValue).toBe(obj);
|
||||
});
|
||||
|
||||
test("this value of call comes from reference for private property", () => {
|
||||
let thisValue = null;
|
||||
const obj = new (class A {
|
||||
#func = () => {
|
||||
thisValue = this;
|
||||
};
|
||||
|
||||
constructor() {
|
||||
this.#func``;
|
||||
}
|
||||
})();
|
||||
|
||||
expect(thisValue).toBe(obj);
|
||||
});
|
||||
|
||||
test("this value of call comes from reference for non-computed super call property", () => {
|
||||
let thisValue = null;
|
||||
|
||||
class A {
|
||||
func() {
|
||||
thisValue = this;
|
||||
}
|
||||
}
|
||||
|
||||
const obj = new (class B extends A {
|
||||
constructor() {
|
||||
super().func``;
|
||||
}
|
||||
})();
|
||||
|
||||
expect(thisValue).toBe(obj);
|
||||
});
|
||||
|
||||
test("this value of call comes from reference for computed super call property", () => {
|
||||
let thisValue = null;
|
||||
|
||||
class A {
|
||||
func() {
|
||||
thisValue = this;
|
||||
}
|
||||
}
|
||||
|
||||
const obj = new (class B extends A {
|
||||
constructor() {
|
||||
super()["func"]``;
|
||||
}
|
||||
})();
|
||||
|
||||
expect(thisValue).toBe(obj);
|
||||
});
|
||||
|
||||
test("this value of call comes from reference for non-computed super property", () => {
|
||||
let thisValue = null;
|
||||
|
||||
class A {
|
||||
func() {
|
||||
thisValue = this;
|
||||
}
|
||||
}
|
||||
|
||||
const obj = new (class B extends A {
|
||||
constructor() {
|
||||
super();
|
||||
super.func``;
|
||||
}
|
||||
})();
|
||||
|
||||
expect(thisValue).toBe(obj);
|
||||
});
|
||||
|
||||
test("this value of call comes from reference for computed super property", () => {
|
||||
let thisValue = null;
|
||||
|
||||
class A {
|
||||
func() {
|
||||
thisValue = this;
|
||||
}
|
||||
}
|
||||
|
||||
const obj = new (class B extends A {
|
||||
constructor() {
|
||||
super();
|
||||
super["func"]``;
|
||||
}
|
||||
})();
|
||||
|
||||
expect(thisValue).toBe(obj);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue