Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* vim:set ts=2 sw=2 sts=2 et: */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 // Tests that the input field is focused when the console is opened.
8 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
10 function test() {
11 addTab(TEST_URI);
12 browser.addEventListener("DOMContentLoaded", testInputFocus, false);
13 }
15 function testInputFocus() {
16 browser.removeEventListener("DOMContentLoaded", testInputFocus, false);
18 openConsole().then((hud) => {
19 waitForMessages({
20 webconsole: hud,
21 messages: [{
22 text: "Dolske Digs Bacon",
23 category: CATEGORY_WEBDEV,
24 severity: SEVERITY_LOG,
25 }],
26 }).then(([result]) => {
27 let msg = [...result.matched][0];
28 let outputItem = msg.querySelector(".message-body");
29 ok(outputItem, "found a logged message");
30 let inputNode = hud.jsterm.inputNode;
31 ok(inputNode.getAttribute("focused"), "input node is focused, first");
33 let lostFocus = () => {
34 inputNode.removeEventListener("blur", lostFocus);
35 info("input node lost focus");
36 }
38 inputNode.addEventListener("blur", lostFocus);
40 browser.ownerDocument.getElementById("urlbar").click();
42 ok(!inputNode.getAttribute("focused"), "input node is not focused");
44 EventUtils.sendMouseEvent({type: "click"}, hud.outputNode);
46 ok(inputNode.getAttribute("focused"), "input node is focused, second time")
48 // test click-drags are not focusing the input element.
49 EventUtils.sendMouseEvent({type: "mousedown", clientX: 3, clientY: 4},
50 outputItem);
51 EventUtils.sendMouseEvent({type: "click", clientX: 15, clientY: 5},
52 outputItem);
54 executeSoon(() => {
55 todo(!inputNode.getAttribute("focused"), "input node is not focused after drag");
56 finishTest();
57 });
58 });
59 });
60 }