browser/devtools/webconsole/test/browser_webconsole_bug_588967_input_expansion.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:a09f81ad78f9
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 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
7
8 function test() {
9 addTab(TEST_URI);
10 browser.addEventListener("load", function onLoad() {
11 browser.removeEventListener("load", onLoad, true);
12 openConsole(null, testInputExpansion);
13 }, true);
14 }
15
16 function testInputExpansion(hud) {
17 let input = hud.jsterm.inputNode;
18
19 input.focus();
20
21 is(input.getAttribute("multiline"), "true", "multiline is enabled");
22
23 let ordinaryHeight = input.clientHeight;
24
25 // Tests if the inputNode expands.
26 input.value = "hello\nworld\n";
27 let length = input.value.length;
28 input.selectionEnd = length;
29 input.selectionStart = length;
30 // Performs an "d". This will trigger/test for the input event that should
31 // change the height of the inputNode.
32 EventUtils.synthesizeKey("d", {});
33 ok(input.clientHeight > ordinaryHeight, "the input expanded");
34
35 // Test if the inputNode shrinks again.
36 input.value = "";
37 EventUtils.synthesizeKey("d", {});
38 is(input.clientHeight, ordinaryHeight, "the input's height is normal again");
39
40 input = length = null;
41
42 finishTest();
43 }
44

mercurial