browser/devtools/debugger/test/browser_dbg_search-basic-04.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 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Tests that the selection is dropped for line and token searches, after
michael@0 6 * pressing backspace enough times.
michael@0 7 */
michael@0 8
michael@0 9 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
michael@0 10
michael@0 11 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 12 let gEditor, gSources, gSearchBox;
michael@0 13
michael@0 14 function test() {
michael@0 15 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 16 gTab = aTab;
michael@0 17 gDebuggee = aDebuggee;
michael@0 18 gPanel = aPanel;
michael@0 19 gDebugger = gPanel.panelWin;
michael@0 20 gEditor = gDebugger.DebuggerView.editor;
michael@0 21 gSources = gDebugger.DebuggerView.Sources;
michael@0 22 gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
michael@0 23
michael@0 24 waitForSourceShown(gPanel, "-01.js")
michael@0 25 .then(testLineSearch)
michael@0 26 .then(testTokenSearch)
michael@0 27 .then(() => closeDebuggerAndFinish(gPanel))
michael@0 28 .then(null, aError => {
michael@0 29 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 30 });
michael@0 31 });
michael@0 32 }
michael@0 33
michael@0 34 function testLineSearch() {
michael@0 35 setText(gSearchBox, ":42");
michael@0 36 ok(isCaretPos(gPanel, 7),
michael@0 37 "The editor caret position appears to be correct (1.1).");
michael@0 38 ok(isEditorSel(gPanel, [160, 160]),
michael@0 39 "The editor selection appears to be correct (1.1).");
michael@0 40 is(gEditor.getSelection(), "",
michael@0 41 "The editor selected text appears to be correct (1.1).");
michael@0 42
michael@0 43 backspaceText(gSearchBox, 1);
michael@0 44 ok(isCaretPos(gPanel, 4),
michael@0 45 "The editor caret position appears to be correct (1.2).");
michael@0 46 ok(isEditorSel(gPanel, [110, 110]),
michael@0 47 "The editor selection appears to be correct (1.2).");
michael@0 48 is(gEditor.getSelection(), "",
michael@0 49 "The editor selected text appears to be correct (1.2).");
michael@0 50
michael@0 51 backspaceText(gSearchBox, 1);
michael@0 52 ok(isCaretPos(gPanel, 4),
michael@0 53 "The editor caret position appears to be correct (1.3).");
michael@0 54 ok(isEditorSel(gPanel, [110, 110]),
michael@0 55 "The editor selection appears to be correct (1.3).");
michael@0 56 is(gEditor.getSelection(), "",
michael@0 57 "The editor selected text appears to be correct (1.3).");
michael@0 58
michael@0 59 setText(gSearchBox, ":4");
michael@0 60 ok(isCaretPos(gPanel, 4),
michael@0 61 "The editor caret position appears to be correct (1.4).");
michael@0 62 ok(isEditorSel(gPanel, [110, 110]),
michael@0 63 "The editor selection appears to be correct (1.4).");
michael@0 64 is(gEditor.getSelection(), "",
michael@0 65 "The editor selected text appears to be correct (1.4).");
michael@0 66
michael@0 67 gSearchBox.select();
michael@0 68 backspaceText(gSearchBox, 1);
michael@0 69 ok(isCaretPos(gPanel, 4),
michael@0 70 "The editor caret position appears to be correct (1.5).");
michael@0 71 ok(isEditorSel(gPanel, [110, 110]),
michael@0 72 "The editor selection appears to be correct (1.5).");
michael@0 73 is(gEditor.getSelection(), "",
michael@0 74 "The editor selected text appears to be correct (1.5).");
michael@0 75 is(gSearchBox.value, "",
michael@0 76 "The searchbox should have been cleared.");
michael@0 77 }
michael@0 78
michael@0 79 function testTokenSearch() {
michael@0 80 setText(gSearchBox, "#;\"");
michael@0 81 ok(isCaretPos(gPanel, 5, 23),
michael@0 82 "The editor caret position appears to be correct (2.1).");
michael@0 83 ok(isEditorSel(gPanel, [153, 155]),
michael@0 84 "The editor selection appears to be correct (2.1).");
michael@0 85 is(gEditor.getSelection(), ";\"",
michael@0 86 "The editor selected text appears to be correct (2.1).");
michael@0 87
michael@0 88 backspaceText(gSearchBox, 1);
michael@0 89 ok(isCaretPos(gPanel, 5, 22),
michael@0 90 "The editor caret position appears to be correct (2.2).");
michael@0 91 ok(isEditorSel(gPanel, [153, 154]),
michael@0 92 "The editor selection appears to be correct (2.2).");
michael@0 93 is(gEditor.getSelection(), ";",
michael@0 94 "The editor selected text appears to be correct (2.2).");
michael@0 95
michael@0 96 backspaceText(gSearchBox, 1);
michael@0 97 ok(isCaretPos(gPanel, 5, 22),
michael@0 98 "The editor caret position appears to be correct (2.3).");
michael@0 99 ok(isEditorSel(gPanel, [154, 154]),
michael@0 100 "The editor selection appears to be correct (2.3).");
michael@0 101 is(gEditor.getSelection(), "",
michael@0 102 "The editor selected text appears to be correct (2.3).");
michael@0 103
michael@0 104 setText(gSearchBox, "#;");
michael@0 105 ok(isCaretPos(gPanel, 5, 22),
michael@0 106 "The editor caret position appears to be correct (2.4).");
michael@0 107 ok(isEditorSel(gPanel, [153, 154]),
michael@0 108 "The editor selection appears to be correct (2.4).");
michael@0 109 is(gEditor.getSelection(), ";",
michael@0 110 "The editor selected text appears to be correct (2.4).");
michael@0 111
michael@0 112 gSearchBox.select();
michael@0 113 backspaceText(gSearchBox, 1);
michael@0 114 ok(isCaretPos(gPanel, 5, 22),
michael@0 115 "The editor caret position appears to be correct (2.5).");
michael@0 116 ok(isEditorSel(gPanel, [154, 154]),
michael@0 117 "The editor selection appears to be correct (2.5).");
michael@0 118 is(gEditor.getSelection(), "",
michael@0 119 "The editor selected text appears to be correct (2.5).");
michael@0 120 is(gSearchBox.value, "",
michael@0 121 "The searchbox should have been cleared.");
michael@0 122 }
michael@0 123
michael@0 124 registerCleanupFunction(function() {
michael@0 125 gTab = null;
michael@0 126 gDebuggee = null;
michael@0 127 gPanel = null;
michael@0 128 gDebugger = null;
michael@0 129 gEditor = null;
michael@0 130 gSources = null;
michael@0 131 gSearchBox = null;
michael@0 132 });

mercurial