Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Test that we can debug minified javascript with source maps. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | const TAB_URL = EXAMPLE_URL + "doc_minified.html"; |
michael@0 | 9 | const JS_URL = EXAMPLE_URL + "code_math.js"; |
michael@0 | 10 | |
michael@0 | 11 | let gDebuggee, gPanel, gDebugger; |
michael@0 | 12 | let gEditor, gSources, gFrames; |
michael@0 | 13 | |
michael@0 | 14 | function test() { |
michael@0 | 15 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 16 | gDebuggee = aDebuggee; |
michael@0 | 17 | gPanel = aPanel; |
michael@0 | 18 | gDebugger = gPanel.panelWin; |
michael@0 | 19 | gEditor = gDebugger.DebuggerView.editor; |
michael@0 | 20 | gSources = gDebugger.DebuggerView.Sources; |
michael@0 | 21 | gFrames = gDebugger.DebuggerView.StackFrames; |
michael@0 | 22 | |
michael@0 | 23 | waitForSourceShown(gPanel, JS_URL) |
michael@0 | 24 | .then(checkInitialSource) |
michael@0 | 25 | .then(testSetBreakpoint) |
michael@0 | 26 | .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
michael@0 | 27 | .then(null, aError => { |
michael@0 | 28 | ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
michael@0 | 29 | }); |
michael@0 | 30 | }); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | function checkInitialSource() { |
michael@0 | 34 | isnot(gSources.selectedValue.indexOf(".js"), -1, |
michael@0 | 35 | "The debugger should not show the minified js file."); |
michael@0 | 36 | is(gSources.selectedValue.indexOf(".min.js"), -1, |
michael@0 | 37 | "The debugger should show the original js file."); |
michael@0 | 38 | is(gEditor.getText().split("\n").length, 46, |
michael@0 | 39 | "The debugger's editor should have the original source displayed, " + |
michael@0 | 40 | "not the whitespace stripped minified version."); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | function testSetBreakpoint() { |
michael@0 | 44 | let deferred = promise.defer(); |
michael@0 | 45 | |
michael@0 | 46 | gDebugger.gThreadClient.setBreakpoint({ url: JS_URL, line: 30, column: 21 }, aResponse => { |
michael@0 | 47 | ok(!aResponse.error, |
michael@0 | 48 | "Should be able to set a breakpoint in a js file."); |
michael@0 | 49 | ok(!aResponse.actualLocation, |
michael@0 | 50 | "Should be able to set a breakpoint on line 30 and column 10."); |
michael@0 | 51 | |
michael@0 | 52 | gDebugger.gClient.addOneTimeListener("resumed", () => { |
michael@0 | 53 | waitForCaretAndScopes(gPanel, 30).then(() => { |
michael@0 | 54 | // Make sure that we have the right stack frames. |
michael@0 | 55 | is(gFrames.itemCount, 9, |
michael@0 | 56 | "Should have nine frames."); |
michael@0 | 57 | is(gFrames.getItemAtIndex(0).attachment.url.indexOf(".min.js"), -1, |
michael@0 | 58 | "First frame should not be a minified JS frame."); |
michael@0 | 59 | isnot(gFrames.getItemAtIndex(0).attachment.url.indexOf(".js"), -1, |
michael@0 | 60 | "First frame should be a JS frame."); |
michael@0 | 61 | |
michael@0 | 62 | deferred.resolve(); |
michael@0 | 63 | }); |
michael@0 | 64 | |
michael@0 | 65 | // This will cause the breakpoint to be hit, and put us back in the |
michael@0 | 66 | // paused state. |
michael@0 | 67 | gDebuggee.arithmetic(); |
michael@0 | 68 | }); |
michael@0 | 69 | }); |
michael@0 | 70 | |
michael@0 | 71 | return deferred.promise; |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | registerCleanupFunction(function() { |
michael@0 | 75 | gDebuggee = null; |
michael@0 | 76 | gPanel = null; |
michael@0 | 77 | gDebugger = null; |
michael@0 | 78 | gEditor = null; |
michael@0 | 79 | gSources = null; |
michael@0 | 80 | gFrames = null; |
michael@0 | 81 | }); |