mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +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,143 @@
|
|||
// Note: This must be checked at script level because that is the only place
|
||||
// where function order is visible. We introduce some test(...) with
|
||||
// names to make sure the file does have some tests and a suite.
|
||||
|
||||
const evalViaArrow = x => eval(x);
|
||||
const evalRef = eval;
|
||||
const expectedBeforeEval = "1256MNQR3478CDHIOP";
|
||||
const expectedAfterEval = "1256MNQR3478CDHIOPA9B";
|
||||
const expectedAfterEvalRef = "1256MNQR3478CDHIOPA9BKJL";
|
||||
const expectOrderToBe = expectedOrder => {
|
||||
const currentOrder = Object.getOwnPropertyNames(this)
|
||||
.filter(s => s.length === 2 && s[0] === "f")
|
||||
.map(s => s[1])
|
||||
.join("");
|
||||
expect(currentOrder).toBe(expectedOrder);
|
||||
};
|
||||
|
||||
test("function order should be in tree order and nothing in eval should be included", () => {
|
||||
expectOrderToBe(expectedBeforeEval);
|
||||
});
|
||||
|
||||
{
|
||||
function f1() {}
|
||||
|
||||
expectOrderToBe(expectedBeforeEval);
|
||||
|
||||
function f2() {}
|
||||
}
|
||||
|
||||
expectOrderToBe(expectedBeforeEval);
|
||||
|
||||
function f3() {}
|
||||
|
||||
expectOrderToBe(expectedBeforeEval);
|
||||
|
||||
function f4() {}
|
||||
|
||||
expectOrderToBe(expectedBeforeEval);
|
||||
|
||||
{
|
||||
function f5() {}
|
||||
|
||||
function f6() {}
|
||||
}
|
||||
|
||||
function f7() {}
|
||||
|
||||
function f8() {}
|
||||
|
||||
expectOrderToBe(expectedBeforeEval);
|
||||
eval(`
|
||||
expectOrderToBe(expectedAfterEval);
|
||||
|
||||
function f9() {}
|
||||
|
||||
{
|
||||
function fA() {}
|
||||
}
|
||||
|
||||
function fB() {}
|
||||
|
||||
expectOrderToBe(expectedAfterEval);
|
||||
`);
|
||||
|
||||
expectOrderToBe(expectedAfterEval);
|
||||
|
||||
function fC() {}
|
||||
|
||||
function fD() {}
|
||||
|
||||
expectOrderToBe(expectedAfterEval);
|
||||
|
||||
// This eval does not do anything because it goes via a function, this means
|
||||
// its parent environment is not the global environment so it does not have
|
||||
// a global var environment and does not put the functions on `this`.
|
||||
evalViaArrow(`
|
||||
expectOrderToBe(expectedAfterEval);
|
||||
|
||||
function fE() {}
|
||||
|
||||
{
|
||||
expectOrderToBe(expectedAfterEval);
|
||||
function fF() {}
|
||||
}
|
||||
|
||||
function fG() {}
|
||||
|
||||
expectOrderToBe(expectedAfterEval);
|
||||
`);
|
||||
|
||||
test("function order should be in tree order, functions in eval should be in order but at the back", () => {
|
||||
expectOrderToBe(expectedAfterEval);
|
||||
});
|
||||
|
||||
function fH() {}
|
||||
|
||||
function fI() {}
|
||||
|
||||
expectOrderToBe(expectedAfterEval);
|
||||
|
||||
// This is an indirect eval, but still has the global scope as immediate
|
||||
// parent so it does influence the global `this`.
|
||||
evalRef(`
|
||||
expectOrderToBe(expectedAfterEvalRef);
|
||||
console.log(2, JSON.stringify(Object.getOwnPropertyNames(this).filter(s => s.length === 2)));
|
||||
|
||||
function fJ() {}
|
||||
|
||||
{
|
||||
expectOrderToBe(expectedAfterEvalRef);
|
||||
function fK() {}
|
||||
}
|
||||
|
||||
function fL() {}
|
||||
|
||||
expectOrderToBe(expectedAfterEvalRef);
|
||||
`);
|
||||
|
||||
{
|
||||
function fM() {}
|
||||
|
||||
function fN() {}
|
||||
}
|
||||
|
||||
test("function order should be in tree order, functions in evalRef should be in order but at the back", () => {
|
||||
expectOrderToBe(expectedAfterEvalRef);
|
||||
});
|
||||
|
||||
function fO() {}
|
||||
|
||||
function fP() {}
|
||||
|
||||
{
|
||||
function fQ() {}
|
||||
|
||||
{
|
||||
expectOrderToBe(expectedAfterEvalRef);
|
||||
}
|
||||
|
||||
function fR() {}
|
||||
}
|
||||
|
||||
expectOrderToBe(expectedAfterEvalRef);
|
Loading…
Add table
Add a link
Reference in a new issue