browser/devtools/debugger/test/browser_dbg_search-autofill-identifier.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_search-autofill-identifier.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,135 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Tests that Debugger Search uses the identifier under cursor if nothing is
     1.9 + * selected or manually passed and searching using certain operators.
    1.10 + */
    1.11 +"use strict";
    1.12 +
    1.13 +function test() {
    1.14 +  const TAB_URL = EXAMPLE_URL + "doc_function-search.html";
    1.15 +
    1.16 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.17 +    let Source = 'code_function-search-01.js';
    1.18 +    let Debugger = aPanel.panelWin;
    1.19 +    let Editor = Debugger.DebuggerView.editor;
    1.20 +    let Filtering = Debugger.DebuggerView.Filtering;
    1.21 +
    1.22 +    function doSearch(aOperator) {
    1.23 +      Editor.dropSelection();
    1.24 +      Filtering._doSearch(aOperator);
    1.25 +    }
    1.26 +
    1.27 +    waitForSourceShown(aPanel, Source).then(() => {
    1.28 +      info("Testing with cursor at the beginning of the file...");
    1.29 +
    1.30 +      doSearch();
    1.31 +      is(Filtering._searchbox.value, "",
    1.32 +        "The searchbox value should not be auto-filled when searching for files.");
    1.33 +      is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
    1.34 +        "The searchbox contents should not be selected");
    1.35 +      is(Editor.getSelection(), "",
    1.36 +        "The selection in the editor should be empty.");
    1.37 +
    1.38 +      doSearch("!");
    1.39 +      is(Filtering._searchbox.value, "!",
    1.40 +        "The searchbox value should not be auto-filled when searching across all files.");
    1.41 +      is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
    1.42 +        "The searchbox contents should not be selected");
    1.43 +      is(Editor.getSelection(), "",
    1.44 +        "The selection in the editor should be empty.");
    1.45 +
    1.46 +      doSearch("@");
    1.47 +      is(Filtering._searchbox.value, "@",
    1.48 +        "The searchbox value should not be auto-filled when searching for functions.");
    1.49 +      is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
    1.50 +        "The searchbox contents should not be selected");
    1.51 +      is(Editor.getSelection(), "",
    1.52 +        "The selection in the editor should be empty.");
    1.53 +
    1.54 +      doSearch("#");
    1.55 +      is(Filtering._searchbox.value, "#",
    1.56 +        "The searchbox value should not be auto-filled when searching inside a file.");
    1.57 +      is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
    1.58 +        "The searchbox contents should not be selected");
    1.59 +      is(Editor.getSelection(), "",
    1.60 +        "The selection in the editor should be empty.");
    1.61 +
    1.62 +      doSearch(":");
    1.63 +      is(Filtering._searchbox.value, ":",
    1.64 +        "The searchbox value should not be auto-filled when searching for a line.");
    1.65 +      is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
    1.66 +        "The searchbox contents should not be selected");
    1.67 +      is(Editor.getSelection(), "",
    1.68 +        "The selection in the editor should be empty.");
    1.69 +
    1.70 +      doSearch("*");
    1.71 +      is(Filtering._searchbox.value, "*",
    1.72 +        "The searchbox value should not be auto-filled when searching for variables.");
    1.73 +      is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
    1.74 +        "The searchbox contents should not be selected");
    1.75 +      is(Editor.getSelection(), "",
    1.76 +        "The selection in the editor should be empty.");
    1.77 +
    1.78 +      Editor.setCursor({ line: 7, ch: 0});
    1.79 +      info("Testing with cursor at line 8 and char 1...");
    1.80 +
    1.81 +      doSearch();
    1.82 +      is(Filtering._searchbox.value, "",
    1.83 +        "The searchbox value should not be auto-filled when searching for files.");
    1.84 +      is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
    1.85 +        "The searchbox contents should not be selected");
    1.86 +      is(Editor.getSelection(), "",
    1.87 +        "The selection in the editor should be empty.");
    1.88 +
    1.89 +      doSearch("!");
    1.90 +      is(Filtering._searchbox.value, "!test",
    1.91 +        "The searchbox value was incorrect when searching across all files.");
    1.92 +      is(Filtering._searchbox.selectionStart, 1,
    1.93 +        "The searchbox operator should not be selected");
    1.94 +      is(Filtering._searchbox.selectionEnd, 5,
    1.95 +        "The searchbox contents should be selected");
    1.96 +      is(Editor.getSelection(), "",
    1.97 +        "The selection in the editor should be empty.");
    1.98 +
    1.99 +      doSearch("@");
   1.100 +      is(Filtering._searchbox.value, "@test",
   1.101 +        "The searchbox value was incorrect when searching for functions.");
   1.102 +      is(Filtering._searchbox.selectionStart, 1,
   1.103 +        "The searchbox operator should not be selected");
   1.104 +      is(Filtering._searchbox.selectionEnd, 5,
   1.105 +        "The searchbox contents should be selected");
   1.106 +      is(Editor.getSelection(), "",
   1.107 +        "The selection in the editor should be empty.");
   1.108 +
   1.109 +      doSearch("#");
   1.110 +      is(Filtering._searchbox.value, "#test",
   1.111 +        "The searchbox value should be auto-filled when searching inside a file.");
   1.112 +      is(Filtering._searchbox.selectionStart, 1,
   1.113 +        "The searchbox operator should not be selected");
   1.114 +      is(Filtering._searchbox.selectionEnd, 5,
   1.115 +        "The searchbox contents should be selected");
   1.116 +      is(Editor.getSelection(), "test",
   1.117 +        "The selection in the editor should be 'test'.");
   1.118 +
   1.119 +      doSearch(":");
   1.120 +      is(Filtering._searchbox.value, ":",
   1.121 +        "The searchbox value should not be auto-filled when searching for a line.");
   1.122 +      is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
   1.123 +        "The searchbox contents should not be selected");
   1.124 +      is(Editor.getSelection(), "",
   1.125 +        "The selection in the editor should be empty.");
   1.126 +
   1.127 +      doSearch("*");
   1.128 +      is(Filtering._searchbox.value, "*",
   1.129 +        "The searchbox value should not be auto-filled when searching for variables.");
   1.130 +      is(Filtering._searchbox.selectionStart, Filtering._searchbox.selectionEnd,
   1.131 +        "The searchbox contents should not be selected");
   1.132 +      is(Editor.getSelection(), "",
   1.133 +        "The selection in the editor should be empty.");
   1.134 +
   1.135 +      closeDebuggerAndFinish(aPanel);
   1.136 +    });
   1.137 +  });
   1.138 +};

mercurial