browser/devtools/debugger/test/browser_dbg_source-maps-03.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 we can debug minified javascript with source maps.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_minified.html";
     9 const JS_URL = EXAMPLE_URL + "code_math.js";
    11 let gDebuggee, gPanel, gDebugger;
    12 let gEditor, gSources, gFrames;
    14 function test() {
    15   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    16     gDebuggee = aDebuggee;
    17     gPanel = aPanel;
    18     gDebugger = gPanel.panelWin;
    19     gEditor = gDebugger.DebuggerView.editor;
    20     gSources = gDebugger.DebuggerView.Sources;
    21     gFrames = gDebugger.DebuggerView.StackFrames;
    23     waitForSourceShown(gPanel, JS_URL)
    24       .then(checkInitialSource)
    25       .then(testSetBreakpoint)
    26       .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    27       .then(null, aError => {
    28         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    29       });
    30   });
    31 }
    33 function checkInitialSource() {
    34   isnot(gSources.selectedValue.indexOf(".js"), -1,
    35     "The debugger should not show the minified js file.");
    36   is(gSources.selectedValue.indexOf(".min.js"), -1,
    37     "The debugger should show the original js file.");
    38   is(gEditor.getText().split("\n").length, 46,
    39     "The debugger's editor should have the original source displayed, " +
    40     "not the whitespace stripped minified version.");
    41 }
    43 function testSetBreakpoint() {
    44   let deferred = promise.defer();
    46   gDebugger.gThreadClient.setBreakpoint({ url: JS_URL, line: 30, column: 21 }, aResponse => {
    47     ok(!aResponse.error,
    48       "Should be able to set a breakpoint in a js file.");
    49     ok(!aResponse.actualLocation,
    50       "Should be able to set a breakpoint on line 30 and column 10.");
    52     gDebugger.gClient.addOneTimeListener("resumed", () => {
    53       waitForCaretAndScopes(gPanel, 30).then(() => {
    54         // Make sure that we have the right stack frames.
    55         is(gFrames.itemCount, 9,
    56           "Should have nine frames.");
    57         is(gFrames.getItemAtIndex(0).attachment.url.indexOf(".min.js"), -1,
    58           "First frame should not be a minified JS frame.");
    59         isnot(gFrames.getItemAtIndex(0).attachment.url.indexOf(".js"), -1,
    60           "First frame should be a JS frame.");
    62         deferred.resolve();
    63       });
    65       // This will cause the breakpoint to be hit, and put us back in the
    66       // paused state.
    67       gDebuggee.arithmetic();
    68     });
    69   });
    71   return deferred.promise;
    72 }
    74 registerCleanupFunction(function() {
    75   gDebuggee = null;
    76   gPanel = null;
    77   gDebugger = null;
    78   gEditor = null;
    79   gSources = null;
    80   gFrames = null;
    81 });

mercurial