browser/devtools/debugger/test/browser_dbg_searchbox-help-popup-01.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_searchbox-help-popup-01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     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 + * Make sure that the searchbox popup is displayed when focusing the searchbox,
     1.9 + * and hidden when the user starts typing.
    1.10 + */
    1.11 +
    1.12 +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
    1.13 +
    1.14 +let gTab, gDebuggee, gPanel, gDebugger;
    1.15 +let gSearchBox, gSearchBoxPanel;
    1.16 +
    1.17 +function test() {
    1.18 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.19 +    gTab = aTab;
    1.20 +    gDebuggee = aDebuggee;
    1.21 +    gPanel = aPanel;
    1.22 +    gDebugger = gPanel.panelWin;
    1.23 +    gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
    1.24 +    gSearchBoxPanel = gDebugger.DebuggerView.Filtering._searchboxHelpPanel;
    1.25 +
    1.26 +    waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1)
    1.27 +      .then(showPopup)
    1.28 +      .then(hidePopup)
    1.29 +      .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    1.30 +      .then(null, aError => {
    1.31 +        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    1.32 +      });
    1.33 +
    1.34 +    gDebuggee.firstCall();
    1.35 +  });
    1.36 +}
    1.37 +
    1.38 +function showPopup() {
    1.39 +  is(gSearchBoxPanel.state, "closed",
    1.40 +    "The search box panel shouldn't be visible yet.");
    1.41 +
    1.42 +  let finished = once(gSearchBoxPanel, "popupshown");
    1.43 +  EventUtils.sendMouseEvent({ type: "click" }, gSearchBox, gDebugger);
    1.44 +  return finished;
    1.45 +}
    1.46 +
    1.47 +function hidePopup() {
    1.48 +  is(gSearchBoxPanel.state, "open",
    1.49 +    "The search box panel should be visible after searching started.");
    1.50 +
    1.51 +  let finished = once(gSearchBoxPanel, "popuphidden");
    1.52 +  setText(gSearchBox, "#");
    1.53 +  return finished;
    1.54 +}
    1.55 +
    1.56 +registerCleanupFunction(function() {
    1.57 +  gTab = null;
    1.58 +  gDebuggee = null;
    1.59 +  gPanel = null;
    1.60 +  gDebugger = null;
    1.61 +  gSearchBox = null;
    1.62 +  gSearchBoxPanel = null;
    1.63 +});

mercurial