mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
|
@ -0,0 +1,76 @@
|
|||
describe("[[Construct]] trap normal behavior", () => {
|
||||
test("forwarding when not defined in handler", () => {
|
||||
let p = new Proxy(
|
||||
function () {
|
||||
this.x = 5;
|
||||
},
|
||||
{ construct: null }
|
||||
);
|
||||
expect(new p().x).toBe(5);
|
||||
p = new Proxy(
|
||||
function () {
|
||||
this.x = 5;
|
||||
},
|
||||
{ construct: undefined }
|
||||
);
|
||||
expect(new p().x).toBe(5);
|
||||
p = new Proxy(function () {
|
||||
this.x = 5;
|
||||
}, {});
|
||||
expect(new p().x).toBe(5);
|
||||
});
|
||||
|
||||
test("trapping 'new'", () => {
|
||||
function f(value) {
|
||||
this.x = value;
|
||||
}
|
||||
|
||||
let p;
|
||||
const handler = {
|
||||
construct(target, arguments_, newTarget) {
|
||||
expect(target).toBe(f);
|
||||
expect(newTarget).toBe(p);
|
||||
if (arguments_[1]) {
|
||||
return Reflect.construct(target, [arguments_[0] * 2], newTarget);
|
||||
}
|
||||
return Reflect.construct(target, arguments_, newTarget);
|
||||
},
|
||||
};
|
||||
p = new Proxy(f, handler);
|
||||
|
||||
expect(new p(15).x).toBe(15);
|
||||
expect(new p(15, true).x).toBe(30);
|
||||
});
|
||||
|
||||
test("trapping Reflect.construct", () => {
|
||||
function f(value) {
|
||||
this.x = value;
|
||||
}
|
||||
|
||||
let p;
|
||||
function theNewTarget() {}
|
||||
const handler = {
|
||||
construct(target, arguments_, newTarget) {
|
||||
expect(target).toBe(f);
|
||||
expect(newTarget).toBe(theNewTarget);
|
||||
if (arguments_[1]) {
|
||||
return Reflect.construct(target, [arguments_[0] * 2], newTarget);
|
||||
}
|
||||
return Reflect.construct(target, arguments_, newTarget);
|
||||
},
|
||||
};
|
||||
p = new Proxy(f, handler);
|
||||
|
||||
Reflect.construct(p, [15], theNewTarget);
|
||||
});
|
||||
});
|
||||
|
||||
describe("[[Construct]] invariants", () => {
|
||||
test("target must have a [[Construct]] slot", () => {
|
||||
[{}, [], new Proxy({}, {})].forEach(item => {
|
||||
expect(() => {
|
||||
new new Proxy(item, {})();
|
||||
}).toThrowWithMessage(TypeError, "[object ProxyObject] is not a constructor");
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue