browser/devtools/debugger/test/browser_dbg_search-autofill-identifier.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 Debugger Search uses the identifier under cursor if nothing is
michael@0 6 * selected or manually passed and searching using certain operators.
michael@0 7 */
michael@0 8 "use strict";
michael@0 9
michael@0 10 function test() {
michael@0 11 const TAB_URL = EXAMPLE_URL + "doc_function-search.html";
michael@0 12
michael@0 13 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 14 let Source = 'code_function-search-01.js';
michael@0 15 let Debugger = aPanel.panelWin;
michael@0 16 let Editor = Debugger.DebuggerView.editor;
michael@0 17 let Filtering = Debugger.DebuggerView.Filtering;
michael@0 18
michael@0 19 function doSearch(aOperator) {
michael@0 20 Editor.dropSelection();
michael@0 21 Filtering._doSearch(aOperator);
michael@0 22 }
michael@0 23
michael@0 24 waitForSourceShown(aPanel, Source).then(() => {
michael@0 25 info("Testing with cursor at the beginning of the file...");
michael@0 26
michael@0 27 doSearch();
michael@0 28 is(Filtering._searchbox.value, "",
michael@0 29 "The searchbox value should not be auto-filled when searching for files.");
michael@0 30 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
michael@0 31 "The searchbox contents should not be selected");
michael@0 32 is(Editor.getSelection(), "",
michael@0 33 "The selection in the editor should be empty.");
michael@0 34
michael@0 35 doSearch("!");
michael@0 36 is(Filtering._searchbox.value, "!",
michael@0 37 "The searchbox value should not be auto-filled when searching across all files.");
michael@0 38 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
michael@0 39 "The searchbox contents should not be selected");
michael@0 40 is(Editor.getSelection(), "",
michael@0 41 "The selection in the editor should be empty.");
michael@0 42
michael@0 43 doSearch("@");
michael@0 44 is(Filtering._searchbox.value, "@",
michael@0 45 "The searchbox value should not be auto-filled when searching for functions.");
michael@0 46 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
michael@0 47 "The searchbox contents should not be selected");
michael@0 48 is(Editor.getSelection(), "",
michael@0 49 "The selection in the editor should be empty.");
michael@0 50
michael@0 51 doSearch("#");
michael@0 52 is(Filtering._searchbox.value, "#",
michael@0 53 "The searchbox value should not be auto-filled when searching inside a file.");
michael@0 54 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
michael@0 55 "The searchbox contents should not be selected");
michael@0 56 is(Editor.getSelection(), "",
michael@0 57 "The selection in the editor should be empty.");
michael@0 58
michael@0 59 doSearch(":");
michael@0 60 is(Filtering._searchbox.value, ":",
michael@0 61 "The searchbox value should not be auto-filled when searching for a line.");
michael@0 62 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
michael@0 63 "The searchbox contents should not be selected");
michael@0 64 is(Editor.getSelection(), "",
michael@0 65 "The selection in the editor should be empty.");
michael@0 66
michael@0 67 doSearch("*");
michael@0 68 is(Filtering._searchbox.value, "*",
michael@0 69 "The searchbox value should not be auto-filled when searching for variables.");
michael@0 70 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
michael@0 71 "The searchbox contents should not be selected");
michael@0 72 is(Editor.getSelection(), "",
michael@0 73 "The selection in the editor should be empty.");
michael@0 74
michael@0 75 Editor.setCursor({ line: 7, ch: 0});
michael@0 76 info("Testing with cursor at line 8 and char 1...");
michael@0 77
michael@0 78 doSearch();
michael@0 79 is(Filtering._searchbox.value, "",
michael@0 80 "The searchbox value should not be auto-filled when searching for files.");
michael@0 81 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
michael@0 82 "The searchbox contents should not be selected");
michael@0 83 is(Editor.getSelection(), "",
michael@0 84 "The selection in the editor should be empty.");
michael@0 85
michael@0 86 doSearch("!");
michael@0 87 is(Filtering._searchbox.value, "!test",
michael@0 88 "The searchbox value was incorrect when searching across all files.");
michael@0 89 is(Filtering._searchbox.selectionStart, 1,
michael@0 90 "The searchbox operator should not be selected");
michael@0 91 is(Filtering._searchbox.selectionEnd, 5,
michael@0 92 "The searchbox contents should be selected");
michael@0 93 is(Editor.getSelection(), "",
michael@0 94 "The selection in the editor should be empty.");
michael@0 95
michael@0 96 doSearch("@");
michael@0 97 is(Filtering._searchbox.value, "@test",
michael@0 98 "The searchbox value was incorrect when searching for functions.");
michael@0 99 is(Filtering._searchbox.selectionStart, 1,
michael@0 100 "The searchbox operator should not be selected");
michael@0 101 is(Filtering._searchbox.selectionEnd, 5,
michael@0 102 "The searchbox contents should be selected");
michael@0 103 is(Editor.getSelection(), "",
michael@0 104 "The selection in the editor should be empty.");
michael@0 105
michael@0 106 doSearch("#");
michael@0 107 is(Filtering._searchbox.value, "#test",
michael@0 108 "The searchbox value should be auto-filled when searching inside a file.");
michael@0 109 is(Filtering._searchbox.selectionStart, 1,
michael@0 110 "The searchbox operator should not be selected");
michael@0 111 is(Filtering._searchbox.selectionEnd, 5,
michael@0 112 "The searchbox contents should be selected");
michael@0 113 is(Editor.getSelection(), "test",
michael@0 114 "The selection in the editor should be 'test'.");
michael@0 115
michael@0 116 doSearch(":");
michael@0 117 is(Filtering._searchbox.value, ":",
michael@0 118 "The searchbox value should not be auto-filled when searching for a line.");
michael@0 119 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
michael@0 120 "The searchbox contents should not be selected");
michael@0 121 is(Editor.getSelection(), "",
michael@0 122 "The selection in the editor should be empty.");
michael@0 123
michael@0 124 doSearch("*");
michael@0 125 is(Filtering._searchbox.value, "*",
michael@0 126 "The searchbox value should not be auto-filled when searching for variables.");
michael@0 127 is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
michael@0 128 "The searchbox contents should not be selected");
michael@0 129 is(Editor.getSelection(), "",
michael@0 130 "The selection in the editor should be empty.");
michael@0 131
michael@0 132 closeDebuggerAndFinish(aPanel);
michael@0 133 });
michael@0 134 });
michael@0 135 };

mercurial