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.

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

mercurial