Bug 1404882 - Enable browser_webconsole_No_input_change_and_Tab_key_pressed.js and rename it;r=Honza draft
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Thu, 12 Oct 2017 16:56:23 +0200
changeset 679319 ab4f454590556c0fa57d4a3cf2e85cbfffd57fb5
parent 679288 049172d5ee87f16d585f6b01dfeb231eed8091f6
child 735575 292eade0bf5269e498295c413ef9d6dd3d66381e
push id84193
push userbmo:nchevobbe@mozilla.com
push dateThu, 12 Oct 2017 15:05:44 +0000
reviewersHonza
bugs1404882
milestone58.0a1
Bug 1404882 - Enable browser_webconsole_No_input_change_and_Tab_key_pressed.js and rename it;r=Honza This required to add an extra-check to the hasFocus function to make sure the console document is also focused, since document.activeElement could still be the jsterm input, even if the focus is on another document. MozReview-Commit-ID: 72VfES8sXob
devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_change_and_tab_key_pressed.js
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_No_input_change_and_Tab_key_pressed.js
devtools/client/webconsole/new-console-output/test/mochitest/head.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -201,21 +201,20 @@ skip-if = true
 subsuite = clipboard
 # old console skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
 [browser_jsterm_history_persist.js]
 skip-if = true # Bug 1401881
 [browser_jsterm_inspect.js]
 [browser_jsterm_no_autocompletion_on_defined_variables.js]
 skip-if = true # Bug 1401881
 [browser_jsterm_no_input_and_tab_key_pressed.js]
+[browser_jsterm_no_input_change_and_tab_key_pressed.js]
 [browser_netmonitor_shows_reqs_in_webconsole.js]
 [browser_webconsole.js]
 skip-if = true #	Bug 1404829
-[browser_webconsole_No_input_change_and_Tab_key_pressed.js]
-skip-if = true #	Bug 1404882
 [browser_webconsole_add_edited_input_to_history.js]
 skip-if = true # Bug 1401881
 [browser_webconsole_allow_mixedcontent_securityerrors.js]
 tags = mcb
 skip-if = true #	Bug 1403452
 # old console skip-if = (os == 'win' && bits == 64) # Bug 1390001
 [browser_webconsole_assert.js]
 skip-if = true #	Bug 1403458
rename from devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_No_input_change_and_Tab_key_pressed.js
rename to devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_change_and_tab_key_pressed.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_No_input_change_and_Tab_key_pressed.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_change_and_tab_key_pressed.js
@@ -2,36 +2,32 @@
 /* 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 734061.
 
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
-                 "test/browser/test-console.html";
+const TEST_URI = "data:text/html,Testing jsterm focus";
 
 add_task(function* () {
-  yield loadTab(TEST_URI);
-
-  let hud = yield openConsole();
-
+  let hud = yield openNewTabAndConsole(TEST_URI);
   let jsterm = hud.jsterm;
   let input = jsterm.inputNode;
 
-  is(input.getAttribute("focused"), "true", "input has focus");
+  is(hasFocus(input), true, "input has focus");
   EventUtils.synthesizeKey("VK_TAB", {});
-  is(input.getAttribute("focused"), "", "focus moved away");
+  is(hasFocus(input), false, "focus moved away");
 
   // Test user changed something
   input.focus();
   EventUtils.synthesizeKey("A", {});
   EventUtils.synthesizeKey("VK_TAB", {});
-  is(input.getAttribute("focused"), "true", "input is still focused");
+  is(hasFocus(input), true, "input is still focused");
 
   // Test non empty input but not changed since last focus
   input.blur();
   input.focus();
   EventUtils.synthesizeKey("VK_RIGHT", {});
   EventUtils.synthesizeKey("VK_TAB", {});
-  is(input.getAttribute("focused"), "", "input moved away");
+  is(hasFocus(input), false, "focus moved away");
 });
--- a/devtools/client/webconsole/new-console-output/test/mochitest/head.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/head.js
@@ -254,10 +254,11 @@ function* checkClickOnNode(hud, toolbox,
     "expected source url"
   );
 }
 
 /**
  * Returns true if the give node is currently focused.
  */
 function hasFocus(node) {
-  return node.ownerDocument.activeElement == node;
+  return node.ownerDocument.activeElement == node
+    && node.ownerDocument.hasFocus();
 }