browser/devtools/webconsole/test/browser_webconsole_bug_588967_input_expansion.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_588967_input_expansion.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     1.4 +/* vim:set ts=2 sw=2 sts=2 et: */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
    1.10 +
    1.11 +function test() {
    1.12 +  addTab(TEST_URI);
    1.13 +  browser.addEventListener("load", function onLoad() {
    1.14 +    browser.removeEventListener("load", onLoad, true);
    1.15 +    openConsole(null, testInputExpansion);
    1.16 +  }, true);
    1.17 +}
    1.18 +
    1.19 +function testInputExpansion(hud) {
    1.20 +  let input = hud.jsterm.inputNode;
    1.21 +
    1.22 +  input.focus();
    1.23 +
    1.24 +  is(input.getAttribute("multiline"), "true", "multiline is enabled");
    1.25 +
    1.26 +  let ordinaryHeight = input.clientHeight;
    1.27 +
    1.28 +  // Tests if the inputNode expands.
    1.29 +  input.value = "hello\nworld\n";
    1.30 +  let length = input.value.length;
    1.31 +  input.selectionEnd = length;
    1.32 +  input.selectionStart = length;
    1.33 +  // Performs an "d". This will trigger/test for the input event that should
    1.34 +  // change the height of the inputNode.
    1.35 +  EventUtils.synthesizeKey("d", {});
    1.36 +  ok(input.clientHeight > ordinaryHeight, "the input expanded");
    1.37 +
    1.38 +  // Test if the inputNode shrinks again.
    1.39 +  input.value = "";
    1.40 +  EventUtils.synthesizeKey("d", {});
    1.41 +  is(input.clientHeight, ordinaryHeight, "the input's height is normal again");
    1.42 +
    1.43 +  input = length = null;
    1.44 +
    1.45 +  finishTest();
    1.46 +}
    1.47 +

mercurial