diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/webconsole/test/browser/browser_jsterm_commands.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/webconsole/test/browser/browser_jsterm_commands.js')
-rw-r--r-- | devtools/client/webconsole/test/browser/browser_jsterm_commands.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/devtools/client/webconsole/test/browser/browser_jsterm_commands.js b/devtools/client/webconsole/test/browser/browser_jsterm_commands.js new file mode 100644 index 0000000000..7ff80228fe --- /dev/null +++ b/devtools/client/webconsole/test/browser/browser_jsterm_commands.js @@ -0,0 +1,67 @@ +"use strict"; + +const TEST_URI = "data:text/html,test-page"; + +const { + HELP_URL, +} = require("resource://devtools/client/webconsole/constants.js"); + +add_task(async function () { + const hud = await openNewTabAndConsole(TEST_URI); + + info("Trigger the :help command"); + // Hook the browser method in order to prevent the URL from opening + // as mochitest forbids opening remote URLs. + const onUrlOpened = new Promise(resolve => { + const originalMethod = window.openWebLinkIn; + window.openWebLinkIn = url => { + window.openWebLinkIn = originalMethod; + resolve(url); + }; + }); + execute(hud, ":help"); + info("Wait for the help URL to be requested to open"); + const url = await onUrlOpened; + is(url, HELP_URL, "Expected url was opened when executing :help"); + + info("Execute only ':'"); + await executeAndWaitForMessageByType( + hud, + ":", + "Missing a command name after ':'", + ".console-api.error" + ); + + // Any space after a `:` would lead to the same exception + info("Execute only ': '"); + await executeAndWaitForMessageByType( + hud, + ": ", + "Missing a command name after ':'", + ".console-api.error" + ); + + info("Execute only ': foo'"); + await executeAndWaitForMessageByType( + hud, + ": foo", + "Missing a command name after ':'", + ".console-api.error" + ); + + info("Execute unsupported command ':bar'"); + await executeAndWaitForMessageByType( + hud, + ":bar", + "bar' is not a valid command", + ".console-api.error" + ); + + info("Execute string with two commands"); + await executeAndWaitForMessageByType( + hud, + ":help :help", + "Executing multiple commands in one evaluation is not supported", + ".console-api.error" + ); +}); |