Merge birch and m-i to m-c

This commit is contained in:
Phil Ringnalda 2013-06-29 17:29:09 -07:00
commit 037248754c
52 changed files with 177 additions and 561 deletions

View File

@ -17,4 +17,4 @@
#
# Modifying this file will now automatically clobber the buildbot machines \o/
#
Bug 874669 - Remove legacy event type constants
Bug 880917 needs a clobber for the removal of testVersion.cpp

View File

@ -1114,7 +1114,6 @@ nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope,
nsContentUtils::GetSecurityManager()->GetSystemPrincipal(getter_AddRefs(mPrincipal));
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_PRIVATE_IS_NSISUPPORTS);
JS_SetVersion(cx, JSVERSION_LATEST);
JS_SetErrorReporter(cx, ContentScriptErrorReporter);
nsIXPConnect* xpc = nsContentUtils::XPConnect();
@ -1123,9 +1122,12 @@ nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope,
JS_SetContextPrivate(cx, aScope);
JS::CompartmentOptions options;
options.setZone(JS::SystemZone)
.setVersion(JSVERSION_LATEST);
nsresult rv =
xpc->InitClassesWithNewWrappedGlobal(cx, aScope, mPrincipal,
flags, JS::SystemZone, getter_AddRefs(mGlobal));
flags, options, getter_AddRefs(mGlobal));
NS_ENSURE_SUCCESS(rv, false);

View File

@ -188,7 +188,7 @@ ConvolverNode::SetBuffer(JSContext* aCx, AudioBuffer* aBuffer, ErrorResult& aRv)
uint32_t length = mBuffer->Length();
nsRefPtr<ThreadSharedFloatArrayBufferList> data =
mBuffer->GetThreadSharedChannelsForRate(aCx);
if (length < WEBAUDIO_BLOCK_SIZE) {
if (data && length < WEBAUDIO_BLOCK_SIZE) {
// For very small impulse response buffers, we need to pad the
// buffer with 0 to make sure that the Reverb implementation
// has enough data to compute FFTs from.

View File

@ -284,9 +284,11 @@ nsXBLDocGlobalObject::EnsureScriptEnvironment()
// why - see bug 339647)
JS_SetErrorReporter(cx, XBL_ProtoErrorReporter);
JS::CompartmentOptions options;
options.setZone(JS::SystemZone);
mJSObject = JS_NewGlobalObject(cx, &gSharedGlobalClass,
nsJSPrincipals::get(GetPrincipal()),
JS::SystemZone);
options);
if (!mJSObject)
return NS_OK;

View File

@ -21,27 +21,6 @@
using namespace mozilla;
// Checks that the version is not modified in a given scope.
class AutoVersionChecker
{
DebugOnly<JSContext *> const cx;
DebugOnly<JSVersion> versionBefore;
public:
explicit AutoVersionChecker(JSContext *aCx) : cx(aCx) {
#ifdef DEBUG
versionBefore = JS_GetVersion(cx);
#endif
}
~AutoVersionChecker() {
#ifdef DEBUG
JSVersion versionAfter = JS_GetVersion(cx);
NS_ABORT_IF_FALSE(versionAfter == versionBefore, "version must not change");
#endif
}
};
nsresult
nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
nsXBLBinding* aBinding)
@ -90,7 +69,6 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
AutoPushJSContext cx(context->GetNativeContext());
JSAutoCompartment ac(cx, targetClassObject);
AutoVersionChecker avc(cx);
// Walk our member list and install each one in turn.
for (nsXBLProtoImplMember* curr = mMembers;
@ -230,8 +208,6 @@ nsXBLProtoImpl::CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding)
MOZ_ASSERT(classObject);
mClassObject = classObject;
AutoVersionChecker avc(cx);
// Now that we have a class object installed, we walk our member list and compile each of our
// properties and methods in turn.
for (nsXBLProtoImplMember* curr = mMembers;
@ -300,7 +276,6 @@ nsXBLProtoImpl::FindField(const nsString& aFieldName) const
bool
nsXBLProtoImpl::ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const
{
AutoVersionChecker avc(cx);
for (nsXBLProtoImplField* f = mFields; f; f = f->GetNext()) {
// Using OBJ_LOOKUP_PROPERTY is a pain, since what we have is a
// PRUnichar* for the property name. Let's just use the public API and

View File

@ -762,9 +762,11 @@ nsXULPDGlobalObject::EnsureScriptEnvironment()
// will re-fetch the global and set it up in our language globals array.
{
AutoPushJSContext cx(ctxNew->GetNativeContext());
JS::CompartmentOptions options;
options.setZone(JS::SystemZone);
JS::Rooted<JSObject*> newGlob(cx,
JS_NewGlobalObject(cx, &gSharedGlobalClass,
nsJSPrincipals::get(GetPrincipal()), JS::SystemZone));
nsJSPrincipals::get(GetPrincipal()), options));
if (!newGlob)
return NS_OK;

View File

@ -2123,10 +2123,10 @@ CreateNativeGlobalForInner(JSContext* aCx,
if (aNewInner->GetOuterWindow()) {
top = aNewInner->GetTop();
}
JS::ZoneSpecifier zoneSpec = JS::FreshZone;
JS::CompartmentOptions options;
if (top) {
if (top->GetGlobalJSObject()) {
zoneSpec = JS::SameZoneAs(top->GetGlobalJSObject());
options.zoneSpec = JS::SameZoneAs(top->GetGlobalJSObject());
}
}
@ -2142,7 +2142,7 @@ CreateNativeGlobalForInner(JSContext* aCx,
nsRefPtr<nsIXPConnectJSObjectHolder> jsholder;
nsresult rv = xpc->InitClassesWithNewWrappedGlobal(
aCx, ToSupports(aNewInner),
aPrincipal, flags, zoneSpec, getter_AddRefs(jsholder));
aPrincipal, flags, options, getter_AddRefs(jsholder));
NS_ENSURE_SUCCESS(rv, rv);
MOZ_ASSERT(jsholder);

View File

@ -829,10 +829,6 @@ CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate)
JS_SetGCZeal(workerCx, settings.gcZeal, settings.gcZealFrequency);
#endif
if (aWorkerPrivate->IsChromeWorker()) {
JS_SetVersion(workerCx, JSVERSION_LATEST);
}
return workerCx;
}

View File

@ -973,9 +973,12 @@ CreateDedicatedWorkerGlobalScope(JSContext* aCx)
WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
JS_ASSERT(worker);
JS::CompartmentOptions options;
if (worker->IsChromeWorker())
options.setVersion(JSVERSION_LATEST);
JS::Rooted<JSObject*> global(aCx,
JS_NewGlobalObject(aCx, DedicatedWorkerGlobalScope::Class(),
GetWorkerPrincipal()));
GetWorkerPrincipal(), options));
if (!global) {
return NULL;
}

View File

@ -147,8 +147,8 @@ public:
private:
TemporaryRef<ID2D1Bitmap>
DrawTargetD2D::GetBitmapForSurface(SourceSurface *aSurface,
Rect &aSource);
GetBitmapForSurface(SourceSurface *aSurface,
Rect &aSource);
friend class AutoSaveRestoreClippedOut;
friend class SourceSurfaceD2DTarget;

