browser/devtools/webconsole/test/browser_console_click_focus.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial