Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Enabling the Console panel needs to wait for backend connection (to t…
…he thread actor)
- Loading branch information
1 parent
b51e916
commit a7725b9
Showing
1 changed file
with
79 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -998,73 +998,9 @@ this.disableScriptPanel = function(callback) | |
*/ | ||
this.enableScriptPanel = function(callback) | ||
{ | ||
// Wait till the debugger is attached to the current thread (async) | ||
function onCallback(win) | ||
{ | ||
var context = FW.Firebug.currentContext; | ||
if (!context) | ||
{ | ||
FBTest.ok(context, "There is no current context!" + context); | ||
return; | ||
} | ||
|
||
FBTest.sysout("enableScriptPanel.window loaded: " + win.location.href); | ||
|
||
var listener; | ||
|
||
// If the thread is already attached just execute the callback. | ||
if (context.activeThread) | ||
{ | ||
FBTest.sysout("enableScriptPanel.thread-actor already attached " + | ||
context.activeThread.paused, context.activeThread); | ||
|
||
// xxxHonza: hack, why the ThreadClient isn't paused too? | ||
var actor = FW.Firebug.DebuggerLib.getThreadActor(context.browser); | ||
var state = actor ? actor._state : "no tab actor"; | ||
FBTest.sysout("enableScriptPanel; actor: " + state); | ||
|
||
if (state == "paused") | ||
{ | ||
listener = | ||
{ | ||
onResumed: function() | ||
{ | ||
FBTest.sysout("enableScriptPanel.onResumed;"); | ||
DebuggerController.removeListener(listener); | ||
|
||
if (callback) | ||
callback(win); | ||
} | ||
}; | ||
} | ||
else | ||
{ | ||
if (callback) | ||
callback(win); | ||
return; | ||
} | ||
} | ||
else | ||
{ | ||
// Listener for 'onThreadAttached' event | ||
listener = | ||
{ | ||
onThreadAttached: function() | ||
{ | ||
FBTest.sysout("enableScriptPanel.onThreadAttached;"); | ||
DebuggerController.removeListener(listener); | ||
|
||
if (callback) | ||
callback(win); | ||
} | ||
}; | ||
} | ||
|
||
// Wait till the context is attached to the thread. | ||
if (listener) | ||
DebuggerController.addListener(listener); | ||
|
||
FBTest.sysout("enableScriptPanel.add debugger listener; " + listener); | ||
waitForDebuggerAttach(win, callback); | ||
} | ||
|
||
var cb = callback ? onCallback : null; | ||
|
@@ -1086,7 +1022,13 @@ this.disableConsolePanel = function(callback) | |
*/ | ||
this.enableConsolePanel = function(callback) | ||
{ | ||
this.setPanelState(FW.Firebug.Console, "console", callback, true); | ||
function onCallback(win) | ||
{ | ||
waitForDebuggerAttach(win, callback); | ||
} | ||
|
||
var cb = callback ? onCallback : null; | ||
this.setPanelState(FW.Firebug.Console, "console", cb, true); | ||
}; | ||
|
||
/** | ||
|
@@ -3082,5 +3024,76 @@ this.isMac = function() | |
return (hiddenWindow.navigator.platform.indexOf("Mac") >= 0); | ||
} | ||
|
||
// ********************************************************************************************* // | ||
// JSD2 | ||
|
||
function waitForDebuggerAttach(win, callback) | ||
{ | ||
var context = FW.Firebug.currentContext; | ||
if (!context) | ||
{ | ||
FBTest.ok(context, "There is no current context!" + context); | ||
return; | ||
} | ||
|
||
FBTest.sysout("waitForDebuggerAttach.window loaded: " + win.location.href); | ||
|
||
var listener; | ||
|
||
// If the thread is already attached just execute the callback. | ||
if (context.activeThread) | ||
{ | ||
FBTest.sysout("waitForDebuggerAttach.thread-actor already attached " + | ||
context.activeThread.paused, context.activeThread); | ||
|
||
// xxxHonza: hack, why the ThreadClient isn't paused too? | ||
var actor = FW.Firebug.DebuggerLib.getThreadActor(context.browser); | ||
var state = actor ? actor._state : "no tab actor"; | ||
FBTest.sysout("waitForDebuggerAttach; actor: " + state); | ||
|
||
if (state == "paused") | ||
{ | ||
listener = | ||
{ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
janodvarko
Author
Member
|
||
onResumed: function() | ||
{ | ||
FBTest.sysout("waitForDebuggerAttach.onResumed;"); | ||
DebuggerController.removeListener(listener); | ||
|
||
if (callback) | ||
callback(win); | ||
} | ||
}; | ||
} | ||
else | ||
{ | ||
if (callback) | ||
callback(win); | ||
return; | ||
} | ||
} | ||
else | ||
{ | ||
// Listener for 'onThreadAttached' event | ||
listener = | ||
{ | ||
onThreadAttached: function() | ||
{ | ||
FBTest.sysout("waitForDebuggerAttach.onThreadAttached;"); | ||
DebuggerController.removeListener(listener); | ||
|
||
if (callback) | ||
callback(win); | ||
} | ||
}; | ||
} | ||
|
||
// Wait till the context is attached to the thread. | ||
if (listener) | ||
DebuggerController.addListener(listener); | ||
|
||
FBTest.sysout("waitForDebuggerAttach.add debugger listener; " + listener); | ||
} | ||
|
||
// ********************************************************************************************* // | ||
}).apply(FBTest); |
Are you sure about
onResume
? DebuggerClient doesn't seem to raise such an event.Florent