View File

@ -264,12 +264,13 @@ HRESULT
RadialGradientEffectD2D1::Register(ID2D1Factory1 *aFactory)
{
D2D1_PROPERTY_BINDING bindings[] = {
D2D1_VALUE_TYPE_BINDING(L"StopCollection", &SetStopCollection, &GetStopCollection),
D2D1_VALUE_TYPE_BINDING(L"Center1", &SetCenter1, &GetCenter1),
D2D1_VALUE_TYPE_BINDING(L"Center2", &SetCenter2, &GetCenter2),
D2D1_VALUE_TYPE_BINDING(L"Radius1", &SetRadius1, &GetRadius1),
D2D1_VALUE_TYPE_BINDING(L"Radius2", &SetRadius2, &GetRadius2),
D2D1_VALUE_TYPE_BINDING(L"Transform", &SetTransform, &GetTransform)
D2D1_VALUE_TYPE_BINDING(L"StopCollection", &RadialGradientEffectD2D1::SetStopCollection,
&RadialGradientEffectD2D1::GetStopCollection),
D2D1_VALUE_TYPE_BINDING(L"Center1", &RadialGradientEffectD2D1::SetCenter1, &RadialGradientEffectD2D1::GetCenter1),
D2D1_VALUE_TYPE_BINDING(L"Center2", &RadialGradientEffectD2D1::SetCenter2, &RadialGradientEffectD2D1::GetCenter2),
D2D1_VALUE_TYPE_BINDING(L"Radius1", &RadialGradientEffectD2D1::SetRadius1, &RadialGradientEffectD2D1::GetRadius1),
D2D1_VALUE_TYPE_BINDING(L"Radius2", &RadialGradientEffectD2D1::SetRadius2, &RadialGradientEffectD2D1::GetRadius2),
D2D1_VALUE_TYPE_BINDING(L"Transform", &RadialGradientEffectD2D1::SetTransform, &RadialGradientEffectD2D1::GetTransform)
};
HRESULT hr = aFactory->RegisterEffectFromString(CLSID_RadialGradientEffect, kXmlDescription, bindings, ARRAYSIZE(bindings), CreateEffect);

View File

@ -11,6 +11,7 @@
#include <d2d1effecthelpers.h>
#include "2D.h"
#include "mozilla/Attributes.h"
// {97143DC6-CBC4-4DD4-A8BA-13342B0BA46D}
DEFINE_GUID(CLSID_RadialGradientEffect,
@ -37,8 +38,8 @@ enum {
RADIAL_PROP_TRANSFORM
};
class RadialGradientEffectD2D1 : public ID2D1EffectImpl
, public ID2D1DrawTransform
class RadialGradientEffectD2D1 MOZ_FINAL : public ID2D1EffectImpl
, public ID2D1DrawTransform
{
public:
// ID2D1EffectImpl

View File

@ -45,7 +45,6 @@ ContentMightReflowOnOrientationChange(const nsIntRect& rect)
template<Op OP>
static void
WalkTheTree(Layer* aLayer,
Layer* aParent,
bool& aReady,
const TargetConfig& aTargetConfig)
{
@ -75,7 +74,7 @@ WalkTheTree(Layer* aLayer,
}
for (Layer* child = aLayer->GetFirstChild();
child; child = child->GetNextSibling()) {
WalkTheTree<OP>(child, aLayer, aReady, aTargetConfig);
WalkTheTree<OP>(child, aReady, aTargetConfig);
}
}
@ -83,7 +82,6 @@ void
AsyncCompositionManager::ResolveRefLayers()
{
WalkTheTree<Resolve>(mLayerManager->GetRoot(),
nullptr,
mReadyForCompose,
mTargetConfig);
}
@ -92,7 +90,6 @@ void
AsyncCompositionManager::DetachRefLayers()
{
WalkTheTree<Detach>(mLayerManager->GetRoot(),
nullptr,
mReadyForCompose,
mTargetConfig);
}

View File

@ -175,9 +175,13 @@ ContentHostBase::Composite(EffectChain& aEffectChain,
Float(tileRegionRect.width) / texRect.width,
Float(tileRegionRect.height) / texRect.height);
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain, aOpacity, aTransform, aOffset);
GetCompositor()->DrawDiagnostics(gfx::Color(0.0,1.0,0.0,1.0),
rect, aClipRect, aTransform, aOffset);
if (iterOnWhite) {
GetCompositor()->DrawDiagnostics(gfx::Color(0.0,0.0,1.0,1.0),
rect, aClipRect, aTransform, aOffset);
} else {
GetCompositor()->DrawDiagnostics(gfx::Color(0.0,1.0,0.0,1.0),
rect, aClipRect, aTransform, aOffset);
}
}
}
}

View File

