browser/devtools/debugger/test/browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.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  * Bug 978019: Setting a breakpoint on the last line of a Debugger.Script and
     6  * reloading should still hit the breakpoint.
     7  */
     9 const TAB_URL = EXAMPLE_URL + "doc_breakpoints-break-on-last-line-of-script-on-reload.html";
    10 const CODE_URL = EXAMPLE_URL + "code_breakpoints-break-on-last-line-of-script-on-reload.js";
    12 function test() {
    13   let gPanel, gDebugger, gThreadClient, gEvents;
    15   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    16     gPanel = aPanel;
    17     gDebugger = gPanel.panelWin;
    18     gThreadClient = gDebugger.gThreadClient;
    19     gEvents = gDebugger.EVENTS;
    21     Task.spawn(function* () {
    22       try {
    24         // Refresh and hit the debugger statement before the location we want to
    25         // set our breakpoints. We have to pause before the breakpoint locations
    26         // so that GC doesn't get a chance to kick in and collect the IIFE's
    27         // script, which would causes us to receive a 'noScript' error from the
    28         // server when we try to set the breakpoints.
    29         const [paused, ] = yield promise.all([
    30           waitForThreadEvents(gPanel, "paused"),
    31           reloadActiveTab(gPanel, gEvents.SOURCE_SHOWN),
    32         ]);
    34         is(paused.why.type, "debuggerStatement");
    36         // Set our breakpoints.
    37         const [bp1, bp2, bp3] = yield promise.all([
    38           setBreakpoint({
    39             url: CODE_URL,
    40             line: 3
    41           }),
    42           setBreakpoint({
    43             url: CODE_URL,
    44             line: 4
    45           }),
    46           setBreakpoint({
    47             url: CODE_URL,
    48             line: 5
    49           })
    50         ]);
    52         // Refresh and hit the debugger statement again.
    53         yield promise.all([
    54           reloadActiveTab(gPanel, gEvents.SOURCE_SHOWN),
    55           waitForCaretAndScopes(gPanel, 1)
    56         ]);
    58         // And we should hit the breakpoints as we resume.
    59         yield promise.all([
    60           doResume(gPanel),
    61           waitForCaretAndScopes(gPanel, 3)
    62         ]);
    63         yield promise.all([
    64           doResume(gPanel),
    65           waitForCaretAndScopes(gPanel, 4)
    66         ]);
    67         yield promise.all([
    68           doResume(gPanel),
    69           waitForCaretAndScopes(gPanel, 5)
    70         ]);
    72         // Clean up the breakpoints.
    73         yield promise.all([
    74           rdpInvoke(bp1, bp1.remove),
    75           rdpInvoke(bp2, bp1.remove),
    76           rdpInvoke(bp3, bp1.remove),
    77         ]);
    79         yield resumeDebuggerThenCloseAndFinish(gPanel);
    81       } catch (e) {
    82         DevToolsUtils.reportException(
    83           "browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js",
    84           e
    85         );
    86         ok(false);
    87       }
    88     });
    89   });
    91   function setBreakpoint(location) {
    92     let deferred = promise.defer();
    93     gThreadClient.setBreakpoint(location, ({ error, message }, bpClient) => {
    94       if (error) {
    95         deferred.reject(error + ": " + message);
    96       }
    97       deferred.resolve(bpClient);
    98     });
    99     return deferred.promise;
   100   }
   101 }

mercurial