diff --git a/browser/devtools/debugger/test/browser_dbg_location-changes-blank.js b/browser/devtools/debugger/test/browser_dbg_location-changes-blank.js index 000e47c902ed..b631cac16398 100644 --- a/browser/devtools/debugger/test/browser_dbg_location-changes-blank.js +++ b/browser/devtools/debugger/test/browser_dbg_location-changes-blank.js @@ -13,43 +13,61 @@ var gDebugger = null; function test() { + let scriptShown = false; + let framesAdded = false; + debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) { gTab = aTab; gDebuggee = aDebuggee; gPane = aPane; gDebugger = gPane.contentWindow; - testSimpleCall(); + gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() { + framesAdded = true; + runTest(); + }); + + gDebuggee.simpleCall(); }); + + window.addEventListener("Debugger:SourceShown", function _onEvent(aEvent) { + let url = aEvent.detail.url; + if (url.indexOf("browser_dbg_stack") != -1) { + scriptShown = true; + window.removeEventListener(aEvent.type, _onEvent); + runTest(); + } + }); + + function runTest() + { + if (scriptShown && framesAdded) { + Services.tm.currentThread.dispatch({ run: testSimpleCall }, 0); + } + } } function testSimpleCall() { - gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() { - Services.tm.currentThread.dispatch({ - run: function() { - var frames = gDebugger.DebuggerView.StackFrames._container._list, - childNodes = frames.childNodes; + var frames = gDebugger.DebuggerView.StackFrames._container._list, + childNodes = frames.childNodes; - is(gDebugger.DebuggerController.activeThread.state, "paused", - "Should only be getting stack frames while paused."); + is(gDebugger.DebuggerController.activeThread.state, "paused", + "Should only be getting stack frames while paused."); - is(frames.querySelectorAll(".dbg-stackframe").length, 1, - "Should have only one frame."); + is(frames.querySelectorAll(".dbg-stackframe").length, 1, + "Should have only one frame."); - is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length, - "All children should be frames."); + is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length, + "All children should be frames."); - isnot(gDebugger.DebuggerView.Sources.selectedValue, null, - "There should be a selected script."); - isnot(gDebugger.editor.getText().length, 0, - "The source editor should have some text displayed."); + isnot(gDebugger.DebuggerView.Sources.selectedValue, null, + "There should be a selected script."); + isnot(gDebugger.editor.getText().length, 0, + "The source editor should have some text displayed."); + isnot(gDebugger.editor.getText(), gDebugger.L10N.getStr("loadingText"), + "The source editor text should not be 'Loading...'"); - testLocationChange(); - } - }, 0); - }); - - gDebuggee.simpleCall(); + testLocationChange(); } function testLocationChange() diff --git a/browser/devtools/debugger/test/browser_dbg_location-changes-new.js b/browser/devtools/debugger/test/browser_dbg_location-changes-new.js index 9609a90330a8..cfad4119c06b 100644 --- a/browser/devtools/debugger/test/browser_dbg_location-changes-new.js +++ b/browser/devtools/debugger/test/browser_dbg_location-changes-new.js @@ -13,43 +13,61 @@ var gDebugger = null; function test() { + let scriptShown = false; + let framesAdded = false; + debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) { gTab = aTab; gDebuggee = aDebuggee; gPane = aPane; gDebugger = gPane.contentWindow; - testSimpleCall(); + gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() { + framesAdded = true; + runTest(); + }); + + gDebuggee.simpleCall(); }); + + window.addEventListener("Debugger:SourceShown", function _onEvent(aEvent) { + let url = aEvent.detail.url; + if (url.indexOf("browser_dbg_stack") != -1) { + scriptShown = true; + window.removeEventListener(aEvent.type, _onEvent); + runTest(); + } + }); + + function runTest() + { + if (scriptShown && framesAdded) { + Services.tm.currentThread.dispatch({ run: testSimpleCall }, 0); + } + } } function testSimpleCall() { - gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() { - Services.tm.currentThread.dispatch({ - run: function() { - var frames = gDebugger.DebuggerView.StackFrames._container._list, - childNodes = frames.childNodes; + var frames = gDebugger.DebuggerView.StackFrames._container._list, + childNodes = frames.childNodes; - is(gDebugger.DebuggerController.activeThread.state, "paused", - "Should only be getting stack frames while paused."); + is(gDebugger.DebuggerController.activeThread.state, "paused", + "Should only be getting stack frames while paused."); - is(frames.querySelectorAll(".dbg-stackframe").length, 1, - "Should have only one frame."); + is(frames.querySelectorAll(".dbg-stackframe").length, 1, + "Should have only one frame."); - is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length, - "All children should be frames."); + is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length, + "All children should be frames."); - isnot(gDebugger.DebuggerView.Sources.selectedValue, null, - "There should be a selected script."); - isnot(gDebugger.editor.getText().length, 0, - "The source editor should have some text displayed."); + isnot(gDebugger.DebuggerView.Sources.selectedValue, null, + "There should be a selected script."); + isnot(gDebugger.editor.getText().length, 0, + "The source editor should have some text displayed."); + isnot(gDebugger.editor.getText(), gDebugger.L10N.getStr("loadingText"), + "The source editor text should not be 'Loading...'"); - testLocationChange(); - } - }, 0); - }); - - gDebuggee.simpleCall(); + testLocationChange(); } function testLocationChange()