@ -188,7 +188,6 @@ ContextCallback(JSContext *cx,
if (contextOp == JSCONTEXT_NEW) {
JS_SetErrorReporter(cx, ScriptErrorReporter);
JS_SetVersion(cx, JSVERSION_LATEST);
}
return JS_TRUE;
}
@ -306,10 +305,10 @@ Version(JSContext *cx,
JS::Value *vp)
{
JS::Value *argv = JS_ARGV(cx, vp);
JS_SET_RVAL(cx, vp, INT_TO_JSVAL(JS_GetVersion(cx)));
if (argc > 0 && JSVAL_IS_INT(argv[0]))
JS_SET_RVAL(cx, vp, INT_TO_JSVAL(JS_SetVersion(cx, JSVersion(JSVAL_TO_INT(argv[0])))));
else
JS_SET_RVAL(cx, vp, INT_TO_JSVAL(JS_GetVersion(cx)));
JS_SetVersionForCompartment(js::GetContextCompartment(cx),
JSVersion(JSVAL_TO_INT(argv[0])));
return JS_TRUE;
}
@ -783,11 +782,14 @@ XPCShellEnvironment::Init()
return false;
}
JS::CompartmentOptions options;
options.setZone(JS::SystemZone)
.setVersion(JSVERSION_LATEST);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->InitClassesWithNewWrappedGlobal(cx,
static_cast<nsIGlobalObject *>(backstagePass),
principal, 0,
JS::SystemZone,
options,
getter_AddRefs(holder));
if (NS_FAILED(rv)) {
NS_ERROR("InitClassesWithNewWrappedGlobal failed!");

View File

@ -45,7 +45,7 @@ interface jsdIActivationCallback;
* Debugger service. It is not a good idea to have more than one active client
* of the debugger service.
*/
[scriptable, uuid(9be5b327-6818-464d-9695-f33885fd8377)]
[scriptable, uuid(029b8f0a-aa84-47eb-a60f-1a4752b7ad06)]
interface jsdIDebuggerService : nsISupports
{
/** Internal use only. */
@ -88,29 +88,6 @@ interface jsdIDebuggerService : nsISupports
*/
attribute jsdICallHook functionHook;
/**
* VERSION_* values must be kept in sync with the JSVersion enumeration in
* jspubtd.h.
*/
/**
* Possible values for jsdIScript::version and jsdIContext::version.
*/
const long VERSION_1_0 = 100;
const long VERSION_1_1 = 110;
const long VERSION_1_2 = 120;
const long VERSION_1_3 = 130;
const long VERSION_1_4 = 140;
const long VERSION_1_5 = 150;
const long VERSION_DEFAULT = 0;
const long VERSION_UNKNOWN = -1;
/**
* These flags need to be kept in sync with the context flags defined in
* jsdebug.h
*/
/**
* Link native frames in call stacks.
*/
@ -722,13 +699,6 @@ interface jsdIContext : jsdIEphemeral
*/
attribute unsigned long options;
/**
* Last version set on this context.
* Scripts typically select this with the "language" attribute.
* See the VERSION_* consts on jsdIDebuggerService.
*/
attribute long version;
/**
* Unique tag among all valid jsdIContext objects, useful as a hash key.
*/

View File

@ -1693,23 +1693,6 @@ jsdContext::GetTag(uint32_t *_rval)
return NS_OK;
}
NS_IMETHODIMP
jsdContext::GetVersion (int32_t *_rval)
{
ASSERT_VALID_EPHEMERAL;
*_rval = static_cast<int32_t>(JS_GetVersion(mJSCx));
return NS_OK;
}
NS_IMETHODIMP
jsdContext::SetVersion (int32_t id)
{
ASSERT_VALID_EPHEMERAL;
JSVersion ver = static_cast<JSVersion>(id);
JS_SetVersion(mJSCx, ver);
return NS_OK;
}
NS_IMETHODIMP
jsdContext::GetGlobalObject (jsdIValue **_rval)
{

View File

@ -62,13 +62,14 @@ main (int argc, const char **argv)
JS_SetNativeStackQuota(runtime, 5000000);
JSContext *cx = checkPtr(JS_NewContext(runtime, 8192));
JS_SetVersion(cx, JSVERSION_LATEST);
JS_SetErrorReporter(cx, reportError);
JSAutoRequest ar(cx);
/* Create the global object. */
RootedObject global(cx, checkPtr(JS_NewGlobalObject(cx, &global_class, NULL)));
JS::CompartmentOptions options;
options.setVersion(JSVERSION_LATEST);
RootedObject global(cx, checkPtr(JS_NewGlobalObject(cx, &global_class, NULL, options)));
JS_SetGlobalObject(cx, global);
JSAutoCompartment ac(cx, global);

View File

@ -64,7 +64,6 @@ CPP_SOURCES += [
'testTrap.cpp',
'testTypedArrays.cpp',
'testUTF8.cpp',
'testVersion.cpp',
'testXDR.cpp',
'tests.cpp',
]

View File

@ -1,174 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "jsapi-tests/tests.h"
#include "jsscript.h"
#include "jscntxt.h"
#include "jscntxtinlines.h"
#ifdef JSGC_GENERATIONAL
#include "vm/Shape-inl.h"
#endif
using namespace js;
struct VersionFixture;
/*
* Fast-native callbacks for use from JS.
* They set their results on the current fixture instance.
*/
static VersionFixture *callbackData = NULL;
JSBool CallSetVersion17(JSContext *cx, unsigned argc, jsval *vp);
JSBool OverrideVersion18(JSContext *cx, unsigned argc, jsval *vp);
JSBool CaptureVersion(JSContext *cx, unsigned argc, jsval *vp);
JSBool CheckOverride(JSContext *cx, unsigned argc, jsval *vp);
JSBool EvalScriptVersion16(JSContext *cx, unsigned argc, jsval *vp);
struct VersionFixture : public JSAPITest
{
JSVersion captured;
virtual bool init() {
if (!JSAPITest::init())
return false;
JS_SetOptions(cx, JS_GetOptions(cx));
callbackData = this;
captured = JSVERSION_UNKNOWN;
JS::RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
return JS_DefineFunction(cx, global, "callSetVersion17", CallSetVersion17, 0, 0) &&
JS_DefineFunction(cx, global, "overrideVersion18", OverrideVersion18, 0, 0) &&
JS_DefineFunction(cx, global, "captureVersion", CaptureVersion, 0, 0) &&
JS_DefineFunction(cx, global, "checkOverride", CheckOverride, 1, 0) &&
JS_DefineFunction(cx, global, "evalScriptVersion16",
EvalScriptVersion16, 0, 0);
}
JSScript *fakeScript(const char *contents, size_t length) {
JS::RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
return JS_CompileScript(cx, global, contents, length, "<test>", 1);
}
bool checkVersionIsOverridden() {
CHECK(cx->isVersionOverridden());
return true;
}
bool setVersion(JSVersion version) {
CHECK(JS_GetVersion(cx) != version);
JS_SetVersion(cx, version);
return true;
}
bool evalVersion(const jschar *chars, size_t len, JSVersion version) {
CHECK(JS_GetVersion(cx) != version);
jsval rval;
JS::RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
CHECK(JS_EvaluateUCScriptForPrincipalsVersion(
cx, global, NULL, chars, len, "<test>", 0, &rval, version));
return true;
}
};
/* Callbacks to throw into JS-land. */
JSBool
CallSetVersion17(JSContext *cx, unsigned argc, jsval *vp)
{
return callbackData->setVersion(JSVERSION_1_7);
}
JSBool
OverrideVersion18(JSContext *cx, unsigned argc, jsval *vp)
{
if (!callbackData->setVersion(JSVERSION_1_8))
return false;
return callbackData->checkVersionIsOverridden();
}
JSBool
EvalScriptVersion16(JSContext *cx, unsigned argc, jsval *vp)
{
JS_ASSERT(argc == 1);
jsval *argv = JS_ARGV(cx, vp);
JS_ASSERT(JSVAL_IS_STRING(argv[0]));
JSStableString *str = JSVAL_TO_STRING(argv[0])->ensureStable(cx);
JS_ASSERT(str);
return callbackData->evalVersion(str->chars().get(), str->length(), JSVERSION_1_6);
}
JSBool
CaptureVersion(JSContext *cx, unsigned argc, jsval *vp)
{
callbackData->captured = JS_GetVersion(cx);
return true;
}
JSBool
CheckOverride(JSContext *cx, unsigned argc, jsval *vp)
{
JS_ASSERT(argc == 1);
jsval *argv = JS_ARGV(cx, vp);
JS_ASSERT(JSVAL_IS_BOOLEAN(argv[0]));
bool shouldHaveOverride = !!JSVAL_TO_BOOLEAN(argv[0]);
return shouldHaveOverride == cx->isVersionOverridden();
}
/*
* When re-entering the virtual machine through a *Version API the version
* is no longer forced -- it continues with its natural push/pop oriented
* version progression. This is maintained by the |AutoVersionAPI| class in
* jsapi.cpp.
*/
BEGIN_FIXTURE_TEST(VersionFixture, testVersion_EntryLosesOverride)
{
EXEC("overrideVersion18(); evalScriptVersion16('checkOverride(false); captureVersion()');");
CHECK_EQUAL(captured, JSVERSION_1_6);
/*
* Override gets propagated to default version as non-override when you leave the VM's execute
* call.
*/
CHECK_EQUAL(JS_GetVersion(cx), JSVERSION_1_8);
CHECK(!cx->isVersionOverridden());
return true;
}
END_FIXTURE_TEST(VersionFixture, testVersion_EntryLosesOverride)
/*
* EvalScriptVersion does not propagate overrides to its caller, it
* restores things exactly as they were before the call. This is as opposed to
* the normal (no Version suffix) API which propagates overrides
* to the caller.
*/
BEGIN_FIXTURE_TEST(VersionFixture, testVersion_ReturnLosesOverride)
{
CHECK_EQUAL(JS_GetVersion(cx), JSVERSION_ECMA_5);
EXEC(
"checkOverride(false);"
"evalScriptVersion16('overrideVersion18();');"
"checkOverride(false);"
"captureVersion();"
);
CHECK_EQUAL(captured, JSVERSION_ECMA_5);
return true;
}
END_FIXTURE_TEST(VersionFixture, testVersion_ReturnLosesOverride)
BEGIN_FIXTURE_TEST(VersionFixture, testVersion_EvalPropagatesOverride)
{
CHECK_EQUAL(JS_GetVersion(cx), JSVERSION_ECMA_5);
EXEC(
"checkOverride(false);"
"eval('overrideVersion18();');"
"checkOverride(true);"
"captureVersion();"
);
CHECK_EQUAL(captured, JSVERSION_1_8);
return true;
}
END_FIXTURE_TEST(VersionFixture, testVersion_EvalPropagatesOverride)

View File

@ -51,7 +51,9 @@ bool JSAPITest::definePrint()
JSObject * JSAPITest::createGlobal(JSPrincipals *principals)
{
/* Create the global object. */
global = JS_NewGlobalObject(cx, getGlobalClass(), principals);
JS::CompartmentOptions options;
options.setVersion(JSVERSION_LATEST);
global = JS_NewGlobalObject(cx, getGlobalClass(), principals, options);
if (!global)
return NULL;
JS_AddNamedObjectRoot(cx, &global, "test-global");

View File

@ -301,7 +301,6 @@ class JSAPITest
if (!cx)
return NULL;
JS_SetOptions(cx, JSOPTION_VAROBJFIX);
JS_SetVersion(cx, JSVERSION_LATEST);
JS_SetErrorReporter(cx, &reportError);
return cx;
}

View File

@ -122,47 +122,6 @@ JS::detail::CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl
return false;
}
/*
* This class is a version-establishing barrier at the head of a VM entry or
* re-entry. It ensures that:
*
* - |newVersion| is the starting (default) version used for the context.
* - The starting version state is not an override.
* - Overrides in the VM session are not propagated to the caller.
*/
class AutoVersionAPI
{
JSContext * const cx;
JSVersion oldDefaultVersion;
bool oldHasVersionOverride;
JSVersion oldVersionOverride;
JSVersion newVersion;
public:
AutoVersionAPI(JSContext *cx, JSVersion newVersion)
: cx(cx),
oldDefaultVersion(cx->getDefaultVersion()),
oldHasVersionOverride(cx->isVersionOverridden()),
oldVersionOverride(oldHasVersionOverride ? cx->findVersion() : JSVERSION_UNKNOWN)
{
this->newVersion = newVersion;
cx->clearVersionOverride();
cx->setDefaultVersion(newVersion);
}
~AutoVersionAPI() {
cx->setDefaultVersion(oldDefaultVersion);
if (oldHasVersionOverride)
cx->overrideVersion(oldVersionOverride);
else
cx->clearVersionOverride();
}
/* The version that this scoped-entity establishes. */
JSVersion version() const { return newVersion; }
};
#ifdef HAVE_VA_LIST_AS_ARRAY
#define JS_ADDRESSOF_VA_LIST(ap) ((va_list *)(ap))
#else
@ -752,6 +711,7 @@ JSRuntime::JSRuntime(JSUseHelperThreads useHelperThreads)
numCompartments(0),
localeCallbacks(NULL),
defaultLocale(NULL),
defaultVersion_(JSVERSION_DEFAULT),
#ifdef JS_THREADSAFE
ownerThread_(NULL),
#endif
@ -958,7 +918,8 @@ JSRuntime::init(uint32_t maxbytes)
if (!atomsZone)
return false;
ScopedJSDeletePtr<JSCompartment> atomsCompartment(new_<JSCompartment>(atomsZone.get()));
JS::CompartmentOptions options;
ScopedJSDeletePtr<JSCompartment> atomsCompartment(new_<JSCompartment>(atomsZone.get(), options));
if (!atomsCompartment || !atomsCompartment->init(NULL))
return false;
@ -1344,21 +1305,10 @@ JS_GetVersion(JSContext *cx)
return VersionNumber(cx->findVersion());
}
JS_PUBLIC_API(JSVersion)
JS_SetVersion(JSContext *cx, JSVersion newVersion)
JS_PUBLIC_API(void)
JS_SetVersionForCompartment(JSCompartment *compartment, JSVersion version)
{
JS_ASSERT(VersionIsKnown(newVersion));
JS_ASSERT(!VersionHasFlags(newVersion));
JSVersion newVersionNumber = newVersion;
JSVersion oldVersion = cx->findVersion();
JSVersion oldVersionNumber = VersionNumber(oldVersion);
if (oldVersionNumber == newVersionNumber)
return oldVersionNumber; /* No override actually occurs! */
VersionCopyFlags(&newVersion, oldVersion);
cx->maybeOverrideVersion(newVersion);
return oldVersionNumber;
compartment->options().setVersion(version);
}
static struct v2smap {
@ -3301,7 +3251,8 @@ class AutoHoldZone
};
JS_PUBLIC_API(JSObject *)
JS_NewGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals, JS::ZoneSpecifier zoneSpec)
JS_NewGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals,
const JS::CompartmentOptions &options)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
@ -3310,18 +3261,18 @@ JS_NewGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals, JS::
JSRuntime *rt = cx->runtime();
Zone *zone;
if (zoneSpec == JS::SystemZone)
if (options.zoneSpec == JS::SystemZone)
zone = rt->systemZone;
else if (zoneSpec == JS::FreshZone)
else if (options.zoneSpec == JS::FreshZone)
zone = NULL;
else
zone = ((JSObject *)zoneSpec)->zone();
zone = ((JSObject *)options.zoneSpec)->zone();
JSCompartment *compartment = NewCompartment(cx, zone, principals);
JSCompartment *compartment = NewCompartment(cx, zone, principals, options);
if (!compartment)
return NULL;
if (zoneSpec == JS::SystemZone) {
if (options.zoneSpec == JS::SystemZone) {
rt->systemZone = compartment->zone();
rt->systemZone->isSystem = true;
}
@ -5192,13 +5143,6 @@ JSScript *
JS::Compile(JSContext *cx, HandleObject obj, CompileOptions options,
const jschar *chars, size_t length)
{
Maybe<AutoVersionAPI> mava;
if (options.versionSet) {
mava.construct(cx, options.version);
// AutoVersionAPI propagates some compilation flags through.
options.version = mava.ref().version();
}
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
@ -5351,13 +5295,6 @@ JS::CompileFunction(JSContext *cx, HandleObject obj, CompileOptions options,
const char *name, unsigned nargs, const char **argnames,
const jschar *chars, size_t length)
{
Maybe<AutoVersionAPI> mava;
if (options.versionSet) {
mava.construct(cx, options.version);
// AutoVersionAPI propagates some compilation flags through.
options.version = mava.ref().version();
}
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
@ -5533,7 +5470,6 @@ JS_ExecuteScriptVersion(JSContext *cx, JSObject *objArg, JSScript *script, jsval
JSVersion version)
{
RootedObject obj(cx, objArg);
AutoVersionAPI ava(cx, version);
return JS_ExecuteScript(cx, obj, script, rval);
}
@ -5543,13 +5479,6 @@ extern JS_PUBLIC_API(bool)
JS::Evaluate(JSContext *cx, HandleObject obj, CompileOptions options,
const jschar *chars, size_t length, jsval *rval)
{
Maybe<AutoVersionAPI> mava;
if (options.versionSet) {
mava.construct(cx, options.version);
// AutoVersionAPI propagates some compilation flags through.
options.version = mava.ref().version();
}
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);

View File

@ -1895,8 +1895,14 @@ JS_ContextIterator(JSRuntime *rt, JSContext **iterp);
extern JS_PUBLIC_API(JSVersion)
JS_GetVersion(JSContext *cx);
extern JS_PUBLIC_API(JSVersion)
JS_SetVersion(JSContext *cx, JSVersion version);
// Mutate the version on the compartment. This is generally discouraged, but
// necessary to support the version mutation in the js and xpc shell command
// set.
//
// It would be nice to put this in jsfriendapi, but the linkage requirements
// of the shells make that impossible.
JS_PUBLIC_API(void)
JS_SetVersionForCompartment(JSCompartment *compartment, JSVersion version);
extern JS_PUBLIC_API(const char *)
JS_VersionToString(JSVersion version);
@ -3151,11 +3157,25 @@ SameZoneAs(JSObject *obj)
return ZoneSpecifier(obj);
}
struct JS_PUBLIC_API(CompartmentOptions) {
ZoneSpecifier zoneSpec;
bool hasVersion;
JSVersion version;
explicit CompartmentOptions() : zoneSpec(JS::FreshZone)
, hasVersion(false)
, version(JSVERSION_UNKNOWN)
{}
CompartmentOptions &setZone(ZoneSpecifier spec) { zoneSpec = spec; return *this; }
CompartmentOptions &setVersion(JSVersion version_) { hasVersion = true; version = version_; return *this; }
};
} /* namespace JS */
extern JS_PUBLIC_API(JSObject *)
JS_NewGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals,
JS::ZoneSpecifier zoneSpec = JS::FreshZone);
const JS::CompartmentOptions &options = JS::CompartmentOptions());
extern JS_PUBLIC_API(JSObject *)
JS_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent);

