Bug 1408940 - enable browser_webconsole_history_nav.js;r=nchevobbe draft
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 01 Dec 2017 17:19:41 +0100
changeset 706799 fc669c69d30819d5a4950c5106efdd9e74112f23
parent 706798 7d4f77aecd6ae0c3643e962b955b22d9ab7838da
child 706925 c8e3541dcf68da377c472d817f710e2c84823789
push id91934
push userjdescottes@mozilla.com
push dateMon, 04 Dec 2017 10:12:44 +0000
reviewersnchevobbe
bugs1408940
milestone59.0a1
Bug 1408940 - enable browser_webconsole_history_nav.js;r=nchevobbe MozReview-Commit-ID: LCLeM9cj7TX
devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_nav.js
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_history_nav.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -210,16 +210,17 @@ skip-if = true #	Bug 1403188
 [browser_jsterm_autocomplete_return_key_no_selection.js]
 [browser_jsterm_autocomplete_return_key.js]
 [browser_jsterm_autocomplete-properties-with-non-alphanumeric-names.js]
 [browser_jsterm_completion.js]
 [browser_jsterm_copy_command.js]
 [browser_jsterm_dollar.js]
 [browser_jsterm_history.js]
 [browser_jsterm_history_persist.js]
+[browser_jsterm_history_nav.js]
 [browser_jsterm_inspect.js]
 [browser_jsterm_multiline.js]
 [browser_jsterm_no_autocompletion_on_defined_variables.js]
 [browser_jsterm_no_input_and_tab_key_pressed.js]
 [browser_jsterm_no_input_change_and_tab_key_pressed.js]
 [browser_jsterm_popup_close_on_tab_switch.js]
 [browser_jsterm_popup.js]
 [browser_jsterm_selfxss.js]
@@ -287,18 +288,16 @@ skip-if = true #	Bug 1404382
 skip-if = true #	Bug 1404392
 [browser_webconsole_filters.js]
 [browser_webconsole_filters_persist.js]
 [browser_webconsole_highlighter_console_helper.js]
 skip-if = true #	Bug 1404853
 # old console skip-if = true # Requires direct access to content nodes
 [browser_webconsole_history_arrow_keys.js]
 skip-if = true # Bug 1408939
-[browser_webconsole_history_nav.js]
-skip-if = true # Bug 1408940
 [browser_webconsole_hpkp_invalid-headers.js]
 skip-if = true #	Bug 1405340
 # old console skip-if = (os == 'win' && bits == 64) # Bug 1390001
 [browser_webconsole_hsts_invalid-headers.js]
 skip-if = true #	Bug 1405341
 # old console skip-if = e10s # Bug 1042253 - webconsole e10s tests
 [browser_webconsole_iframe_wrong_hud.js]
 skip-if = true #	Bug 1404378
rename from devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_history_nav.js
rename to devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_nav.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_history_nav.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_nav.js
@@ -1,33 +1,26 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
-// See Bug 660806.
+// See Bug 660806. Check that history navigation with the UP/DOWN arrows does not trigger
+// autocompletion.
 
 const TEST_URI = "data:text/html;charset=utf-8,<p>bug 660806 - history " +
                  "navigation must not show the autocomplete popup";
 
-add_task(function* () {
-  yield loadTab(TEST_URI);
-
-  let hud = yield openConsole();
+add_task(async function () {
+  let { jsterm } = await openNewTabAndConsole(TEST_URI);
+  let popup = jsterm.autocompletePopup;
 
-  yield consoleOpened(hud);
-});
-
-function consoleOpened(HUD) {
-  let deferred = defer();
-
-  let jsterm = HUD.jsterm;
-  let popup = jsterm.autocompletePopup;
+  // The autocomplete popup should never be displayed during the test.
   let onShown = function () {
     ok(false, "popup shown");
   };
 
   jsterm.execute(`window.foobarBug660806 = {
     'location': 'value0',
     'locationbar': 'value1'
   }`);
@@ -37,20 +30,23 @@ function consoleOpened(HUD) {
   ok(!popup.isOpen, "popup is not open");
 
   ok(!jsterm.lastInputValue, "no lastInputValue");
   jsterm.setInputValue("window.foobarBug660806.location");
   is(jsterm.lastInputValue, "window.foobarBug660806.location",
      "lastInputValue is correct");
 
   EventUtils.synthesizeKey("VK_RETURN", {});
+
+  let onSetInputValue = jsterm.once("set-input-value");
   EventUtils.synthesizeKey("VK_UP", {});
+  await onSetInputValue;
+
+  // We don't have an explicit event to wait for here, so we just wait for the next tick
+  // before checking the popup status.
+  await new Promise(executeSoon);
 
   is(jsterm.lastInputValue, "window.foobarBug660806.location",
      "lastInputValue is correct, again");
 
-  executeSoon(function () {
-    ok(!popup.isOpen, "popup is not open");
-    popup.off("popup-opened", onShown);
-    executeSoon(deferred.resolve);
-  });
-  return deferred.promise;
-}
+  ok(!popup.isOpen, "popup is not open");
+  popup.off("popup-opened", onShown);
+});