Bug 1404368 - Enable browser_webconsole_document_focus.js in new frontend;r=jdescottes.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Thu, 04 Jan 2018 12:35:06 +0100
changeset 397774 8a3eb4701abaf310c6347ffbedc2a20552ed844c
parent 397773 928c85e00e1b690129345a03c4741f1d8175a2ad
child 397775 99914fd768522fe45160f171966a5efc65c59cc2
push id57531
push usernchevobbe@mozilla.com
push dateThu, 04 Jan 2018 15:07:12 +0000
treeherderautoland@8a3eb4701aba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1404368
milestone59.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 1404368 - Enable browser_webconsole_document_focus.js in new frontend;r=jdescottes. MozReview-Commit-ID: Fd9p0oigRpB
devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_document_focus.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -259,17 +259,16 @@ skip-if = (os == 'linux' && bits == 32 &
 subsuite = clipboard
 [browser_webconsole_context_menu_object_in_sidebar.js]
 [browser_webconsole_context_menu_open_url.js]
 [browser_webconsole_context_menu_store_as_global.js]
 [browser_webconsole_csp_ignore_reflected_xss_message.js]
 skip-if = (e10s && debug) || (e10s && os == 'win') # Bug 1221499 enabled these on windows
 [browser_webconsole_cspro.js]
 [browser_webconsole_document_focus.js]
-skip-if = true #	Bug 1404368
 [browser_webconsole_duplicate_errors.js]
 skip-if = true #	Bug 1403907
 [browser_webconsole_errors_after_page_reload.js]
 [browser_webconsole_eval_in_debugger_stackframe.js]
 [browser_webconsole_eval_in_debugger_stackframe2.js]
 skip-if = true # Bug 1408893
 [browser_webconsole_execution_scope.js]
 skip-if = true #	Bug 1405333
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_document_focus.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_document_focus.js
@@ -1,38 +1,24 @@
-/* -*- 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 588342.
+// Check that focus is restored to content page after closing the console. See Bug 588342.
+const TEST_URI = "data:text/html;charset=utf-8,Test content focus after closing console";
 
-const TEST_URI = "data:text/html;charset=utf-8,Web Console test for bug 588342";
+add_task(async function () {
+  let hud = await openNewTabAndConsole(TEST_URI);
 
-add_task(function* () {
-  let { browser } = yield loadTab(TEST_URI);
-  let hud = yield openConsole();
+  let inputNode = hud.jsterm.inputNode;
+  info("Focus after console is opened");
+  ok(hasFocus(inputNode), "input node is focused after console is opened");
 
-  yield checkConsoleFocus(hud);
-
-  let isFocused = yield ContentTask.spawn(browser, { }, function* () {
-    var fm = Components.classes["@mozilla.org/focus-manager;1"].
-                         getService(Components.interfaces.nsIFocusManager);
+  info("Closing console");
+  await closeConsole();
+  const isFocused = await ContentTask.spawn(gBrowser.selectedBrowser, { }, function () {
+    const cmp = "@mozilla.org/focus-manager;1";
+    const fm = Components.classes[cmp].getService(Components.interfaces.nsIFocusManager);
     return fm.focusedWindow == content;
   });
-
-  ok(isFocused, "content document has focus");
+  ok(isFocused, "content document has focus after closing the console");
 });
-
-function* checkConsoleFocus(hud) {
-  let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
-
-  yield new Promise(resolve => {
-    waitForFocus(resolve);
-  });
-
-  is(hud.jsterm.inputNode.getAttribute("focused"), "true",
-     "jsterm input is focused on web console open");
-  is(fm.focusedWindow, hud.iframeWindow, "hud window is focused");
-  yield closeConsole(null);
-}