View File

@ -296,8 +296,6 @@ js::NewContext(JSRuntime *rt, size_t stackChunkSize)
if (!cx)
return NULL;
JS_ASSERT(cx->findVersion() == JSVERSION_DEFAULT);
if (!cx->cycleDetectorSet.init()) {
js_delete(cx);
return NULL;
@ -1177,8 +1175,6 @@ ThreadSafeContext::asForkJoinSlice()
JSContext::JSContext(JSRuntime *rt)
: ThreadSafeContext(rt, &rt->mainThread, Context_JS),
defaultVersion(JSVERSION_DEFAULT),
hasVersionOverride(false),
throwing(false),
exception(UndefinedValue()),
options_(0),
@ -1530,13 +1526,13 @@ JSContext::mark(JSTracer *trc)
JSVersion
JSContext::findVersion() const
{
if (hasVersionOverride)
return versionOverride;
if (JSScript *script = currentScript(NULL, ALLOW_CROSS_COMPARTMENT))
return script->getVersion();
return defaultVersion;
if (compartment() && compartment()->options().hasVersion)
return compartment()->options().version;
return runtime()->defaultVersion();
}
#if defined JS_THREADSAFE && defined DEBUG

View File

@ -740,6 +740,9 @@ struct JSRuntime : public JS::shadow::Runtime,
/* Default locale for Internationalization API */
char *defaultLocale;
/* Default JSVersion. */
JSVersion defaultVersion_;
/* See comment for JS_AbortIfWrongThread in jsapi.h. */
#ifdef JS_THREADSAFE
public:
@ -852,6 +855,9 @@ struct JSRuntime : public JS::shadow::Runtime,
/* Gets current default locale. String remains owned by context. */
const char *getDefaultLocale();
JSVersion defaultVersion() { return defaultVersion_; }
void setDefaultVersion(JSVersion v) { defaultVersion_ = v; }
/* Base address of the native stack for the current thread. */
uintptr_t nativeStackBase;
@ -1655,11 +1661,6 @@ struct JSContext : js::ThreadSafeContext,
js::PerThreadData &mainThread() const { return runtime()->mainThread; }
private:
/* See JSContext::findVersion. */
JSVersion defaultVersion; /* script compilation version */
JSVersion versionOverride; /* supercedes defaultVersion when valid */
bool hasVersionOverride;
/* Exception state -- the exception member is a GC root by definition. */
bool throwing; /* is there a pending exception? */
js::Value exception; /* most-recently-thrown exception */
@ -1758,50 +1759,11 @@ struct JSContext : js::ThreadSafeContext,
inline js::RegExpStatics *regExpStatics();
public:
/*
* The default script compilation version can be set iff there is no code running.
* This typically occurs via the JSAPI right after a context is constructed.
*/
inline bool canSetDefaultVersion() const;
/* Force a version for future script compilation. */
inline void overrideVersion(JSVersion newVersion);
/* Set the default script compilation version. */
void setDefaultVersion(JSVersion version) {
defaultVersion = version;
}
void clearVersionOverride() { hasVersionOverride = false; }
JSVersion getDefaultVersion() const { return defaultVersion; }
bool isVersionOverridden() const { return hasVersionOverride; }
JSVersion getVersionOverride() const {
JS_ASSERT(isVersionOverridden());
return versionOverride;
}
/*
* Set the default version if possible; otherwise, force the version.
* Return whether an override occurred.
*/
inline bool maybeOverrideVersion(JSVersion newVersion);
/*
* If there is no code on the stack, turn the override version into the
* default version.
*/
void maybeMigrateVersionOverride() {
if (JS_UNLIKELY(isVersionOverridden()) && !currentlyRunning()) {
defaultVersion = versionOverride;
clearVersionOverride();
}
}
/*
* Return:
* - The override version, if there is an override version.
* - The newest scripted frame's version, if there is such a frame.
* - The version from the compartment.
* - The default version.
*
* Note: if this ever shows up in a profile, just add caching!

View File

@ -437,31 +437,6 @@ CallSetter(JSContext *cx, HandleObject obj, HandleId id, StrictPropertyOp op, un
} /* namespace js */
inline bool
JSContext::canSetDefaultVersion() const
{
return !currentlyRunning() && !hasVersionOverride;
}
inline void
JSContext::overrideVersion(JSVersion newVersion)
{
JS_ASSERT(!canSetDefaultVersion());
versionOverride = newVersion;
hasVersionOverride = true;
}
inline bool
JSContext::maybeOverrideVersion(JSVersion newVersion)
{
if (canSetDefaultVersion()) {
setDefaultVersion(newVersion);
return false;
}
overrideVersion(newVersion);
return true;
}
inline js::LifoAlloc &
JSContext::analysisLifoAlloc()
{

View File

@ -34,8 +34,9 @@ using namespace js::gc;
using mozilla::DebugOnly;
JSCompartment::JSCompartment(Zone *zone)
JSCompartment::JSCompartment(Zone *zone, const JS::CompartmentOptions &options = JS::CompartmentOptions())
: zone_(zone),
options_(options),
rt(zone->rt),
principals(NULL),
isSystem(false),

View File

@ -121,6 +121,7 @@ class DebugScopes;
struct JSCompartment
{
JS::Zone *zone_;
JS::CompartmentOptions options_;
JSRuntime *rt;
JSPrincipals *principals;
@ -142,6 +143,8 @@ struct JSCompartment
JS::Zone *zone() { return zone_; }
const JS::Zone *zone() const { return zone_; }
JS::CompartmentOptions &options() { return options_; }
const JS::CompartmentOptions &options() const { return options_; }
/*
* Nb: global_ might be NULL, if (a) it's the atoms compartment, or (b) the
@ -257,7 +260,7 @@ struct JSCompartment
unsigned debugModeBits; // see debugMode() below
public:
JSCompartment(JS::Zone *zone);
JSCompartment(JS::Zone *zone, const JS::CompartmentOptions &options);
~JSCompartment();
bool init(JSContext *cx);

View File

@ -828,12 +828,6 @@ JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure)
/************************************************************************/
JS_FRIEND_API(void)
js_RevertVersion(JSContext *cx)
{
cx->clearVersionOverride();
}
JS_PUBLIC_API(const JSDebugHooks *)
JS_GetGlobalDebugHooks(JSRuntime *rt)
{

View File

@ -426,9 +426,6 @@ JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure);
/************************************************************************/
extern JS_FRIEND_API(void)
js_RevertVersion(JSContext *cx);
extern JS_PUBLIC_API(const JSDebugHooks *)
JS_GetGlobalDebugHooks(JSRuntime *rt);

View File

@ -4678,7 +4678,8 @@ AutoPrepareForTracing::AutoPrepareForTracing(JSRuntime *rt)
}
JSCompartment *
js::NewCompartment(JSContext *cx, Zone *zone, JSPrincipals *principals)
js::NewCompartment(JSContext *cx, Zone *zone, JSPrincipals *principals,
const JS::CompartmentOptions &options)
{
JSRuntime *rt = cx->runtime();
JS_AbortIfWrongThread(rt);
@ -4700,7 +4701,7 @@ js::NewCompartment(JSContext *cx, Zone *zone, JSPrincipals *principals)
zone->isSystem = principals && principals == trusted;
}
ScopedJSDeletePtr<JSCompartment> compartment(cx->new_<JSCompartment>(zone));
ScopedJSDeletePtr<JSCompartment> compartment(cx->new_<JSCompartment>(zone, options));
if (!compartment || !compartment->init(cx))
return NULL;

View File

@ -1203,7 +1203,8 @@ js_FinalizeStringRT(JSRuntime *rt, JSString *str);
namespace js {
JSCompartment *
NewCompartment(JSContext *cx, JS::Zone *zone, JSPrincipals *principals);
NewCompartment(JSContext *cx, JS::Zone *zone, JSPrincipals *principals,
const JS::CompartmentOptions &options);
namespace gc {

View File

@ -625,9 +625,10 @@ static JSBool
Version(JSContext *cx, unsigned argc, jsval *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
JSVersion origVersion = JS_GetVersion(cx);
if (args.length() == 0 || JSVAL_IS_VOID(args[0])) {
/* Get version. */
args.rval().setInt32(JS_GetVersion(cx));
args.rval().setInt32(origVersion);
} else {
/* Set version. */
int32_t v = -1;
@ -642,20 +643,12 @@ Version(JSContext *cx, unsigned argc, jsval *vp)
JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL, JSSMSG_INVALID_ARGS, "version");
return false;
}
args.rval().setInt32(JS_SetVersion(cx, JSVersion(v)));
JS_SetVersionForCompartment(js::GetContextCompartment(cx), JSVersion(v));
args.rval().setInt32(origVersion);
}
return true;
}
static JSBool
RevertVersion(JSContext *cx, unsigned argc, jsval *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
js_RevertVersion(cx);
args.rval().setUndefined();
return true;
}
static JSScript *
GetTopScript(JSContext *cx)
{
@ -3573,10 +3566,6 @@ static const JSFunctionSpecWithHelp shell_functions[] = {
"version([number])",
" Get or force a script compilation version number."),
JS_FN_HELP("revertVersion", RevertVersion, 0, 0,
"revertVersion()",
" Revert previously set version number."),
JS_FN_HELP("options", Options, 0, 0,
"options([option ...])",
" Get or toggle JavaScript options."),
@ -4782,7 +4771,6 @@ NewContext(JSRuntime *rt)
JS_SetContextPrivate(cx, data);
JS_SetErrorReporter(cx, my_ErrorReporter);
JS_SetVersion(cx, JSVERSION_LATEST);
SetContextOptions(cx);
if (enableTypeInference)
JS_ToggleOptions(cx, JSOPTION_TYPE_INFERENCE);
@ -4807,8 +4795,10 @@ DestroyContext(JSContext *cx, bool withGC)
static JSObject *
NewGlobalObject(JSContext *cx, JSObject *sameZoneAs)
{
JS::ZoneSpecifier spec = sameZoneAs ? JS::SameZoneAs(sameZoneAs) : JS::FreshZone;
RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, NULL, spec));
JS::CompartmentOptions options;
options.setZone(sameZoneAs ? JS::SameZoneAs(sameZoneAs) : JS::FreshZone)
.setVersion(JSVERSION_LATEST);
RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, NULL, options));
if (!glob)
return NULL;

