@@ -6,20 +6,39 @@ module.metadata = {
6
6
"stability" : "stable"
7
7
} ;
8
8
9
+ // Add-on SDK
9
10
const options = require ( "@loader/options" ) ;
10
-
11
11
const { Cu, Ci } = require ( "chrome" ) ;
12
- const { Trace, TraceError } = require ( "firebug.sdk/lib/core/trace.js" ) . get ( module . id ) ;
13
12
const { Class } = require ( "sdk/core/heritage" ) ;
13
+ const { defer, resolve } = require ( "sdk/core/promise" ) ;
14
+ const { on, off, emit } = require ( "sdk/event/core" ) ;
15
+
16
+ // DevTools
17
+ const { devtools } = Cu . import ( "resource://gre/modules/devtools/Loader.jsm" , { } ) ;
18
+ const { makeInfallible } = devtools [ "require" ] ( "devtools/toolkit/DevToolsUtils.js" ) ;
19
+
20
+ // Firebug SDK
21
+ const { Trace, TraceError } = require ( "firebug.sdk/lib/core/trace.js" ) . get ( module . id ) ;
14
22
const { Locale } = require ( "firebug.sdk/lib/core/locale.js" ) ;
15
23
const { ToolboxOverlay } = require ( "firebug.sdk/lib/toolbox-overlay.js" ) ;
24
+ const { Rdp } = require ( "firebug.sdk/lib/core/rdp.js" ) ;
25
+
26
+ // FireQuery
27
+ const { FireQueryFront } = require ( "./firequery-front" ) ;
28
+
29
+ // URL of the {@FireQueryActor } module. This module will be
30
+ // installed and loaded on the backend.
31
+ const actorModuleUrl = options . prefixURI + "lib/firequery-actor.js" ;
16
32
17
33
/**
18
34
* @overlay This object represents an overlay for the Toolbox. The
19
35
* overlay is created when the Toolbox is opened and destroyed when
20
36
* the Toolbox is closed. There is one instance of the overlay per
21
37
* Toolbox, and so there can be more overlay instances created per
22
38
* one browser session.
39
+ *
40
+ * FireQuery uses the overlay to register and attach/detach the
41
+ * backend actor.
23
42
*/
24
43
const FireQueryToolboxOverlay = Class (
25
44
/** @lends FireQueryToolboxOverlay */
@@ -41,9 +60,7 @@ const FireQueryToolboxOverlay = Class(
41
60
42
61
Trace . sysout ( "FireQueryToolboxOverlay.destroy;" , arguments ) ;
43
62
44
- if ( this . pixelPerfectPopup ) {
45
- this . pixelPerfectPopup . destroy ( ) ;
46
- }
63
+ this . detach ( ) ;
47
64
} ,
48
65
49
66
// Events
@@ -52,6 +69,64 @@ const FireQueryToolboxOverlay = Class(
52
69
ToolboxOverlay . prototype . onReady . apply ( this , arguments ) ;
53
70
54
71
Trace . sysout ( "FireQueryToolboxOverlay.onReady;" , options ) ;
72
+
73
+ this . attach ( ) ;
74
+ } ,
75
+
76
+ // Backend
77
+
78
+ /**
79
+ * Attach to the backend FireQuery actor.
80
+ */
81
+ attach : makeInfallible ( function ( ) {
82
+ Trace . sysout ( "ConsoleOverlay.attach;" ) ;
83
+
84
+ if ( this . deferredAttach ) {
85
+ return this . deferredAttach . promise ;
86
+ }
87
+
88
+ let config = {
89
+ prefix : FireQueryFront . prototype . typeName ,
90
+ actorClass : "FireQueryActor" ,
91
+ frontClass : FireQueryFront ,
92
+ moduleUrl : actorModuleUrl
93
+ } ;
94
+
95
+ this . deferredAttach = defer ( ) ;
96
+ let client = this . toolbox . target . client ;
97
+
98
+ // Register as tab actor.
99
+ Rdp . registerTabActor ( client , config ) . then ( ( { registrar, front} ) => {
100
+ FBTrace . sysout ( "ConsoleOverlay.attach; READY" , front ) ;
101
+
102
+ this . front = front ;
103
+
104
+ // xxxHonza: Unregister at shutdown
105
+ this . registrar = registrar ;
106
+
107
+ // Emit an event indicating that the attach process is done. This
108
+ // can be used e.g. by tests.
109
+ emit ( this , "attached" , front ) ;
110
+
111
+ // Resolve the 'attach promise'.
112
+ this . deferredAttach . resolve ( front ) ;
113
+ } ) ;
114
+
115
+ return this . deferredAttach . promise ;
116
+ } ) ,
117
+
118
+ detach : makeInfallible ( function ( ) {
119
+ Trace . sysout ( "ConsoleOverlay.detach;" ) ;
120
+
121
+ // xxxHonza: TODO
122
+
123
+ // Emit an event indicating that the attach process is done. This
124
+ // can be used e.g. by tests.
125
+ emit ( this , "attached" , front ) ;
126
+ } ) ,
127
+
128
+ getJQueryFront : function ( ) {
129
+ return this . attach ( ) ;
55
130
} ,
56
131
} ) ;
57
132
0 commit comments