browser/devtools/debugger/test/browser_dbg_source-maps-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  * Test that bogus source maps don't break debugging.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_minified_bogus_map.html";
     9 const JS_URL = EXAMPLE_URL + "code_math_bogus_map.min.js";
    11 // This test causes an error to be logged in the console, which appears in TBPL
    12 // logs, so we are disabling that here.
    13 let { DevToolsUtils } = Cu.import("resource://gre/modules/devtools/DevToolsUtils.jsm", {});
    14 DevToolsUtils.reportingDisabled = true;
    16 let gPanel, gDebugger, gFrames, gSources, gPrefs, gOptions;
    18 function test() {
    19   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    20     gPanel = aPanel;
    21     gDebugger = gPanel.panelWin;
    22     gFrames = gDebugger.DebuggerView.StackFrames;
    23     gSources = gDebugger.DebuggerView.Sources;
    24     gPrefs = gDebugger.Prefs;
    25     gOptions = gDebugger.DebuggerView.Options;
    27     is(gPrefs.pauseOnExceptions, false,
    28       "The pause-on-exceptions pref should be disabled by default.");
    29     isnot(gOptions._pauseOnExceptionsItem.getAttribute("checked"), "true",
    30       "The pause-on-exceptions menu item should not be checked.");
    32     waitForSourceShown(gPanel, JS_URL)
    33       .then(checkInitialSource)
    34       .then(enablePauseOnExceptions)
    35       .then(disableIgnoreCaughtExceptions)
    36       .then(testSetBreakpoint)
    37       .then(reloadPage)
    38       .then(testHitBreakpoint)
    39       .then(enableIgnoreCaughtExceptions)
    40       .then(disablePauseOnExceptions)
    41       .then(() => closeDebuggerAndFinish(gPanel))
    42       .then(null, aError => {
    43         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    44       });
    45   });
    46 }
    48 function checkInitialSource() {
    49   isnot(gSources.selectedValue.indexOf(".min.js"), -1,
    50     "The debugger should show the minified js file.");
    51 }
    53 function enablePauseOnExceptions() {
    54   let deferred = promise.defer();
    56   gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
    57     is(gPrefs.pauseOnExceptions, true,
    58       "The pause-on-exceptions pref should now be enabled.");
    60     ok(true, "Pausing on exceptions was enabled.");
    61     deferred.resolve();
    62   });
    64   gOptions._pauseOnExceptionsItem.setAttribute("checked", "true");
    65   gOptions._togglePauseOnExceptions();
    67   return deferred.promise;
    68 }
    70 function disableIgnoreCaughtExceptions() {
    71   let deferred = promise.defer();
    73   gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
    74     is(gPrefs.ignoreCaughtExceptions, false,
    75       "The ignore-caught-exceptions pref should now be disabled.");
    77     ok(true, "Ignore caught exceptions was disabled.");
    78     deferred.resolve();
    79   });
    81   gOptions._ignoreCaughtExceptionsItem.setAttribute("checked", "false");
    82   gOptions._toggleIgnoreCaughtExceptions();
    84   return deferred.promise;
    85 }
    87 function testSetBreakpoint() {
    88   let deferred = promise.defer();
    90   gDebugger.gThreadClient.setBreakpoint({ url: JS_URL, line: 3, column: 61 }, aResponse => {
    91     ok(!aResponse.error,
    92       "Should be able to set a breakpoint in a js file.");
    93     ok(!aResponse.actualLocation,
    94       "Should be able to set a breakpoint on line 3 and column 61.");
    96     deferred.resolve();
    97   });
    99   return deferred.promise;
   100 }
   102 function reloadPage() {
   103   let loaded = waitForSourceAndCaret(gPanel, ".js", 3);
   104   gDebugger.DebuggerController._target.activeTab.reload();
   105   return loaded.then(() => ok(true, "Page was reloaded and execution resumed."));
   106 }
   108 function testHitBreakpoint() {
   109   let deferred = promise.defer();
   111   gDebugger.gThreadClient.resume(aResponse => {
   112     ok(!aResponse.error, "Shouldn't get an error resuming.");
   113     is(aResponse.type, "resumed", "Type should be 'resumed'.");
   115     waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
   116       is(gFrames.itemCount, 1, "Should have one frame.");
   118       gDebugger.gThreadClient.resume(deferred.resolve);
   119     });
   120   });
   122   return deferred.promise;
   123 }
   125 function enableIgnoreCaughtExceptions() {
   126   let deferred = promise.defer();
   128   gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
   129     is(gPrefs.ignoreCaughtExceptions, true,
   130       "The ignore-caught-exceptions pref should now be enabled.");
   132     ok(true, "Ignore caught exceptions was enabled.");
   133     deferred.resolve();
   134   });
   136   gOptions._ignoreCaughtExceptionsItem.setAttribute("checked", "true");
   137   gOptions._toggleIgnoreCaughtExceptions();
   139   return deferred.promise;
   140 }
   142 function disablePauseOnExceptions() {
   143   let deferred = promise.defer();
   145   gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
   146     is(gPrefs.pauseOnExceptions, false,
   147       "The pause-on-exceptions pref should now be disabled.");
   149     ok(true, "Pausing on exceptions was disabled.");
   150     deferred.resolve();
   151   });
   153   gOptions._pauseOnExceptionsItem.setAttribute("checked", "false");
   154   gOptions._togglePauseOnExceptions();
   156   return deferred.promise;
   157 }
   159 registerCleanupFunction(function() {
   160   gPanel = null;
   161   gDebugger = null;
   162   gFrames = null;
   163   gSources = null;
   164   gPrefs = null;
   165   gOptions = null;
   166   DevToolsUtils.reportingDisabled = false;
   167 });

mercurial