View File

@ -137,19 +137,6 @@ function test()
expect(["a1", "a2", "a3", "b1", "b2", "b3", "c1", "c2", "c3"] + "",
([a + b for (a in 'abc') for (b in '123')]) + "");
/*
* Version switching
*/
if (typeof version == 'function')
{
var v = version(150);
f = new Function("return version(arguments[0])");
revertVersion();
expect(150, f());
expect(150, eval("f()"));
expect(0, eval("f(0); f()"));
revertVersion();
}
print("End of Tests");
/*

View File

@ -835,7 +835,6 @@ Activation::~Activation()
{
JS_ASSERT(cx_->mainThread().activation_ == this);
cx_->mainThread().activation_ = prev_;
cx_->maybeMigrateVersionOverride();
}
InterpreterActivation::InterpreterActivation(JSContext *cx, StackFrame *entry, FrameRegs &regs)

View File

@ -44,7 +44,7 @@ class nsWrapperCache;
[ref] native nsCCTraversalCallbackRef(nsCycleCollectionTraversalCallback);
[ptr] native nsAXPCNativeCallContextPtr(nsAXPCNativeCallContext);
[ptr] native nsWrapperCachePtr(nsWrapperCache);
native ZoneSpecifier(uintptr_t);
[ref] native JSCompartmentOptions(JS::CompartmentOptions);
[ref] native JSCallArgsRef(const JS::CallArgs);
native JSHandleId(JS::HandleId);
@ -291,7 +291,7 @@ interface nsIXPCFunctionThisTranslator : nsISupports
{ 0xbd, 0xd6, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
%}
[uuid(dee6f80b-7ec5-4690-8622-a48af6a1ce52)]
[uuid(bd61342d-8a88-4f23-8d2d-1782fff02d26)]
interface nsIXPConnect : nsISupports
{
%{ C++
@ -318,14 +318,15 @@ interface nsIXPConnect : nsISupports
* compartment. Can be null if not on the main thread.
* @param aFlags one of the flags below specifying what options this
* global object wants.
* @param aOptions JSAPI-specific options for the new compartment.
*/
nsIXPConnectJSObjectHolder
initClassesWithNewWrappedGlobal(
in JSContextPtr aJSContext,
in nsISupports aCOMObj,
in nsIPrincipal aPrincipal,
in uint32_t aFlags,
in ZoneSpecifier aZoneSpec);
in JSContextPtr aJSContext,
in nsISupports aCOMObj,
in nsIPrincipal aPrincipal,
in uint32_t aFlags,
in JSCompartmentOptions aOptions);
const uint32_t INIT_JS_STANDARD_CLASSES = 1 << 0;
// Free bit here!

