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.
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 box expands as the user types long lines. |
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("load", function onLoad() { |
michael@0 | 13 | browser.removeEventListener("load", onLoad, true); |
michael@0 | 14 | openConsole(null, testJSInputExpansion); |
michael@0 | 15 | }, true); |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | function testJSInputExpansion(hud) { |
michael@0 | 19 | let jsterm = hud.jsterm; |
michael@0 | 20 | let input = jsterm.inputNode; |
michael@0 | 21 | input.focus(); |
michael@0 | 22 | |
michael@0 | 23 | is(input.getAttribute("multiline"), "true", "multiline is enabled"); |
michael@0 | 24 | // Tests if the inputNode expands. |
michael@0 | 25 | input.value = "hello\nworld\n"; |
michael@0 | 26 | let length = input.value.length; |
michael@0 | 27 | input.selectionEnd = length; |
michael@0 | 28 | input.selectionStart = length; |
michael@0 | 29 | function getHeight() |
michael@0 | 30 | { |
michael@0 | 31 | return input.clientHeight; |
michael@0 | 32 | } |
michael@0 | 33 | let initialHeight = getHeight(); |
michael@0 | 34 | // Performs an "d". This will trigger/test for the input event that should |
michael@0 | 35 | // change the "row" attribute of the inputNode. |
michael@0 | 36 | EventUtils.synthesizeKey("d", {}); |
michael@0 | 37 | let newHeight = getHeight(); |
michael@0 | 38 | ok(initialHeight < newHeight, "Height changed: " + newHeight); |
michael@0 | 39 | |
michael@0 | 40 | // Add some more rows. Tests for the 8 row limit. |
michael@0 | 41 | input.value = "row1\nrow2\nrow3\nrow4\nrow5\nrow6\nrow7\nrow8\nrow9\nrow10\n"; |
michael@0 | 42 | length = input.value.length; |
michael@0 | 43 | input.selectionEnd = length; |
michael@0 | 44 | input.selectionStart = length; |
michael@0 | 45 | EventUtils.synthesizeKey("d", {}); |
michael@0 | 46 | let newerHeight = getHeight(); |
michael@0 | 47 | |
michael@0 | 48 | ok(newerHeight > newHeight, "height changed: " + newerHeight); |
michael@0 | 49 | |
michael@0 | 50 | // Test if the inputNode shrinks again. |
michael@0 | 51 | input.value = ""; |
michael@0 | 52 | EventUtils.synthesizeKey("d", {}); |
michael@0 | 53 | let height = getHeight(); |
michael@0 | 54 | info("height: " + height); |
michael@0 | 55 | info("initialHeight: " + initialHeight); |
michael@0 | 56 | let finalHeightDifference = Math.abs(initialHeight - height); |
michael@0 | 57 | ok(finalHeightDifference <= 1, "height shrank to original size within 1px"); |
michael@0 | 58 | |
michael@0 | 59 | finishTest(); |
michael@0 | 60 | } |