browser/devtools/debugger/test/browser_dbg_pretty-print-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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Tests that the function searching works with pretty printed sources.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html";
    10 let gTab, gDebuggee, gPanel, gDebugger;
    11 let gSearchBox;
    13 function test() {
    14   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    15     gTab = aTab;
    16     gDebuggee = aDebuggee;
    17     gPanel = aPanel;
    18     gDebugger = gPanel.panelWin;
    19     gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
    21     waitForSourceShown(gPanel, "code_ugly.js")
    22       .then(testUglySearch)
    23       .then(() => {
    24         const finished = waitForSourceShown(gPanel, "code_ugly.js");
    25         clickPrettyPrintButton();
    26         return finished;
    27       })
    28       .then(testPrettyPrintedSearch)
    29       .then(() => closeDebuggerAndFinish(gPanel))
    30       .then(null, aError => {
    31         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    32       });
    33   });
    34 }
    36 function testUglySearch() {
    37   const deferred = promise.defer();
    39   once(gDebugger, "popupshown").then(() => {
    40     ok(isCaretPos(gPanel, 2, 10),
    41        "The bar function's non-pretty-printed location should be shown.");
    42     deferred.resolve();
    43   });
    45   setText(gSearchBox, "@bar");
    46   return deferred.promise;
    47 }
    49 function clickPrettyPrintButton() {
    50   gDebugger.document.getElementById("pretty-print").click();
    51 }
    53 function testPrettyPrintedSearch() {
    54   const deferred = promise.defer();
    56   once(gDebugger, "popupshown").then(() => {
    57     ok(isCaretPos(gPanel, 6, 10),
    58        "The bar function's pretty printed location should be shown.");
    59     deferred.resolve();
    60   });
    62   setText(gSearchBox, "@bar");
    63   return deferred.promise;
    64 }
    66 registerCleanupFunction(function() {
    67   gTab = null;
    68   gDebuggee = null;
    69   gPanel = null;
    70   gDebugger = null;
    71   gSearchBox = null;
    72 });

mercurial