|
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/. */ |
|
5 |
|
6 // Tests that the input field is focused when the console is opened. |
|
7 |
|
8 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; |
|
9 |
|
10 function test() { |
|
11 addTab(TEST_URI); |
|
12 browser.addEventListener("DOMContentLoaded", testInputFocus, false); |
|
13 } |
|
14 |
|
15 function testInputFocus() { |
|
16 browser.removeEventListener("DOMContentLoaded", testInputFocus, false); |
|
17 |
|
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"); |
|
32 |
|
33 let lostFocus = () => { |
|
34 inputNode.removeEventListener("blur", lostFocus); |
|
35 info("input node lost focus"); |
|
36 } |
|
37 |
|
38 inputNode.addEventListener("blur", lostFocus); |
|
39 |
|
40 browser.ownerDocument.getElementById("urlbar").click(); |
|
41 |
|
42 ok(!inputNode.getAttribute("focused"), "input node is not focused"); |
|
43 |
|
44 EventUtils.sendMouseEvent({type: "click"}, hud.outputNode); |
|
45 |
|
46 ok(inputNode.getAttribute("focused"), "input node is focused, second time") |
|
47 |
|
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); |
|
53 |
|
54 executeSoon(() => { |
|
55 todo(!inputNode.getAttribute("focused"), "input node is not focused after drag"); |
|
56 finishTest(); |
|
57 }); |
|
58 }); |
|
59 }); |
|
60 } |