mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 790905 - Replace no-op principal check with something real. r=luke
This would have caught this bug.
This commit is contained in:
parent
501866d7d9
commit
9307d49238
@ -9,6 +9,7 @@
|
|||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
#include "jsscript.h"
|
#include "jsscript.h"
|
||||||
#include "jsstr.h"
|
#include "jsstr.h"
|
||||||
|
#include "jsfriendapi.h"
|
||||||
|
|
||||||
static JSScript *
|
static JSScript *
|
||||||
CompileScriptForPrincipalsVersionOrigin(JSContext *cx, JS::HandleObject obj,
|
CompileScriptForPrincipalsVersionOrigin(JSContext *cx, JS::HandleObject obj,
|
||||||
@ -78,6 +79,7 @@ static JSPrincipals testPrincipals[] = {
|
|||||||
BEGIN_TEST(testXDR_principals)
|
BEGIN_TEST(testXDR_principals)
|
||||||
{
|
{
|
||||||
JSScript *script;
|
JSScript *script;
|
||||||
|
JSCompartment *compartment = js::GetContextCompartment(cx);
|
||||||
for (int i = TEST_FIRST; i != TEST_END; ++i) {
|
for (int i = TEST_FIRST; i != TEST_END; ++i) {
|
||||||
script = createScriptViaXDR(NULL, NULL, i);
|
script = createScriptViaXDR(NULL, NULL, i);
|
||||||
CHECK(script);
|
CHECK(script);
|
||||||
@ -89,6 +91,10 @@ BEGIN_TEST(testXDR_principals)
|
|||||||
CHECK(!JS_GetScriptPrincipals(script));
|
CHECK(!JS_GetScriptPrincipals(script));
|
||||||
CHECK(!JS_GetScriptOriginPrincipals(script));
|
CHECK(!JS_GetScriptOriginPrincipals(script));
|
||||||
|
|
||||||
|
// Appease the new JSAPI assertions. The stuff being tested here is
|
||||||
|
// going away anyway.
|
||||||
|
JSPrincipals *old = JS_GetCompartmentPrincipals(compartment);
|
||||||
|
JS_SetCompartmentPrincipals(compartment, &testPrincipals[0]);
|
||||||
script = createScriptViaXDR(&testPrincipals[0], NULL, i);
|
script = createScriptViaXDR(&testPrincipals[0], NULL, i);
|
||||||
CHECK(script);
|
CHECK(script);
|
||||||
CHECK(JS_GetScriptPrincipals(script) == &testPrincipals[0]);
|
CHECK(JS_GetScriptPrincipals(script) == &testPrincipals[0]);
|
||||||
@ -108,6 +114,7 @@ BEGIN_TEST(testXDR_principals)
|
|||||||
CHECK(script);
|
CHECK(script);
|
||||||
CHECK(!JS_GetScriptPrincipals(script));
|
CHECK(!JS_GetScriptPrincipals(script));
|
||||||
CHECK(JS_GetScriptOriginPrincipals(script) == &testPrincipals[1]);
|
CHECK(JS_GetScriptOriginPrincipals(script) == &testPrincipals[1]);
|
||||||
|
JS_SetCompartmentPrincipals(compartment, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -5173,7 +5173,8 @@ JS::Compile(JSContext *cx, HandleObject obj, CompileOptions options,
|
|||||||
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
|
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
|
||||||
AssertHeapIsIdle(cx);
|
AssertHeapIsIdle(cx);
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
assertSameCompartment(cx, obj, options.principals, options.originPrincipals);
|
assertSameCompartment(cx, obj);
|
||||||
|
JS_ASSERT_IF(options.principals, cx->compartment->principals == options.principals);
|
||||||
AutoLastFrameCheck lfc(cx);
|
AutoLastFrameCheck lfc(cx);
|
||||||
|
|
||||||
return frontend::CompileScript(cx, obj, NULL, options, chars, length);
|
return frontend::CompileScript(cx, obj, NULL, options, chars, length);
|
||||||
@ -5436,7 +5437,8 @@ JS::CompileFunction(JSContext *cx, HandleObject obj, CompileOptions options,
|
|||||||
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
|
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
|
||||||
AssertHeapIsIdle(cx);
|
AssertHeapIsIdle(cx);
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
assertSameCompartment(cx, obj, options.principals, options.originPrincipals);
|
assertSameCompartment(cx, obj);
|
||||||
|
JS_ASSERT_IF(options.principals, cx->compartment->principals == options.principals);
|
||||||
AutoLastFrameCheck lfc(cx);
|
AutoLastFrameCheck lfc(cx);
|
||||||
|
|
||||||
RootedAtom funAtom(cx);
|
RootedAtom funAtom(cx);
|
||||||
@ -5653,7 +5655,9 @@ JS::Evaluate(JSContext *cx, HandleObject obj, CompileOptions options,
|
|||||||
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
|
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
|
||||||
AssertHeapIsIdle(cx);
|
AssertHeapIsIdle(cx);
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
assertSameCompartment(cx, obj, options.principals, options.originPrincipals);
|
assertSameCompartment(cx, obj);
|
||||||
|
JS_ASSERT_IF(options.principals, cx->compartment->principals == options.principals);
|
||||||
|
|
||||||
AutoLastFrameCheck lfc(cx);
|
AutoLastFrameCheck lfc(cx);
|
||||||
|
|
||||||
options.setCompileAndGo(true);
|
options.setCompileAndGo(true);
|
||||||
|
@ -227,8 +227,6 @@ class CompartmentChecker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void check(JSPrincipals *) { /* nothing for now */ }
|
|
||||||
|
|
||||||
void check(JSObject *obj) {
|
void check(JSObject *obj) {
|
||||||
if (obj)
|
if (obj)
|
||||||
check(obj->compartment());
|
check(obj->compartment());
|
||||||
|
Loading…
Reference in New Issue
Block a user