diff --git a/browser/devtools/debugger/test/browser_dbg_bug723069_editor-breakpoints.js b/browser/devtools/debugger/test/browser_dbg_bug723069_editor-breakpoints.js index ac6fa0bbecd..405ca729601 100644 --- a/browser/devtools/debugger/test/browser_dbg_bug723069_editor-breakpoints.js +++ b/browser/devtools/debugger/test/browser_dbg_bug723069_editor-breakpoints.js @@ -23,37 +23,44 @@ function test() let SourceEditor = tempScope.SourceEditor; let scriptShown = false; let framesAdded = false; + let resumed = false; + let testStarted = false; debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) { gTab = aTab; gDebuggee = aDebuggee; gPane = aPane; gDebugger = gPane.debuggerWindow; + resumed = true; + gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() { framesAdded = true; - runTest(); + executeSoon(startTest); }); - gDebuggee.firstCall(); + executeSoon(function() { + gDebuggee.firstCall(); + }); }); - window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) { - let url = aEvent.detail.url; - if (url.indexOf("-02.js") != -1) { - scriptShown = true; - window.removeEventListener(aEvent.type, _onEvent); - runTest(); - } - }); - - function runTest() + function onScriptShown(aEvent) { - if (scriptShown && framesAdded) { - Services.tm.currentThread.dispatch({ run: onScriptShown }, 0); + scriptShown = aEvent.detail.url.indexOf("-02.js") != -1; + executeSoon(startTest); + } + + window.addEventListener("Debugger:ScriptShown", onScriptShown); + + function startTest() + { + if (scriptShown && framesAdded && resumed && !testStarted) { + window.removeEventListener("Debugger:ScriptShown", onScriptShown); + testStarted = true; + Services.tm.currentThread.dispatch({ run: performTest }, 0); } } - function onScriptShown() + function performTest() { gScripts = gDebugger.DebuggerView.Scripts; diff --git a/browser/devtools/debugger/test/browser_dbg_bug731394_editor-contextmenu.js b/browser/devtools/debugger/test/browser_dbg_bug731394_editor-contextmenu.js index 385e124cd29..e9b8b9fdbbd 100644 --- a/browser/devtools/debugger/test/browser_dbg_bug731394_editor-contextmenu.js +++ b/browser/devtools/debugger/test/browser_dbg_bug731394_editor-contextmenu.js @@ -21,37 +21,43 @@ function test() let contextMenu = null; let scriptShown = false; let framesAdded = false; + let resumed = false; + let testStarted = false; debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) { gTab = aTab; gDebuggee = aDebuggee; gPane = aPane; gDebugger = gPane.debuggerWindow; + resumed = true; gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() { framesAdded = true; - runTest(); + executeSoon(startTest); + }); + + executeSoon(function() { + gDebuggee.firstCall(); }); - gDebuggee.firstCall(); }); - window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) { - let url = aEvent.detail.url; - if (url.indexOf("-02.js") != -1) { - scriptShown = true; - window.removeEventListener(aEvent.type, _onEvent); - runTest(); - } - }); + function onScriptShown(aEvent) { + scriptShown = aEvent.detail.url.indexOf("-02.js") != -1; + executeSoon(startTest); + } - function runTest() + window.addEventListener("Debugger:ScriptShown", onScriptShown); + + function startTest() { - if (scriptShown && framesAdded) { - Services.tm.currentThread.dispatch({ run: onScriptShown }, 0); + if (scriptShown && framesAdded && resumed && !testStarted) { + testStarted = true; + window.removeEventListener("Debugger:ScriptShown", onScriptShown); + Services.tm.currentThread.dispatch({ run: performTest }, 0); } } - function onScriptShown() + function performTest() { let scripts = gDebugger.DebuggerView.Scripts._scripts; diff --git a/browser/devtools/debugger/test/browser_dbg_script-switching.js b/browser/devtools/debugger/test/browser_dbg_script-switching.js index ee1fba7e70a..a3548c4e89c 100644 --- a/browser/devtools/debugger/test/browser_dbg_script-switching.js +++ b/browser/devtools/debugger/test/browser_dbg_script-switching.js @@ -18,33 +18,39 @@ function test() { let scriptShown = false; let framesAdded = false; + let resumed = false; + let testStarted = false; debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) { gTab = aTab; gDebuggee = aDebuggee; gPane = aPane; gDebugger = gPane.debuggerWindow; + resumed = true; gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() { framesAdded = true; - runTest(); + executeSoon(startTest); }); - gDebuggee.firstCall(); + executeSoon(function() { + gDebuggee.firstCall(); + }); }); - window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) { - let url = aEvent.detail.url; - if (url.indexOf("-02.js") != -1) { - scriptShown = true; - window.removeEventListener(aEvent.type, _onEvent); - runTest(); - } - }); - - function runTest() + function onScriptShown(aEvent) { - if (scriptShown && framesAdded) { + scriptShown = aEvent.detail.url.indexOf("-02.js") != -1; + executeSoon(startTest); + } + + window.addEventListener("Debugger:ScriptShown", onScriptShown); + + function startTest() + { + if (scriptShown && framesAdded && resumed && !testStarted) { + window.removeEventListener("Debugger:ScriptShown", onScriptShown); + testStarted = true; Services.tm.currentThread.dispatch({ run: testScriptsDisplay }, 0); } } @@ -75,8 +81,6 @@ function testScriptsDisplay() { ok(gDebugger.DebuggerView.Scripts.containsLabel( label2), "Second script label is incorrect."); - dump("Debugger editor text:\n" + gDebugger.editor.getText() + "\n"); - ok(gDebugger.editor.getText().search(/debugger/) != -1, "The correct script was loaded initially."); @@ -96,8 +100,6 @@ function testScriptsDisplay() { function testSwitchPaused() { - dump("Debugger editor text:\n" + gDebugger.editor.getText() + "\n"); - ok(gDebugger.editor.getText().search(/debugger/) == -1, "The second script is no longer displayed."); diff --git a/browser/devtools/debugger/test/browser_dbg_update-editor-mode.js b/browser/devtools/debugger/test/browser_dbg_update-editor-mode.js index 972abbb5d04..68b3c67358c 100644 --- a/browser/devtools/debugger/test/browser_dbg_update-editor-mode.js +++ b/browser/devtools/debugger/test/browser_dbg_update-editor-mode.js @@ -22,32 +22,38 @@ function test() { let scriptShown = false; let framesAdded = false; + let testStarted = false; + let resumed = false; debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) { gTab = aTab; gDebuggee = aDebuggee; gPane = aPane; gDebugger = gPane.debuggerWindow; + resumed = true; gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() { framesAdded = true; - runTest(); + executeSoon(startTest); + }); + + executeSoon(function() { + gDebuggee.firstCall(); }); - gDebuggee.firstCall(); }); - window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) { - let url = aEvent.detail.url; - if (url.indexOf("editor-mode") != -1) { - scriptShown = true; - window.removeEventListener(aEvent.type, _onEvent); - runTest(); - } - }); + function onScriptShown(aEvent) { + scriptShown = aEvent.detail.url.indexOf("test-editor-mode") != -1; + executeSoon(startTest); + } - function runTest() + window.addEventListener("Debugger:ScriptShown", onScriptShown); + + function startTest() { - if (scriptShown && framesAdded) { + if (scriptShown && framesAdded && resumed && !testStarted) { + window.removeEventListener("Debugger:ScriptShown", onScriptShown); + testStarted = true; Services.tm.currentThread.dispatch({ run: testScriptsDisplay }, 0); } }