View File

@ -460,9 +460,6 @@ mozJSComponentLoader::ReallyInit()
if (!mContext)
return NS_ERROR_OUT_OF_MEMORY;
// Always use the latest js version
JS_SetVersion(mContext, JSVERSION_LATEST);
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
if (!secman)
@ -727,11 +724,14 @@ mozJSComponentLoader::PrepareObjectForLocation(JSCLContextHelper& aCx,
rv = NS_NewBackstagePass(getter_AddRefs(backstagePass));
NS_ENSURE_SUCCESS(rv, nullptr);
JS::CompartmentOptions options;
options.setZone(JS::SystemZone)
.setVersion(JSVERSION_LATEST);
rv = xpc->InitClassesWithNewWrappedGlobal(aCx,
static_cast<nsIGlobalObject *>(backstagePass),
mSystemPrincipal,
0,
JS::SystemZone,
options,
getter_AddRefs(holder));
NS_ENSURE_SUCCESS(rv, nullptr);

View File

@ -491,10 +491,11 @@ Load(JSContext *cx, unsigned argc, jsval *vp)
static JSBool
Version(JSContext *cx, unsigned argc, jsval *vp)
{
JSVersion origVersion = JS_GetVersion(cx);
JS_SET_RVAL(cx, vp, INT_TO_JSVAL(origVersion));
if (argc > 0 && JSVAL_IS_INT(JS_ARGV(cx, vp)[0]))
JS_SET_RVAL(cx, vp, INT_TO_JSVAL(JS_SetVersion(cx, JSVersion(JSVAL_TO_INT(JS_ARGV(cx, vp)[0])))));
else
JS_SET_RVAL(cx, vp, INT_TO_JSVAL(JS_GetVersion(cx)));
JS_SetVersionForCompartment(js::GetContextCompartment(cx),
JSVersion(JSVAL_TO_INT(JS_ARGV(cx, vp)[0])));
return true;
}
@ -1318,7 +1319,8 @@ ProcessArgs(JSContext *cx, JS::Handle<JSObject*> obj, char **argv, int argc, XPC
if (++i == argc) {
return usage();
}
JS_SetVersion(cx, JSVersion(atoi(argv[i])));
JS_SetVersionForCompartment(js::GetContextCompartment(cx),
JSVersion(atoi(argv[i])));
break;
case 'W':
reportWarnings = false;
@ -1482,7 +1484,6 @@ ContextCallback(JSContext *cx, unsigned contextOp)
if (contextOp == JSCONTEXT_NEW) {
JS_SetErrorReporter(cx, my_ErrorReporter);
JS_SetVersion(cx, JSVERSION_LATEST);
}
return true;
}
@ -1716,12 +1717,15 @@ main(int argc, char **argv, char **envp)
return 1;
}
JS::CompartmentOptions options;
options.setZone(JS::SystemZone)
.setVersion(JSVERSION_LATEST);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->InitClassesWithNewWrappedGlobal(cx,
static_cast<nsIGlobalObject *>(backstagePass),
systemprincipal,
0,
JS::SystemZone,
options,
getter_AddRefs(holder));
if (NS_FAILED(rv))
return 1;

