Bug 1050340 - Stop doing a CheckedUnwrap while crawling the object graph in Structured Clone. r=luke

\o/
This commit is contained in:
Bobby Holley 2014-08-18 14:18:40 -07:00
Родитель 24a1e4a8e1
Коммит a434cbc427
2 изменённых файлов: 2 добавлений и 18 удалений

Просмотреть файл

@ -771,13 +771,7 @@ JSStructuredCloneWriter::parseTransferable()
if (!v.isObject())
return reportErrorTransferable();
RootedObject tObj(context(), CheckedUnwrap(&v.toObject()));
if (!tObj) {
JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED);
return false;
}
RootedObject tObj(context(), &v.toObject());
// No duplicates allowed
if (std::find(transferableObjects.begin(), transferableObjects.end(), tObj) != transferableObjects.end()) {
@ -1013,16 +1007,6 @@ JSStructuredCloneWriter::startWrite(HandleValue v)
} else if (v.isObject()) {
RootedObject obj(context(), &v.toObject());
// The object might be a security wrapper. See if we can clone what's
// behind it. If we can, unwrap the object.
obj = CheckedUnwrap(obj);
if (!obj) {
JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED);
return false;
}
AutoCompartment ac(context(), obj);
bool backref;
if (!startObject(obj, &backref))
return false;

Просмотреть файл

@ -183,7 +183,7 @@
Cu.evalInSandbox('function tryToClone(x) { return cloneInto({val: x}, cloneTarget, { wrapReflectors: true }).val; }', sandbox2);
is(Cu.evalInSandbox('tryToClone(soXHR)', sandbox2), sandbox2.soXHR, 'Same-origin wrapReflectors works');
checkThrows(function() { Cu.evalInSandbox('tryToClone(chromeDoc)', sandbox2); },
'wrapReflectors may not wrap cross-origin reflectors', /denied|insecure/);
'wrapReflectors may not wrap cross-origin reflectors', /unsupported value type/);
var test = { a: function() { return 42; } };