Bug 1472673 - fix windows screenshot file test, add more console screenshot command tests; r=nchevobbe
MozReview-Commit-ID: 7P4l5PNjYwV
--- a/devtools/client/webconsole/components/JSTerm.js
+++ b/devtools/client/webconsole/components/JSTerm.js
@@ -396,17 +396,17 @@ class JSTerm extends Component {
type: "inspectObject",
object: objectActor
}
}, true);
return this.hud.consoleOutput;
}
screenshotNotify(results) {
- const wrappedResults = results.map(result => ({ result }));
+ const wrappedResults = results.map(message => ({ message, type: "logMessage" }));
this.hud.consoleOutput.dispatchMessagesAdd(wrappedResults);
}
/**
* Execute a string. Execution happens asynchronously in the content process.
*
* @param string [executeString]
* The string you want to execute. If this is not provided, the current
--- a/devtools/client/webconsole/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/test/mochitest/browser.ini
@@ -224,18 +224,19 @@ skip-if = os != 'mac' # The tested ctrl+
[browser_jsterm_instance_of.js]
[browser_jsterm_multiline.js]
[browser_jsterm_no_autocompletion_on_defined_variables.js]
[browser_jsterm_no_input_and_tab_key_pressed.js]
[browser_jsterm_null_undefined.js]
[browser_jsterm_popup_close_on_tab_switch.js]
[browser_jsterm_screenshot_command_clipboard.js]
subsuite = clipboard
+[browser_jsterm_screenshot_command_user.js]
+subsuite = clipboard
[browser_jsterm_screenshot_command_file.js]
-skip-if = (os == 'win') # Bug 1464461, disabled on Win due to timeouts
[browser_jsterm_selfxss.js]
subsuite = clipboard
[browser_webconsole_allow_mixedcontent_securityerrors.js]
tags = mcb
[browser_webconsole_batching.js]
[browser_webconsole_block_mixedcontent_securityerrors.js]
tags = mcb
[browser_webconsole_cached_messages.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/test/mochitest/browser_jsterm_screenshot_command_user.js
@@ -0,0 +1,40 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Test that screenshot command works properly
+
+"use strict";
+
+const TEST_URI = `data:text/html,<meta charset=utf8><script>
+ function screenshot() {
+ console.log(\"screen\");
+ }
+</script>`;
+
+add_task(async function() {
+ await addTab(TEST_URI);
+
+ const hud = await openConsole();
+ ok(hud, "web console opened");
+
+ await testCommand(hud);
+ await testUserScreenshotFunction(hud);
+});
+
+async function testCommand(hud) {
+ const command = `:screenshot --clipboard`;
+ const onMessage = waitForMessage(hud, "Screenshot copied to clipboard.");
+ hud.jsterm.execute(command);
+ await onMessage;
+ ok(true, ":screenshot was executed as expected");
+}
+
+// if a user defines a screenshot, as is the case in the Test URI, the
+// command should not overwrite the screenshot function
+async function testUserScreenshotFunction(hud) {
+ const command = `screenshot()`;
+ const onMessage = waitForMessage(hud, "screen");
+ hud.jsterm.execute(command);
+ await onMessage;
+ ok(true, "content screenshot function is not overidden and was executed as expected");
+}