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 disabled breakpoints survive target navigation. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; |
michael@0 | 9 | |
michael@0 | 10 | function test() { |
michael@0 | 11 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 12 | let gDebugger = aPanel.panelWin; |
michael@0 | 13 | let gEvents = gDebugger.EVENTS; |
michael@0 | 14 | let gEditor = gDebugger.DebuggerView.editor; |
michael@0 | 15 | let gSources = gDebugger.DebuggerView.Sources; |
michael@0 | 16 | let gBreakpoints = gDebugger.DebuggerController.Breakpoints; |
michael@0 | 17 | let gBreakpointLocation = { url: EXAMPLE_URL + "code_script-switching-01.js", line: 5 }; |
michael@0 | 18 | |
michael@0 | 19 | Task.spawn(function() { |
michael@0 | 20 | yield waitForSourceShown(aPanel, "-01.js"); |
michael@0 | 21 | yield aPanel.addBreakpoint(gBreakpointLocation); |
michael@0 | 22 | |
michael@0 | 23 | yield ensureThreadClientState(aPanel, "resumed"); |
michael@0 | 24 | yield testWhenBreakpointEnabledAndFirstSourceShown(); |
michael@0 | 25 | |
michael@0 | 26 | yield reloadActiveTab(aPanel, gEvents.SOURCE_SHOWN); |
michael@0 | 27 | yield testWhenBreakpointEnabledAndSecondSourceShown(); |
michael@0 | 28 | |
michael@0 | 29 | yield gSources.disableBreakpoint(gBreakpointLocation); |
michael@0 | 30 | yield reloadActiveTab(aPanel, gEvents.SOURCE_SHOWN); |
michael@0 | 31 | yield testWhenBreakpointDisabledAndSecondSourceShown(); |
michael@0 | 32 | |
michael@0 | 33 | yield gSources.enableBreakpoint(gBreakpointLocation); |
michael@0 | 34 | yield reloadActiveTab(aPanel, gEvents.SOURCE_SHOWN); |
michael@0 | 35 | yield testWhenBreakpointEnabledAndSecondSourceShown(); |
michael@0 | 36 | |
michael@0 | 37 | yield resumeDebuggerThenCloseAndFinish(aPanel); |
michael@0 | 38 | }); |
michael@0 | 39 | |
michael@0 | 40 | function verifyView({ disabled, visible }) { |
michael@0 | 41 | return Task.spawn(function() { |
michael@0 | 42 | // It takes a tick for the checkbox in the SideMenuWidget and the |
michael@0 | 43 | // gutter in the editor to get updated. |
michael@0 | 44 | yield waitForTick(); |
michael@0 | 45 | |
michael@0 | 46 | let breakpointItem = gSources.getBreakpoint(gBreakpointLocation); |
michael@0 | 47 | let visibleBreakpoints = gEditor.getBreakpoints(); |
michael@0 | 48 | is(!!breakpointItem.attachment.disabled, disabled, |
michael@0 | 49 | "The selected brekapoint state was correct."); |
michael@0 | 50 | is(breakpointItem.attachment.view.checkbox.hasAttribute("checked"), !disabled, |
michael@0 | 51 | "The selected brekapoint's checkbox state was correct."); |
michael@0 | 52 | |
michael@0 | 53 | // Source editor starts counting line and column numbers from 0. |
michael@0 | 54 | let breakpointLine = breakpointItem.attachment.line - 1; |
michael@0 | 55 | let matchedBreakpoints = visibleBreakpoints.filter(e => e.line == breakpointLine); |
michael@0 | 56 | is(!!matchedBreakpoints.length, visible, |
michael@0 | 57 | "The selected breakpoint's visibility in the editor was correct."); |
michael@0 | 58 | }); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | // All the following executeSoon()'s are required to spin the event loop |
michael@0 | 62 | // before causing the debuggee to pause, to allow functions to yield first. |
michael@0 | 63 | |
michael@0 | 64 | function testWhenBreakpointEnabledAndFirstSourceShown() { |
michael@0 | 65 | return Task.spawn(function() { |
michael@0 | 66 | yield ensureSourceIs(aPanel, "-01.js"); |
michael@0 | 67 | yield verifyView({ disabled: false, visible: true }); |
michael@0 | 68 | |
michael@0 | 69 | executeSoon(() => aDebuggee.firstCall()); |
michael@0 | 70 | yield waitForDebuggerEvents(aPanel, gEvents.FETCHED_SCOPES); |
michael@0 | 71 | yield ensureSourceIs(aPanel, "-01.js"); |
michael@0 | 72 | yield ensureCaretAt(aPanel, 5); |
michael@0 | 73 | yield verifyView({ disabled: false, visible: true }); |
michael@0 | 74 | |
michael@0 | 75 | executeSoon(() => gDebugger.gThreadClient.resume()); |
michael@0 | 76 | yield waitForSourceAndCaretAndScopes(aPanel, "-02.js", 1); |
michael@0 | 77 | yield verifyView({ disabled: false, visible: false }); |
michael@0 | 78 | }); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | function testWhenBreakpointEnabledAndSecondSourceShown() { |
michael@0 | 82 | return Task.spawn(function() { |
michael@0 | 83 | yield ensureSourceIs(aPanel, "-02.js", true); |
michael@0 | 84 | yield verifyView({ disabled: false, visible: false }); |
michael@0 | 85 | |
michael@0 | 86 | executeSoon(() => aDebuggee.firstCall()); |
michael@0 | 87 | yield waitForSourceAndCaretAndScopes(aPanel, "-01.js", 1); |
michael@0 | 88 | yield verifyView({ disabled: false, visible: true }); |
michael@0 | 89 | |
michael@0 | 90 | executeSoon(() => gDebugger.gThreadClient.resume()); |
michael@0 | 91 | yield waitForSourceAndCaretAndScopes(aPanel, "-02.js", 1); |
michael@0 | 92 | yield verifyView({ disabled: false, visible: false }); |
michael@0 | 93 | }); |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | function testWhenBreakpointDisabledAndSecondSourceShown() { |
michael@0 | 97 | return Task.spawn(function() { |
michael@0 | 98 | yield ensureSourceIs(aPanel, "-02.js", true); |
michael@0 | 99 | yield verifyView({ disabled: true, visible: false }); |
michael@0 | 100 | |
michael@0 | 101 | executeSoon(() => aDebuggee.firstCall()); |
michael@0 | 102 | yield waitForDebuggerEvents(aPanel, gEvents.FETCHED_SCOPES); |
michael@0 | 103 | yield ensureSourceIs(aPanel, "-02.js"); |
michael@0 | 104 | yield ensureCaretAt(aPanel, 1); |
michael@0 | 105 | yield verifyView({ disabled: true, visible: false }); |
michael@0 | 106 | |
michael@0 | 107 | executeSoon(() => gDebugger.gThreadClient.resume()); |
michael@0 | 108 | yield waitForDebuggerEvents(aPanel, gEvents.AFTER_FRAMES_CLEARED); |
michael@0 | 109 | yield ensureSourceIs(aPanel, "-02.js"); |
michael@0 | 110 | yield ensureCaretAt(aPanel, 1); |
michael@0 | 111 | yield verifyView({ disabled: true, visible: false }); |
michael@0 | 112 | }); |
michael@0 | 113 | } |
michael@0 | 114 | }); |
michael@0 | 115 | } |