View File

@ -3275,10 +3275,12 @@ xpc_CreateSandboxObject(JSContext *cx, jsval *vp, nsISupports *prinOrSop, Sandbo
MOZ_ASSERT(principal);
}
JS::ZoneSpecifier zoneSpec = options.sameZoneAs
JS::CompartmentOptions compartmentOptions;
compartmentOptions.setZone(options.sameZoneAs
? JS::SameZoneAs(js::UncheckedUnwrap(options.sameZoneAs))
: JS::SystemZone;
RootedObject sandbox(cx, xpc::CreateGlobalObject(cx, &SandboxClass, principal, zoneSpec));
: JS::SystemZone);
RootedObject sandbox(cx, xpc::CreateGlobalObject(cx, &SandboxClass,
principal, compartmentOptions));
if (!sandbox)
return NS_ERROR_FAILURE;
@ -3816,6 +3818,13 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString& source,
return NS_ERROR_INVALID_ARG;
jsVersion = JS_StringToVersion(bytes.ptr());
// Explicitly check for "latest", which we support for sandboxes but
// isn't in the set of web-exposed version strings.
if (jsVersion == JSVERSION_UNKNOWN &&
!strcmp(bytes.ptr(), "latest"))
{
jsVersion = JSVERSION_LATEST;
}
if (jsVersion == JSVERSION_UNKNOWN)
return NS_ERROR_INVALID_ARG;
}
@ -3900,12 +3909,11 @@ xpc_EvalInSandbox(JSContext *cx, HandleObject sandboxArg, const nsAString& sourc
pusher.Push(sandcx);
JSAutoCompartment ac(sandcx, sandbox);
if (jsVersion != JSVERSION_DEFAULT)
JS_SetVersion(sandcx, jsVersion);
JS::CompileOptions options(sandcx);
options.setPrincipals(nsJSPrincipals::get(prin))
.setFileAndLine(filename, lineNo);
if (jsVersion != JSVERSION_DEFAULT)
options.setVersion(jsVersion);
JS::RootedObject rootedSandbox(sandcx, sandbox);
ok = JS::Evaluate(sandcx, rootedSandbox, options,
PromiseFlatString(source).get(), source.Length(),

View File

@ -160,7 +160,9 @@ XPCJSContextStack::GetSafeJSContext()
JS::RootedObject glob(mSafeJSContext);
JS_SetErrorReporter(mSafeJSContext, mozJSLoaderErrorReporter);
glob = xpc::CreateGlobalObject(mSafeJSContext, &global_class, principal, JS::SystemZone);
JS::CompartmentOptions options;
options.setZone(JS::SystemZone);
glob = xpc::CreateGlobalObject(mSafeJSContext, &global_class, principal, options);
if (!glob)
MOZ_CRASH();

View File

@ -283,7 +283,7 @@ FinishCreate(XPCWrappedNativeScope* Scope,
nsresult
XPCWrappedNative::WrapNewGlobal(xpcObjectHelper &nativeHelper,
nsIPrincipal *principal, bool initStandardClasses,
ZoneSpecifier zoneSpec,
JS::CompartmentOptions& aOptions,
XPCWrappedNative **wrappedGlobal)
{
AutoJSContext cx;
@ -313,7 +313,7 @@ XPCWrappedNative::WrapNewGlobal(xpcObjectHelper &nativeHelper,
MOZ_ASSERT(clasp->flags & JSCLASS_IS_GLOBAL);
// Create the global.
RootedObject global(cx, xpc::CreateGlobalObject(cx, clasp, principal, zoneSpec));
RootedObject global(cx, xpc::CreateGlobalObject(cx, clasp, principal, aOptions));
if (!global)
return NS_ERROR_FAILURE;
XPCWrappedNativeScope *scope = GetCompartmentPrivate(global)->scope;

View File

@ -392,7 +392,7 @@ namespace xpc {
JSObject*
CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal,
JS::ZoneSpecifier zoneSpec)
JS::CompartmentOptions& aOptions)
{
// Make sure that Type Inference is enabled for everything non-chrome.
// Sandboxes and compilation scopes are exceptions. See bug 744034.
@ -402,7 +402,7 @@ CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal,
MOZ_ASSERT(principal);
RootedObject global(cx,
JS_NewGlobalObject(cx, clasp, nsJSPrincipals::get(principal), zoneSpec));
JS_NewGlobalObject(cx, clasp, nsJSPrincipals::get(principal), aOptions));
if (!global)
return nullptr;
JSAutoCompartment ac(cx, global);
@ -438,7 +438,7 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
nsISupports *aCOMObj,
nsIPrincipal * aPrincipal,
uint32_t aFlags,
JS::ZoneSpecifier zoneSpec,
JS::CompartmentOptions& aOptions,
nsIXPConnectJSObjectHolder **_retval)
{
NS_ASSERTION(aJSContext, "bad param");
@ -457,8 +457,7 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
nsresult rv =
XPCWrappedNative::WrapNewGlobal(helper, aPrincipal,
aFlags & nsIXPConnect::INIT_JS_STANDARD_CLASSES,
zoneSpec,
getter_AddRefs(wrappedGlobal));
aOptions, getter_AddRefs(wrappedGlobal));
NS_ENSURE_SUCCESS(rv, rv);
// Grab a copy of the global and enter its compartment.

View File

@ -2418,7 +2418,7 @@ public:
static nsresult
WrapNewGlobal(xpcObjectHelper &nativeHelper,
nsIPrincipal *principal, bool initStandardClasses,
JS::ZoneSpecifier zoneSpec,
JS::CompartmentOptions& aOptions,
XPCWrappedNative **wrappedGlobal);
static nsresult
@ -3726,7 +3726,7 @@ struct SandboxOptions {
JSObject *
CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal,
JS::ZoneSpecifier zoneSpec);
JS::CompartmentOptions& aOptions);
}
// Helper for creating a sandbox object to use for evaluating

View File

@ -1,3 +0,0 @@
/* Some constructs that require a high default version number. */
let x = 12;
function simpleGen() { yield 12; }

View File

@ -1,19 +0,0 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
function run_test() {
var file = do_get_file("bug596580_versioned.js");
var ios = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var uri = ios.newFileURI(file);
var scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader);
scriptLoader.loadSubScript(uri.spec);
version(150)
try {
scriptLoader.loadSubScript(uri.spec);
throw new Error("Subscript should fail to load.");
} catch (e if e instanceof SyntaxError) {
// Okay.
}
}

