Bug 1382833 - Don't throw when dealing with CPOWs in the Object Actor;r=jimb

MozReview-Commit-ID: CaIS2IpaQme

--HG--
extra : rebase_source : 75b4fe1abd460978039d7f1085d56e64b9dd2765
This commit is contained in:
Brian Grinstead 2017-07-26 11:22:56 -07:00
parent 23bebfb386
commit 46cc553a7c
3 changed files with 40 additions and 5 deletions

View File

@ -91,13 +91,25 @@ ObjectActor.prototype = {
g.proxyTarget = this.hooks.createValueGrip(this.obj.proxyTarget);
g.proxyHandler = this.hooks.createValueGrip(this.obj.proxyHandler);
} else {
g.class = this.obj.class;
g.extensible = this.obj.isExtensible();
g.frozen = this.obj.isFrozen();
g.sealed = this.obj.isSealed();
try {
g.class = this.obj.class;
g.extensible = this.obj.isExtensible();
g.frozen = this.obj.isFrozen();
g.sealed = this.obj.isSealed();
} catch (e) {
// Handle cases where the underlying object's calls to isExtensible, etc throw.
// This is possible with ProxyObjects like CPOWs. Note these are different from
// scripted Proxies created via `new Proxy`, which match this.obj.isProxy above.
}
}
if (g.class != "DeadObject") {
// Changing the class so that CPOWs will be visible in the UI
let isCPOW = DevToolsUtils.isCPOW(this.obj);
if (isCPOW) {
g.class = "CPOW: " + g.class;
}
if (g.class != "DeadObject" && !isCPOW) {
if (g.class == "Promise") {
g.promiseState = this._createPromiseState();
}

View File

@ -28,6 +28,21 @@ for (let key of Object.keys(ThreadSafeDevToolsUtils)) {
exports[key] = ThreadSafeDevToolsUtils[key];
}
/**
* Helper for Cu.isCrossProcessWrapper that works with Debugger.Objects.
* This will always return false in workers (see the implementation in
* ThreadSafeDevToolsUtils.js).
*
* @param Debugger.Object debuggerObject
* @return bool
*/
exports.isCPOW = function (debuggerObject) {
try {
return Cu.isCrossProcessWrapper(debuggerObject.unsafeDereference());
} catch (e) { }
return false;
};
/**
* Waits for the next tick in the event loop to execute a callback.
*/

View File

@ -69,6 +69,14 @@ exports.values = function values(object) {
return Object.keys(object).map(k => object[k]);
};
/**
* This is overridden in DevToolsUtils for the main thread, where we have the
* Cu object available.
*/
exports.isCPOW = function () {
return false;
};
/**
* Report that |who| threw an exception, |exception|.
*/