Bug 728926 - Intermittent failure in browser_dbg_script-switching.js | The correct script was loaded initially. | The first script is displayed. r=rcampbell

This commit is contained in:
Mihai Sucan 2012-04-05 16:00:05 +03:00
Родитель 0987eca51d
Коммит 5844d7a3bc
1 изменённых файлов: 62 добавлений и 42 удалений

Просмотреть файл

@ -20,19 +20,41 @@ var gScripts = null;
function test()
{
let scriptShown = false;
let framesAdded = false;
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
gTab = aTab;
gDebuggee = aDebuggee;
gPane = aPane;
gDebugger = gPane.debuggerWindow;
testScriptsDisplay();
gPane.activeThread.addOneTimeListener("framesadded", function() {
framesAdded = true;
runTest();
});
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()
{
if (scriptShown && framesAdded) {
Services.tm.currentThread.dispatch({ run: testScriptsDisplay }, 0);
}
}
}
function testScriptsDisplay() {
gPane.activeThread.addOneTimeListener("framesadded", function() {
Services.tm.currentThread.dispatch({ run: function() {
gScripts = gDebugger.DebuggerView.Scripts._scripts;
is(gDebugger.StackFrames.activeThread.state, "paused",
@ -57,25 +79,21 @@ function testScriptsDisplay() {
ok(gDebugger.DebuggerView.Scripts.containsLabel(
label2), "Second script label is incorrect.");
ok(gDebugger.editor.getText().search(/debugger/) != -1,
"The correct script was loaded initially.");
is(gDebugger.editor.getDebugLocation(), 5,
"editor debugger location is correct.");
gDebugger.editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
function onChange() {
gDebugger.editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
onChange);
window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
let url = aEvent.detail.url;
if (url.indexOf("-01.js") != -1) {
window.removeEventListener(aEvent.type, _onEvent);
testSwitchPaused();
});
gScripts.selectedIndex = 0;
gDebugger.SourceScripts.onChange({ target: gScripts });
}}, 0);
}
});
gDebuggee.firstCall();
gDebugger.DebuggerView.Scripts.selectScript(EXAMPLE_URL + label1);
}
function testSwitchPaused()
@ -90,14 +108,16 @@ function testSwitchPaused()
"editor debugger location has been cleared.");
gDebugger.StackFrames.activeThread.resume(function() {
gDebugger.editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
function onSecondChange() {
gDebugger.editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
onSecondChange);
window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
let url = aEvent.detail.url;
if (url.indexOf("-02.js") != -1) {
window.removeEventListener(aEvent.type, _onEvent);
testSwitchRunning();
}
});
gScripts.selectedIndex = 1;
gDebugger.SourceScripts.onChange({ target: gScripts });
gDebugger.DebuggerView.Scripts.selectScript(EXAMPLE_URL +
"test-script-switching-02.js");
});
}