Bug 1065811 - Track Xray waivers with CPOWs. r=billm

This commit is contained in:
Bobby Holley
2014-09-25 13:13:29 +02:00
parent 4088e55174
commit f2b9845ecb
8 changed files with 56 additions and 25 deletions

View File

@@ -10,6 +10,7 @@
#include "mozilla/dom/TabChild.h"
#include "jsfriendapi.h"
#include "xpcprivate.h"
#include "WrapperFactory.h"
#include "mozilla/Preferences.h"
using namespace js;
@@ -186,7 +187,9 @@ JavaScriptShared::init()
return false;
if (!cpows_.init())
return false;
if (!objectIds_.init())
if (!unwaivedObjectIds_.init())
return false;
if (!waivedObjectIds_.init())
return false;
return true;
@@ -383,7 +386,7 @@ JavaScriptShared::ConvertID(const JSIID &from, nsID *to)
JSObject *
JavaScriptShared::findObjectById(JSContext *cx, const ObjectId &objId)
{
RootedObject obj(cx, findObjectById(objId));
RootedObject obj(cx, objects_.find(objId));
if (!obj) {
JS_ReportError(cx, "operation not possible on dead CPOW");
return nullptr;
@@ -394,8 +397,13 @@ JavaScriptShared::findObjectById(JSContext *cx, const ObjectId &objId)
// can access objects in other compartments using cross-compartment
// wrappers.
JSAutoCompartment ac(cx, scopeForTargetObjects());
if (!JS_WrapObject(cx, &obj))
return nullptr;
if (objId.hasXrayWaiver()) {
if (!xpc::WrapperFactory::WaiveXrayAndWrap(cx, &obj))
return nullptr;
} else {
if (!JS_WrapObject(cx, &obj))
return nullptr;
}
return obj;
}