browser/devtools/webconsole/test/browser_webconsole_history.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.

     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/. */
     6 // Tests the console history feature accessed via the up and down arrow keys.
     8 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
    10 // Constants used for defining the direction of JSTerm input history navigation.
    11 const HISTORY_BACK = -1;
    12 const HISTORY_FORWARD = 1;
    14 function test() {
    15   addTab(TEST_URI);
    16   browser.addEventListener("load", function onLoad() {
    17     browser.removeEventListener("load", onLoad, true);
    18     openConsole(null, testHistory);
    19   }, true);
    20 }
    22 function testHistory(hud) {
    23   let jsterm = hud.jsterm;
    24   let input = jsterm.inputNode;
    26   let executeList = ["document", "window", "window.location"];
    28   for each (var item in executeList) {
    29     input.value = item;
    30     jsterm.execute();
    31   }
    33   for (var i = executeList.length - 1; i != -1; i--) {
    34     jsterm.historyPeruse(HISTORY_BACK);
    35     is (input.value, executeList[i], "check history previous idx:" + i);
    36   }
    38   jsterm.historyPeruse(HISTORY_BACK);
    39   is (input.value, executeList[0], "test that item is still index 0");
    41   jsterm.historyPeruse(HISTORY_BACK);
    42   is (input.value, executeList[0], "test that item is still still index 0");
    44   for (var i = 1; i < executeList.length; i++) {
    45     jsterm.historyPeruse(HISTORY_FORWARD);
    46     is (input.value, executeList[i], "check history next idx:" + i);
    47   }
    49   jsterm.historyPeruse(HISTORY_FORWARD);
    50   is (input.value, "", "check input is empty again");
    52   // Simulate pressing Arrow_Down a few times and then if Arrow_Up shows
    53   // the previous item from history again.
    54   jsterm.historyPeruse(HISTORY_FORWARD);
    55   jsterm.historyPeruse(HISTORY_FORWARD);
    56   jsterm.historyPeruse(HISTORY_FORWARD);
    58   is (input.value, "", "check input is still empty");
    60   let idxLast = executeList.length - 1;
    61   jsterm.historyPeruse(HISTORY_BACK);
    62   is (input.value, executeList[idxLast], "check history next idx:" + idxLast);
    64   executeSoon(finishTest);
    65 }

mercurial