mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 893858 - More testing for CPOWs and fix some small bugs. r=dvander
This commit is contained in:
parent
8e3e74bfea
commit
8b2781aaba
@ -27,8 +27,15 @@ function make_object()
|
|||||||
o.b = true;
|
o.b = true;
|
||||||
o.s = "hello";
|
o.s = "hello";
|
||||||
o.x = { i: 10 };
|
o.x = { i: 10 };
|
||||||
o.f = function () { return 99; }
|
o.f = function () { return 99; };
|
||||||
|
|
||||||
|
// Doing anything with this Proxy will throw.
|
||||||
|
var throwing = new Proxy({}, new Proxy({}, {
|
||||||
|
get: function (trap) { throw trap; }
|
||||||
|
}));
|
||||||
|
|
||||||
return { "data": o,
|
return { "data": o,
|
||||||
|
"throwing": throwing,
|
||||||
"document": content.document
|
"document": content.document
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,39 @@
|
|||||||
ok(data.b === false, "boolean property");
|
ok(data.b === false, "boolean property");
|
||||||
ok(data.s === "bye", "string property");
|
ok(data.s === "bye", "string property");
|
||||||
ok(data.x === null, "nested property");
|
ok(data.x === null, "nested property");
|
||||||
|
|
||||||
|
let throwing = message.objects.throwing;
|
||||||
|
// Based on the table on:
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
|
||||||
|
let tests = [
|
||||||
|
() => Object.getOwnPropertyDescriptor(throwing, 'test'),
|
||||||
|
() => Object.getOwnPropertyNames(throwing),
|
||||||
|
() => Object.defineProperty(throwing, 'test', {value: 1}),
|
||||||
|
() => delete throwing.test,
|
||||||
|
() => "test" in throwing,
|
||||||
|
() => Object.prototype.hasOwnProperty.call(throwing, 'test'),
|
||||||
|
() => throwing.test,
|
||||||
|
() => { throwing.test = 1 },
|
||||||
|
// () => { for (let prop in throwing) {} }, Bug 783829
|
||||||
|
() => { for (let prop of throwing) {} },
|
||||||
|
() => Object.keys(throwing),
|
||||||
|
() => Function.prototype.call.call(throwing),
|
||||||
|
() => new throwing,
|
||||||
|
() => Object.preventExtensions(throwing),
|
||||||
|
() => Object.freeze(throwing),
|
||||||
|
() => Object.seal(throwing),
|
||||||
|
]
|
||||||
|
|
||||||
|
for (let test of tests) {
|
||||||
|
let threw = false;
|
||||||
|
try {
|
||||||
|
test()
|
||||||
|
} catch (e) {
|
||||||
|
threw = true;
|
||||||
|
}
|
||||||
|
ok(threw, "proxy operation threw exception");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function recvAsyncMessage(message) {
|
function recvAsyncMessage(message) {
|
||||||
@ -57,7 +90,7 @@
|
|||||||
run_tests("inprocess");
|
run_tests("inprocess");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,6 +271,8 @@ JavaScriptChild::AnswerDelete(const ObjectId &objId, const nsString &id, ReturnS
|
|||||||
AutoSafeJSContext cx;
|
AutoSafeJSContext cx;
|
||||||
JSAutoRequest request(cx);
|
JSAutoRequest request(cx);
|
||||||
|
|
||||||
|
*success = false;
|
||||||
|
|
||||||
RootedObject obj(cx, findObject(objId));
|
RootedObject obj(cx, findObject(objId));
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return false;
|
return false;
|
||||||
@ -299,6 +301,8 @@ JavaScriptChild::AnswerHas(const ObjectId &objId, const nsString &id, ReturnStat
|
|||||||
AutoSafeJSContext cx;
|
AutoSafeJSContext cx;
|
||||||
JSAutoRequest request(cx);
|
JSAutoRequest request(cx);
|
||||||
|
|
||||||
|
*bp = false;
|
||||||
|
|
||||||
RootedObject obj(cx, findObject(objId));
|
RootedObject obj(cx, findObject(objId));
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return false;
|
return false;
|
||||||
@ -323,6 +327,8 @@ JavaScriptChild::AnswerHasOwn(const ObjectId &objId, const nsString &id, ReturnS
|
|||||||
AutoSafeJSContext cx;
|
AutoSafeJSContext cx;
|
||||||
JSAutoRequest request(cx);
|
JSAutoRequest request(cx);
|
||||||
|
|
||||||
|
*bp = false;
|
||||||
|
|
||||||
RootedObject obj(cx, findObject(objId));
|
RootedObject obj(cx, findObject(objId));
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return false;
|
return false;
|
||||||
@ -434,7 +440,7 @@ JavaScriptChild::AnswerIsExtensible(const ObjectId &objId, ReturnStatus *rs, boo
|
|||||||
return fail(cx, rs);
|
return fail(cx, rs);
|
||||||
|
|
||||||
*result = !!extensible;
|
*result = !!extensible;
|
||||||
return true;
|
return ok(rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -548,7 +554,6 @@ JavaScriptChild::AnswerObjectClassIs(const ObjectId &objId, const uint32_t &clas
|
|||||||
JSAutoCompartment comp(cx, obj);
|
JSAutoCompartment comp(cx, obj);
|
||||||
|
|
||||||
*result = js_ObjectClassIs(cx, obj, (js::ESClassValue)classValue);
|
*result = js_ObjectClassIs(cx, obj, (js::ESClassValue)classValue);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,7 +593,7 @@ JavaScriptChild::AnswerGetPropertyNames(const ObjectId &objId, const uint32_t &f
|
|||||||
for (size_t i = 0; i < props.length(); i++) {
|
for (size_t i = 0; i < props.length(); i++) {
|
||||||
nsString name;
|
nsString name;
|
||||||
if (!convertIdToGeckoString(cx, props.handleAt(i), &name))
|
if (!convertIdToGeckoString(cx, props.handleAt(i), &name))
|
||||||
return false;
|
return fail(cx, rs);
|
||||||
|
|
||||||
names->AppendElement(name);
|
names->AppendElement(name);
|
||||||
}
|
}
|
||||||
@ -603,6 +608,8 @@ JavaScriptChild::AnswerInstanceOf(const ObjectId &objId, const JSIID &iid, Retur
|
|||||||
AutoSafeJSContext cx;
|
AutoSafeJSContext cx;
|
||||||
JSAutoRequest request(cx);
|
JSAutoRequest request(cx);
|
||||||
|
|
||||||
|
*instanceof = false;
|
||||||
|
|
||||||
RootedObject obj(cx, findObject(objId));
|
RootedObject obj(cx, findObject(objId));
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return false;
|
return false;
|
||||||
|
@ -7212,12 +7212,11 @@ JS_GetScriptedGlobal(JSContext *cx)
|
|||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
JS_PreventExtensions(JSContext *cx, JS::HandleObject obj)
|
JS_PreventExtensions(JSContext *cx, JS::HandleObject obj)
|
||||||
{
|
{
|
||||||
JSBool extensible;
|
bool extensible;
|
||||||
if (!JS_IsExtensible(cx, obj, &extensible))
|
if (!JSObject::isExtensible(cx, obj, &extensible))
|
||||||
return JS_TRUE;
|
return false;
|
||||||
if (extensible)
|
if (!extensible)
|
||||||
return JS_TRUE;
|
return true;
|
||||||
|
|
||||||
return JSObject::preventExtensions(cx, obj);
|
return JSObject::preventExtensions(cx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user