browser/devtools/debugger/test/browser_dbg_search-basic-04.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial