summaryrefslogtreecommitdiffstats
path: root/devtools/shared/commands/script/tests/browser_script_command_execute_basic.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/shared/commands/script/tests/browser_script_command_execute_basic.js')
-rw-r--r--devtools/shared/commands/script/tests/browser_script_command_execute_basic.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/devtools/shared/commands/script/tests/browser_script_command_execute_basic.js b/devtools/shared/commands/script/tests/browser_script_command_execute_basic.js
index e63f55a338..f5efa6ac30 100644
--- a/devtools/shared/commands/script/tests/browser_script_command_execute_basic.js
+++ b/devtools/shared/commands/script/tests/browser_script_command_execute_basic.js
@@ -75,6 +75,11 @@ add_task(async () => {
function testFunc() {}
var testLocale = new Intl.Locale("de-latn-de-u-ca-gregory-co-phonebk-hc-h23-kf-true-kn-false-nu-latn");
+
+ var testFormData = new FormData();
+ var testHeaders = new Headers();
+ var testURLSearchParams = new URLSearchParams();
+ var testReadableStream = new ReadableStream();
</script>
<body id="body1" class="class2"><h1>Body text</h1></body>
</html>`);
@@ -97,6 +102,7 @@ add_task(async () => {
await doEagerEvalESGetters(commands);
await doEagerEvalDOMGetters(commands);
await doEagerEvalOtherNativeGetters(commands);
+ await doEagerEvalDOMMethods(commands);
await doEagerEvalAsyncFunctions(commands);
await commands.destroy();
@@ -1001,6 +1007,53 @@ async function doEagerEvalOtherNativeGetters(commands) {
}
}
+async function doEagerEvalDOMMethods(commands) {
+ // The following "values" methods share single native function with different
+ // JitInfo, while ReadableStream's "values" isn't side-effect free.
+
+ const testDataAllowed = [
+ [`testFormData.values().constructor.name`, "Object"],
+ [`testHeaders.values().constructor.name`, "Object"],
+ [`testURLSearchParams.values().constructor.name`, "Object"],
+ ];
+
+ for (const [code, expectedResult] of testDataAllowed) {
+ const response = await commands.scriptCommand.execute(code, {
+ eager: true,
+ });
+ checkObject(
+ response,
+ {
+ input: code,
+ result: expectedResult,
+ },
+ code
+ );
+
+ ok(!response.exception, "no eval exception");
+ ok(!response.helperResult, "no helper result");
+ }
+
+ const testDataDisallowed = ["testReadableStream.values()"];
+
+ for (const code of testDataDisallowed) {
+ const response = await commands.scriptCommand.execute(code, {
+ eager: true,
+ });
+ checkObject(
+ response,
+ {
+ input: code,
+ result: { type: "undefined" },
+ },
+ code
+ );
+
+ ok(!response.exception, "no eval exception");
+ ok(!response.helperResult, "no helper result");
+ }
+}
+
async function doEagerEvalAsyncFunctions(commands) {
// [code, expectedResult]
const testData = [["typeof testAsync()", "object"]];