View File

@ -5,7 +5,6 @@ tail =
[test_bogus_files.js]
[test_bug408412.js]
[test_bug451678.js]
[test_bug596580.js]
[test_bug604362.js]
[test_bug641378.js]
[test_bug677864.js]

View File

@ -3573,6 +3573,11 @@ nsSVGTextFrame2::ReflowSVG()
mRect =
nsLayoutUtils::RoundGfxRectToAppRect(r, presContext->AppUnitsPerCSSPixel());
// Due to rounding issues when we have a transform applied, we sometimes
// don't include an additional row of pixels. For now, just inflate our
// covered region.
mRect.Inflate(presContext->AppUnitsPerDevPixel());
if (mState & NS_FRAME_FIRST_REFLOW) {
// Make sure we have our filter property (if any) before calling

View File

@ -202,8 +202,6 @@ public class BrowserToolbar extends GeckoRelativeLayout
mTitle = (GeckoTextView) findViewById(R.id.awesome_bar_title);
mTitlePadding = mTitle.getPaddingRight();
if (Build.VERSION.SDK_INT >= 16)
mTitle.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
mTabs = (ShapedButton) findViewById(R.id.tabs);
mTabsCounter = (TabCounter) findViewById(R.id.tabs_counter);

View File

@ -1927,7 +1927,7 @@ pref("svg.paint-order.enabled", true);
#endif
// Is support for the new SVG text implementation enabled?
pref("svg.text.css-frames.enabled", false);
pref("svg.text.css-frames.enabled", true);
pref("font.minimum-size.ar", 0);
pref("font.minimum-size.x-armn", 0);

View File

@ -536,13 +536,15 @@ private:
JSAutoRequest ar(mContext);
mGlobal = JS_NewGlobalObject(mContext, &sGlobalClass, nullptr, JS::SystemZone);
JS::CompartmentOptions options;
options.setZone(JS::SystemZone)
.setVersion(JSVERSION_LATEST);
mGlobal = JS_NewGlobalObject(mContext, &sGlobalClass, nullptr, options);
NS_ENSURE_TRUE(mGlobal, NS_ERROR_OUT_OF_MEMORY);
JS_SetGlobalObject(mContext, mGlobal);
JS_InitStandardClasses(mContext, mGlobal);
JS_SetVersion(mContext, JSVERSION_LATEST);
JS_SetErrorReporter(mContext, PACErrorReporter);
if (!JS_DefineFunctions(mContext, mGlobal, PACGlobalFunctions))

View File

@ -2728,7 +2728,7 @@ ServerHandler.prototype =
// getting the line number where we evaluate the SJS file. Don't
// separate these two lines!
var line = new Error().lineNumber;
Cu.evalInSandbox(sis.read(file.fileSize), s);
Cu.evalInSandbox(sis.read(file.fileSize), s, "latest");
}
catch (e)
{