@@ -118,32 +118,59 @@ const FireQueryToolboxOverlay = Class(
118
118
return this . deferredAttach . promise ;
119
119
} ) ,
120
120
121
+ detach : makeInfallible ( function ( ) {
122
+ Trace . sysout ( "FireQueryToolboxOverlay.detach;" ) ;
123
+
124
+ // xxxHonza: TODO
125
+
126
+ // Emit an event indicating that the detach process is done. This
127
+ // can be used e.g. by tests.
128
+ emit ( this , "detach" ) ;
129
+ } ) ,
130
+
121
131
patchJQuery : function ( ) {
122
132
let deferred = defer ( ) ;
123
133
124
134
let patch = Http . getResource ( JQUERYPATCH ) ;
125
135
let watcher = getJQueryWatcherCode ( ) ;
126
- let console = this . toolbox . target . activeConsole ;
127
136
128
- this . toolbox . initInspector ( ) . then ( ( ) => {
129
- let walker = this . toolbox . walker ;
130
- this . front . patchJQuery ( patch , watcher , walker , console ) . then ( ( ) => {
131
- deferred . resolve ( ) ;
137
+ // xxxHonza: activeConsole object has been introduced in Fx40
138
+ // It should be used instead of the tedious asynchronous
139
+ // process as soon as Fx40 is the minimum required version.
140
+ // We still need to call initInspector to get the walker though.
141
+ // let console = this.toolbox.target.activeConsole;
142
+ let target = this . toolbox . target ;
143
+ target . activeTab . attachThread ( { } , ( response , thread ) => {
144
+ this . attachConsole ( thread ) . then ( console => {
145
+ this . toolbox . initInspector ( ) . then ( ( ) => {
146
+ let walker = this . toolbox . walker ;
147
+ this . front . patchJQuery ( patch , watcher , walker , console ) . then ( ( ) => {
148
+ deferred . resolve ( ) ;
149
+ } ) ;
150
+ } ) ;
132
151
} ) ;
133
152
} ) ;
134
153
135
154
return deferred . promise ;
136
155
} ,
137
156
138
- detach : makeInfallible ( function ( ) {
139
- Trace . sysout ( "FireQueryToolboxOverlay.detach;" ) ;
157
+ attachConsole : function ( threadClient ) {
158
+ let deferred = defer ( ) ;
159
+ let debuggerClient = threadClient . client ;
160
+ let consoleActor = this . toolbox . target . form . consoleActor ;
140
161
141
- // xxxHonza: TODO
162
+ debuggerClient . attachConsole ( consoleActor , [ "ConsoleAPI" ] ,
163
+ ( response , webConsoleClient ) => {
142
164
143
- // Emit an event indicating that the detach process is done. This
144
- // can be used e.g. by tests.
145
- emit ( this , "detach" ) ;
146
- } ) ,
165
+ if ( response . error ) {
166
+ deferred . reject ( response ) ;
167
+ } else {
168
+ deferred . resolve ( webConsoleClient ) ;
169
+ }
170
+ } ) ;
171
+
172
+ return deferred . promise ;
173
+ } ,
147
174
148
175
getJQueryFront : function ( ) {
149
176
return this . attach ( ) ;
0 commit comments