Skip to content

Commit 1152ad7

Browse files
committed
Support for Fx39 and Fx40
1 parent 8e06bee commit 1152ad7

File tree

2 files changed

+61
-14
lines changed

2 files changed

+61
-14
lines changed

data/tooltip-provider.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,28 @@ TooltipProvider.prototype =
5959
hasChildren: function(object) {
6060
if (object instanceof Property) {
6161
var value = this.getValue(object);
62-
return (value && value.type == "object" &&
63-
value.ownPropertyLength > 0);
62+
if (!value) {
63+
return false;
64+
}
65+
66+
var hasChildren = value.ownPropertyLength > 0;
67+
68+
// xxxHonza: Support for Fx40 (grip.ownPropertyLength doesn't exist)
69+
if (value.preview) {
70+
hasChildren = hasChildren || value.preview.ownPropertiesLength > 0;
71+
}
72+
73+
// xxxHonza: Support (rather a workaround) for Fx39
74+
// (grip.preview.ownPropertiesLength doesn't exist)
75+
if (value.preview) {
76+
var preview = value.preview;
77+
var kind = preview.kind;
78+
var objectsWithProps = ["DOMNode", "ObjectWithURL"];
79+
hasChildren = hasChildren || (objectsWithProps.indexOf(kind) != -1);
80+
hasChildren = hasChildren || (kind == "ArrayLike" && preview.length > 0);
81+
}
82+
83+
return (value.type == "object" && hasChildren);
6484
}
6585
},
6686

lib/firequery-toolbox-overlay.js

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,32 +118,59 @@ const FireQueryToolboxOverlay = Class(
118118
return this.deferredAttach.promise;
119119
}),
120120

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+
121131
patchJQuery: function() {
122132
let deferred = defer();
123133

124134
let patch = Http.getResource(JQUERYPATCH);
125135
let watcher = getJQueryWatcherCode();
126-
let console = this.toolbox.target.activeConsole;
127136

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+
});
132151
});
133152
});
134153

135154
return deferred.promise;
136155
},
137156

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;
140161

141-
// xxxHonza: TODO
162+
debuggerClient.attachConsole(consoleActor, ["ConsoleAPI"],
163+
(response, webConsoleClient) => {
142164

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+
},
147174

148175
getJQueryFront: function() {
149176
return this.attach();

0 commit comments

Comments
 (0)