1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_588342_document_focus.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +/* vim:set ts=2 sw=2 sts=2 et: */ 1.5 +/* ***** BEGIN LICENSE BLOCK ***** 1.6 + * Any copyright is dedicated to the Public Domain. 1.7 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.8 + * 1.9 + * Contributor(s): 1.10 + * Mihai Șucan <mihai.sucan@gmail.com> 1.11 + * 1.12 + * ***** END LICENSE BLOCK ***** */ 1.13 + 1.14 +const TEST_URI = "data:text/html;charset=utf-8,Web Console test for bug 588342"; 1.15 +let fm; 1.16 + 1.17 +function test() { 1.18 + fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager); 1.19 + addTab(TEST_URI); 1.20 + browser.addEventListener("load", function onLoad() { 1.21 + browser.removeEventListener("load", onLoad, true); 1.22 + openConsole(null, consoleOpened); 1.23 + }, true); 1.24 +} 1.25 + 1.26 +function consoleOpened(hud) { 1.27 + waitForFocus(function() { 1.28 + is(hud.jsterm.inputNode.getAttribute("focused"), "true", 1.29 + "jsterm input is focused on web console open"); 1.30 + isnot(fm.focusedWindow, content, "content document has no focus"); 1.31 + closeConsole(null, consoleClosed); 1.32 + }, hud.iframeWindow); 1.33 +} 1.34 + 1.35 +function consoleClosed() { 1.36 + is(fm.focusedWindow, browser.contentWindow, 1.37 + "content document has focus"); 1.38 + 1.39 + fm = null; 1.40 + finishTest(); 1.41 +} 1.42 +