Bug 1482875 - Add test for middle-click pasting in console input; r=Honza.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Fri, 18 Jan 2019 14:19:56 +0000
changeset 514435 bf190444c5793c7fca517d5893b12f4e2d50efd2
parent 514434 9915f978e03beef3b5da8d0aa870e8b28394f73c
child 514436 c586ab9cae6d139d5ce403b56f980be711e8c73c
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1482875
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1482875 - Add test for middle-click pasting in console input; r=Honza. Differential Revision: https://phabricator.services.mozilla.com/D16793
devtools/client/webconsole/test/mochitest/browser.ini
devtools/client/webconsole/test/mochitest/browser_jsterm_middle_click_paste.js
--- a/devtools/client/webconsole/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/test/mochitest/browser.ini
@@ -242,16 +242,18 @@ skip-if = os != 'mac' # The tested ctrl+
 [browser_jsterm_helper_pprint.js]
 [browser_jsterm_hide_when_devtools_chrome_enabled_false.js]
 [browser_jsterm_history.js]
 [browser_jsterm_history_arrow_keys.js]
 [browser_jsterm_history_nav.js]
 [browser_jsterm_history_persist.js]
 [browser_jsterm_inspect.js]
 [browser_jsterm_instance_of.js]
+[browser_jsterm_middle_click_paste.js]
+subsuite = clipboard
 [browser_jsterm_multiline.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
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/test/mochitest/browser_jsterm_middle_click_paste.js
@@ -0,0 +1,42 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Test that pasting clipboard content into input with middle-click works.
+
+"use strict";
+
+const TEST_URI = `data:text/html;charset=utf-8,Web Console test paste on middle-click`;
+
+add_task(async function() {
+  // Enable pasting with middle-click.
+  await pushPref("middlemouse.paste", true);
+
+  // Run test with legacy JsTerm
+  await pushPref("devtools.webconsole.jsterm.codeMirror", false);
+  await performTests();
+  // And then run it with the CodeMirror-powered one.
+  await pushPref("devtools.webconsole.jsterm.codeMirror", true);
+  await performTests();
+});
+
+async function performTests() {
+  const hud = await openNewTabAndConsole(TEST_URI);
+  const {jsterm} = hud;
+
+  info("Set clipboard content");
+  const clipboardContent = "test clipboard content";
+  setClipboardText(clipboardContent);
+
+  info("Middle-click on the console input");
+  const node = jsterm.node || jsterm.inputNode;
+
+  EventUtils.synthesizeMouse(node, 30, 10, {button: 1}, hud.iframeWindow);
+  is(jsterm.getInputValue(), clipboardContent,
+    "clipboard content was pasted in the console input");
+}
+
+function setClipboardText(text) {
+  const helper = SpecialPowers.Cc["@mozilla.org/widget/clipboardhelper;1"]
+    .getService(SpecialPowers.Ci.nsIClipboardHelper);
+  helper.copyString(text);
+}