Bug 1405649 - enable browser_webconsole_split_persist.js;r=Honza draft
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 09 Feb 2018 19:40:59 +0100
changeset 755583 32e8c7808ccdc8730dc11729804bb6c03610e0eb
parent 755582 bf9d34dca74a5b7e843e5d0d4a28115f8b7232e0
push id99197
push userjdescottes@mozilla.com
push dateThu, 15 Feb 2018 14:01:32 +0000
reviewersHonza
bugs1405649
milestone60.0a1
Bug 1405649 - enable browser_webconsole_split_persist.js;r=Honza MozReview-Commit-ID: IISiwUya2x8
devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_split_persist.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -340,17 +340,16 @@ subsuite = clipboard
 [browser_webconsole_sourcemap_css.js]
 [browser_webconsole_sourcemap_error.js]
 [browser_webconsole_sourcemap_invalid.js]
 [browser_webconsole_sourcemap_nosource.js]
 [browser_webconsole_split.js]
 [browser_webconsole_split_escape_key.js]
 [browser_webconsole_split_focus.js]
 [browser_webconsole_split_persist.js]
-skip-if = true #	Bug 1405649
 [browser_webconsole_stacktrace_location_debugger_link.js]
 [browser_webconsole_stacktrace_location_scratchpad_link.js]
 [browser_webconsole_strict_mode_errors.js]
 [browser_webconsole_string.js]
 [browser_webconsole_time_methods.js]
 skip-if = true #	Bug 1404877
 [browser_webconsole_timestamps.js]
 [browser_webconsole_trackingprotection_errors.js]
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_split_persist.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_split_persist.js
@@ -1,117 +1,94 @@
 /* -*- 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";
-
- function test() {
-  info("Test that the split console state is persisted");
+"use strict";
 
-  let toolbox;
-  let TEST_URI = "data:text/html;charset=utf-8,<p>Web Console test for " +
-                 "splitting</p>";
+// Test that the split console state is persisted.
 
-  Task.spawn(runner).then(finish);
+const TEST_URI = "data:text/html;charset=utf-8,<p>Web Console test for splitting</p>";
 
-  function* runner() {
-    info("Opening a tab while there is no user setting on split console pref");
-    let {tab} = yield loadTab(TEST_URI);
-    let target = TargetFactory.forTab(tab);
-    toolbox = yield gDevTools.showToolbox(target, "inspector");
+add_task(async function () {
+  info("Opening a tab while there is no user setting on split console pref");
+  let toolbox = await openNewTabAndToolbox(TEST_URI, "inspector");
+  ok(!toolbox.splitConsole, "Split console is hidden by default");
+  ok(!isCommandButtonChecked(toolbox), "Split console button is unchecked by default.");
 
-    ok(!toolbox.splitConsole, "Split console is hidden by default.");
-    ok(!isCommandButtonChecked(), "Split console button is unchecked by " +
-                                  "default.");
-    yield toggleSplitConsoleWithEscape();
-    ok(toolbox.splitConsole, "Split console is now visible.");
-    ok(isCommandButtonChecked(), "Split console button is now checked.");
-    ok(getVisiblePrefValue(), "Visibility pref is true");
+  await toggleSplitConsoleWithEscape(toolbox);
+  ok(toolbox.splitConsole, "Split console is now visible.");
+  ok(isCommandButtonChecked(toolbox), "Split console button is now checked.");
+  ok(getVisiblePrefValue(), "Visibility pref is true");
+
+  is(getHeightPrefValue(), toolbox.webconsolePanel.height,
+     "Panel height matches the pref");
+  toolbox.webconsolePanel.height = 200;
 
-    is(getHeightPrefValue(), toolbox.webconsolePanel.height,
-       "Panel height matches the pref");
-    toolbox.webconsolePanel.height = 200;
-
-    yield toolbox.destroy();
+  await toolbox.destroy();
 
-    info("Opening a tab while there is a true user setting on split console " +
-         "pref");
-    ({tab} = yield loadTab(TEST_URI));
-    target = TargetFactory.forTab(tab);
-    toolbox = yield gDevTools.showToolbox(target, "inspector");
+  info("Opening a tab while there is a true user setting on split console pref");
+  toolbox = await openNewTabAndToolbox(TEST_URI, "inspector");
+  ok(toolbox.splitConsole, "Split console is visible by default.");
+
+  ok(isCommandButtonChecked(toolbox), "Split console button is checked by default.");
+  is(getHeightPrefValue(), 200, "Height is set based on panel height after closing");
 
-    ok(toolbox.splitConsole, "Split console is visible by default.");
-    ok(isCommandButtonChecked(), "Split console button is checked by default.");
-    is(getHeightPrefValue(), 200, "Height is set based on panel height after " +
-                                  "closing");
+  let activeElement = getActiveElement(toolbox.doc);
+  let inputNode = toolbox.getPanel("webconsole").hud.jsterm.inputNode;
+  is(activeElement, inputNode, "Split console input is focused by default");
 
-    // Use the binding element since jsterm.inputNode is a XUL textarea element.
-    let activeElement = getActiveElement(toolbox.doc);
-    activeElement = activeElement.ownerDocument.getBindingParent(activeElement);
-    let inputNode = toolbox.getPanel("webconsole").hud.jsterm.inputNode;
-    is(activeElement, inputNode, "Split console input is focused by default");
+  toolbox.webconsolePanel.height = 1;
+  ok(toolbox.webconsolePanel.clientHeight > 1,
+     "The actual height of the console is bound with a min height");
 
-    toolbox.webconsolePanel.height = 1;
-    ok(toolbox.webconsolePanel.clientHeight > 1,
-       "The actual height of the console is bound with a min height");
-
-    toolbox.webconsolePanel.height = 10000;
-    ok(toolbox.webconsolePanel.clientHeight < 10000,
-       "The actual height of the console is bound with a max height");
+  toolbox.webconsolePanel.height = 10000;
+  ok(toolbox.webconsolePanel.clientHeight < 10000,
+     "The actual height of the console is bound with a max height");
 
-    yield toggleSplitConsoleWithEscape();
-    ok(!toolbox.splitConsole, "Split console is now hidden.");
-    ok(!isCommandButtonChecked(), "Split console button is now unchecked.");
-    ok(!getVisiblePrefValue(), "Visibility pref is false");
+  await toggleSplitConsoleWithEscape(toolbox);
+  ok(!toolbox.splitConsole, "Split console is now hidden.");
+  ok(!isCommandButtonChecked(toolbox), "Split console button is now unchecked.");
+  ok(!getVisiblePrefValue(), "Visibility pref is false");
 
-    yield toolbox.destroy();
+  await toolbox.destroy();
 
-    is(getHeightPrefValue(), 10000,
-       "Height is set based on panel height after closing");
+  is(getHeightPrefValue(), 10000, "Height is set based on panel height after closing");
 
-    info("Opening a tab while there is a false user setting on split " +
-         "console pref");
-    ({tab} = yield loadTab(TEST_URI));
-    target = TargetFactory.forTab(tab);
-    toolbox = yield gDevTools.showToolbox(target, "inspector");
+  info("Opening a tab while there is a false user setting on split " +
+       "console pref");
+  toolbox = await openNewTabAndToolbox(TEST_URI, "inspector");
 
-    ok(!toolbox.splitConsole, "Split console is hidden by default.");
-    ok(!getVisiblePrefValue(), "Visibility pref is false");
+  ok(!toolbox.splitConsole, "Split console is hidden by default.");
+  ok(!getVisiblePrefValue(), "Visibility pref is false");
 
-    yield toolbox.destroy();
-  }
+  await toolbox.destroy();
+});
 
-  function getActiveElement(doc) {
-    let activeElement = doc.activeElement;
-    while (activeElement && activeElement.contentDocument) {
-      activeElement = activeElement.contentDocument.activeElement;
-    }
-    return activeElement;
+function getActiveElement(doc) {
+  let activeElement = doc.activeElement;
+  while (activeElement && activeElement.contentDocument) {
+    activeElement = activeElement.contentDocument.activeElement;
   }
+  return activeElement;
+}
 
-  function getVisiblePrefValue() {
-    return Services.prefs.getBoolPref("devtools.toolbox.splitconsoleEnabled");
-  }
-
-  function getHeightPrefValue() {
-    return Services.prefs.getIntPref("devtools.toolbox.splitconsoleHeight");
-  }
+function getVisiblePrefValue() {
+  return Services.prefs.getBoolPref("devtools.toolbox.splitconsoleEnabled");
+}
 
-  function isCommandButtonChecked() {
-    return toolbox.doc.querySelector("#command-button-splitconsole")
-      .classList.contains("checked");
-  }
+function getHeightPrefValue() {
+  return Services.prefs.getIntPref("devtools.toolbox.splitconsoleHeight");
+}
 
-  function toggleSplitConsoleWithEscape() {
-    let onceSplitConsole = toolbox.once("split-console");
-    let contentWindow = toolbox.win;
-    contentWindow.focus();
-    EventUtils.sendKey("ESCAPE", contentWindow);
-    return onceSplitConsole;
-  }
+function isCommandButtonChecked(toolbox) {
+  return toolbox.doc.querySelector("#command-button-splitconsole")
+    .classList.contains("checked");
+}
 
-  function finish() {
-    toolbox = TEST_URI = null;
-    finishTest();
-  }
+function toggleSplitConsoleWithEscape(toolbox) {
+  let onceSplitConsole = toolbox.once("split-console");
+  let toolboxWindow = toolbox.win;
+  toolboxWindow.focus();
+  EventUtils.sendKey("ESCAPE", toolboxWindow);
+  return onceSplitConsole;
 }