зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1842701 - Part 5: Add tests for devtools. r=nchevobbe,devtools-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D184328
This commit is contained in:
Родитель
dd02d84fff
Коммит
c2fa29e8f5
|
@ -66,3 +66,78 @@ add_task(async function () {
|
|||
|
||||
await resume(dbg);
|
||||
});
|
||||
|
||||
add_task(async function () {
|
||||
// Test the behavior when the variables are declared in the script.
|
||||
|
||||
const hud = await openNewTabAndConsole("data:text/html,Nothing");
|
||||
|
||||
let message = await executeAndWaitForResultMessage(
|
||||
hud,
|
||||
"var $ = 'var_$'; $",
|
||||
"var_$"
|
||||
);
|
||||
ok(message, "$ was not overridden");
|
||||
|
||||
message = await executeAndWaitForResultMessage(
|
||||
hud,
|
||||
"const $$ = 'const_$$'; $$",
|
||||
"const_$$"
|
||||
);
|
||||
ok(message, "$$ was not overridden");
|
||||
|
||||
message = await executeAndWaitForResultMessage(
|
||||
hud,
|
||||
"function keys() { return 'function_keys'; } keys()",
|
||||
"function_keys"
|
||||
);
|
||||
ok(message, "keys was not overridden");
|
||||
|
||||
// Hoisted variable.
|
||||
message = await executeAndWaitForResultMessage(
|
||||
hud,
|
||||
"{ var clear = 'var_clear'; } clear",
|
||||
"var_clear"
|
||||
);
|
||||
ok(message, "clear was not overridden");
|
||||
|
||||
// Hoisted function.
|
||||
message = await executeAndWaitForResultMessage(
|
||||
hud,
|
||||
"{ function help() { return 'function_help'; } } help()",
|
||||
"function_help"
|
||||
);
|
||||
ok(message, "help was not overridden");
|
||||
|
||||
// Lexical variables are not hoisted.
|
||||
message = await executeAndWaitForResultMessage(
|
||||
hud,
|
||||
"{ let values = 'let_values'; } typeof values",
|
||||
"function"
|
||||
);
|
||||
ok(message, "values was not overridden because it's not global");
|
||||
});
|
||||
|
||||
add_task(async function () {
|
||||
// NOTE: Open a new page to use the same binding name again.
|
||||
|
||||
const hud = await openNewTabAndConsole("data:text/html,Nothing");
|
||||
|
||||
// An assignment on `globalThis` property inside the script doesn't shadow
|
||||
// the helper binding.
|
||||
let message = await executeAndWaitForResultMessage(
|
||||
hud,
|
||||
"globalThis.values = 'globalThis_values'; typeof values",
|
||||
"function"
|
||||
);
|
||||
ok(message, "values was overridden because it's not declaration");
|
||||
|
||||
// Executing `values` again shadows the helper binding, given it exists
|
||||
// before the execution.
|
||||
message = await executeAndWaitForResultMessage(
|
||||
hud,
|
||||
"values",
|
||||
"globalThis_values"
|
||||
);
|
||||
ok(message, "values was not overridden if it exists before the execution");
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче