mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Back out 8 changesets (bug 990353) for gaia-integration bustage
CLOSED TREE Backed out changeset f6b3c03454a4 (bug 990353) Backed out changeset 6e1f9b821ae0 (bug 990353) Backed out changeset 2926ad6c594f (bug 990353) Backed out changeset 74b75c155205 (bug 990353) Backed out changeset 394e09fe2da2 (bug 990353) Backed out changeset 0fdd36b19a51 (bug 990353) Backed out changeset 0792729890cc (bug 990353) Backed out changeset 487e6f72fcf7 (bug 990353)
This commit is contained in:
parent
7e36684d60
commit
380621d27b
@ -599,12 +599,6 @@ pref("dom.forms.color", false);
|
||||
// Turns on gralloc-based direct texturing for Gonk
|
||||
pref("gfx.gralloc.enabled", false);
|
||||
|
||||
// This preference instructs the JS engine to discard the
|
||||
// source of any privileged JS after compilation. This saves
|
||||
// memory, but makes things like Function.prototype.toSource()
|
||||
// fail.
|
||||
pref("javascript.options.discardSystemSource", true);
|
||||
|
||||
// XXXX REMOVE FOR PRODUCTION. Turns on GC and CC logging
|
||||
pref("javascript.options.mem.log", false);
|
||||
|
||||
|
@ -2656,7 +2656,8 @@ nsXULPrototypeScript::Compile(const char16_t* aText,
|
||||
// If the script was inline, tell the JS parser to save source for
|
||||
// Function.prototype.toSource(). If it's out of line, we retrieve the
|
||||
// source from the files on demand.
|
||||
options.setSourceIsLazy(mOutOfLine);
|
||||
options.setSourcePolicy(mOutOfLine ? JS::CompileOptions::LAZY_SOURCE
|
||||
: JS::CompileOptions::SAVE_SOURCE);
|
||||
JS::Rooted<JSObject*> scope(cx, JS::CurrentGlobalOrNull(cx));
|
||||
if (scope) {
|
||||
JS::ExposeObjectToActiveJS(scope);
|
||||
|
@ -748,8 +748,7 @@ nsXULPDGlobalObject::GetCompilationGlobal()
|
||||
AutoSafeJSContext cx;
|
||||
JS::CompartmentOptions options;
|
||||
options.setZone(JS::SystemZone)
|
||||
.setInvisibleToDebugger(true)
|
||||
.setDiscardSource(xpc::ShouldDiscardSystemSource());
|
||||
.setInvisibleToDebugger(true);
|
||||
mJSObject = JS_NewGlobalObject(cx, &gSharedGlobalClass,
|
||||
nsJSPrincipals::get(GetPrincipal()),
|
||||
JS::DontFireOnNewGlobalHook, options);
|
||||
|
@ -699,20 +699,6 @@ ScriptExecutorRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
NS_ASSERTION(global, "Must have a global by now!");
|
||||
|
||||
// Determine whether we want to be discarding source on this global to save
|
||||
// memory. It would make more sense to do this when we create the global, but
|
||||
// the information behind UsesSystemPrincipal() et al isn't finalized until
|
||||
// the call to SetPrincipal during the first script load. After that, however,
|
||||
// it never changes. So we can just idempotently set the bits here.
|
||||
//
|
||||
// Note that we read a pref that is cached on the main thread. This is benignly
|
||||
// racey.
|
||||
if (xpc::ShouldDiscardSystemSource()) {
|
||||
bool discard = aWorkerPrivate->UsesSystemPrincipal() ||
|
||||
aWorkerPrivate->IsInPrivilegedApp();
|
||||
JS::CompartmentOptionsRef(global).setDiscardSource(discard);
|
||||
}
|
||||
|
||||
for (uint32_t index = mFirstIndex; index <= mLastIndex; index++) {
|
||||
ScriptLoadInfo& loadInfo = loadInfos.ElementAt(index);
|
||||
|
||||
|
@ -168,8 +168,7 @@ nsXBLDocGlobalObject::GetCompilationGlobal()
|
||||
AutoSafeJSContext cx;
|
||||
JS::CompartmentOptions options;
|
||||
options.setZone(JS::SystemZone)
|
||||
.setInvisibleToDebugger(true)
|
||||
.setDiscardSource(xpc::ShouldDiscardSystemSource());
|
||||
.setInvisibleToDebugger(true);
|
||||
mJSObject = JS_NewGlobalObject(cx, &gSharedGlobalClass,
|
||||
nsJSPrincipals::get(GetPrincipal()),
|
||||
JS::DontFireOnNewGlobalHook,
|
||||
|
@ -146,8 +146,7 @@ CanLazilyParse(ExclusiveContext *cx, const ReadOnlyCompileOptions &options)
|
||||
{
|
||||
return options.canLazilyParse &&
|
||||
options.compileAndGo &&
|
||||
!cx->compartment()->options().discardSource() &&
|
||||
!options.sourceIsLazy &&
|
||||
options.sourcePolicy == CompileOptions::SAVE_SOURCE &&
|
||||
!(cx->compartment()->debugMode() &&
|
||||
cx->compartment()->runtimeFromAnyThread()->debugHooks.newScriptHook);
|
||||
}
|
||||
@ -213,7 +212,7 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
|
||||
|
||||
if (!CheckLength(cx, length))
|
||||
return nullptr;
|
||||
JS_ASSERT_IF(staticLevel != 0, !options.sourceIsLazy);
|
||||
JS_ASSERT_IF(staticLevel != 0, options.sourcePolicy != CompileOptions::LAZY_SOURCE);
|
||||
|
||||
RootedScriptSource sourceObject(cx, CreateScriptSourceObject(cx, options));
|
||||
if (!sourceObject)
|
||||
@ -224,11 +223,16 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
|
||||
SourceCompressionTask mysct(cx);
|
||||
SourceCompressionTask *sct = extraSct ? extraSct : &mysct;
|
||||
|
||||
if (!cx->compartment()->options().discardSource()) {
|
||||
if (options.sourceIsLazy)
|
||||
ss->setSourceRetrievable();
|
||||
else if (!ss->setSourceCopy(cx, chars, length, false, sct))
|
||||
switch (options.sourcePolicy) {
|
||||
case CompileOptions::SAVE_SOURCE:
|
||||
if (!ss->setSourceCopy(cx, chars, length, false, sct))
|
||||
return nullptr;
|
||||
break;
|
||||
case CompileOptions::LAZY_SOURCE:
|
||||
ss->setSourceRetrievable();
|
||||
break;
|
||||
case CompileOptions::NO_SOURCE:
|
||||
break;
|
||||
}
|
||||
|
||||
bool canLazilyParse = CanLazilyParse(cx, options);
|
||||
@ -513,8 +517,8 @@ CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, const ReadOnlyComp
|
||||
ScriptSource *ss = sourceObject->source();
|
||||
|
||||
SourceCompressionTask sct(cx);
|
||||
JS_ASSERT(!options.sourceIsLazy);
|
||||
if (!cx->compartment()->options().discardSource()) {
|
||||
JS_ASSERT(options.sourcePolicy != CompileOptions::LAZY_SOURCE);
|
||||
if (options.sourcePolicy == CompileOptions::SAVE_SOURCE) {
|
||||
if (!ss->setSourceCopy(cx, chars, length, true, &sct))
|
||||
return false;
|
||||
}
|
||||
|
@ -35,20 +35,20 @@ withSourceHook(function (url) {
|
||||
}, function () {
|
||||
log += 'I';
|
||||
return evaluate('(function inner() { 2; })',
|
||||
{ fileName: 'inner', sourceIsLazy: true })
|
||||
{ fileName: 'inner', sourcePolicy: 'LAZY_SOURCE' })
|
||||
.toSource();
|
||||
}),
|
||||
'(function inner() { 1; })');
|
||||
// Verify that the source hook that throws has been reinstated.
|
||||
evaluate('(function middle() { })',
|
||||
{ fileName: 'middle', sourceIsLazy: true })
|
||||
{ fileName: 'middle', sourcePolicy: 'LAZY_SOURCE' })
|
||||
.toSource();
|
||||
});
|
||||
}, 'borborygmus');
|
||||
|
||||
// Verify that the outermost source hook has been restored.
|
||||
assertEq(evaluate('(function outer() { 4; })',
|
||||
{ fileName: 'outer', sourceIsLazy: true })
|
||||
{ fileName: 'outer', sourcePolicy: 'LAZY_SOURCE' })
|
||||
.toSource(),
|
||||
'(function outer() { 3; })');
|
||||
});
|
||||
|
@ -28,7 +28,7 @@ function test(source) {
|
||||
}
|
||||
|
||||
g.evaluate(source, { fileName: "BanalBivalve.jsm",
|
||||
sourceIsLazy: true });
|
||||
sourcePolicy: "LAZY_SOURCE"});
|
||||
});
|
||||
|
||||
assertEq(log, 'ds');
|
||||
|
@ -9,7 +9,7 @@
|
||||
BEGIN_TEST(testBug795104)
|
||||
{
|
||||
JS::CompileOptions opts(cx);
|
||||
JS::CompartmentOptionsRef(cx->compartment()).setDiscardSource(true);
|
||||
opts.setSourcePolicy(JS::CompileOptions::NO_SOURCE);
|
||||
const size_t strLen = 60002;
|
||||
char *s = static_cast<char *>(JS_malloc(cx, strLen));
|
||||
CHECK(s);
|
||||
|
@ -2479,12 +2479,6 @@ JS::CompartmentOptionsRef(JSCompartment *compartment)
|
||||
return compartment->options();
|
||||
}
|
||||
|
||||
JS::CompartmentOptions &
|
||||
JS::CompartmentOptionsRef(JSObject *obj)
|
||||
{
|
||||
return obj->compartment()->options();
|
||||
}
|
||||
|
||||
JS::CompartmentOptions &
|
||||
JS::CompartmentOptionsRef(JSContext *cx)
|
||||
{
|
||||
@ -4354,7 +4348,7 @@ JS::ReadOnlyCompileOptions::copyPODOptions(const ReadOnlyCompileOptions &rhs)
|
||||
asmJSOption = rhs.asmJSOption;
|
||||
forceAsync = rhs.forceAsync;
|
||||
installedFile = rhs.installedFile;
|
||||
sourceIsLazy = rhs.sourceIsLazy;
|
||||
sourcePolicy = rhs.sourcePolicy;
|
||||
introductionType = rhs.introductionType;
|
||||
introductionLineno = rhs.introductionLineno;
|
||||
introductionOffset = rhs.introductionOffset;
|
||||
|
@ -2549,7 +2549,6 @@ class JS_PUBLIC_API(CompartmentOptions)
|
||||
: version_(JSVERSION_UNKNOWN)
|
||||
, invisibleToDebugger_(false)
|
||||
, mergeable_(false)
|
||||
, discardSource_(false)
|
||||
, traceGlobal_(nullptr)
|
||||
, singletonsAsTemplates_(true)
|
||||
{
|
||||
@ -2583,15 +2582,6 @@ class JS_PUBLIC_API(CompartmentOptions)
|
||||
return *this;
|
||||
}
|
||||
|
||||
// For certain globals, we know enough about the code that will run in them
|
||||
// that we can discard script source entirely.
|
||||
bool discardSource() const { return discardSource_; }
|
||||
CompartmentOptions &setDiscardSource(bool flag) {
|
||||
discardSource_ = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool cloneSingletons(JSContext *cx) const;
|
||||
Override &cloneSingletonsOverride() { return cloneSingletonsOverride_; }
|
||||
|
||||
@ -2622,7 +2612,6 @@ class JS_PUBLIC_API(CompartmentOptions)
|
||||
JSVersion version_;
|
||||
bool invisibleToDebugger_;
|
||||
bool mergeable_;
|
||||
bool discardSource_;
|
||||
Override cloneSingletonsOverride_;
|
||||
union {
|
||||
ZoneSpecifier spec;
|
||||
@ -2639,9 +2628,6 @@ class JS_PUBLIC_API(CompartmentOptions)
|
||||
JS_PUBLIC_API(CompartmentOptions &)
|
||||
CompartmentOptionsRef(JSCompartment *compartment);
|
||||
|
||||
JS_PUBLIC_API(CompartmentOptions &)
|
||||
CompartmentOptionsRef(JSObject *obj);
|
||||
|
||||
JS_PUBLIC_API(CompartmentOptions &)
|
||||
CompartmentOptionsRef(JSContext *cx);
|
||||
|
||||
@ -3416,7 +3402,7 @@ class JS_FRIEND_API(ReadOnlyCompileOptions)
|
||||
asmJSOption(false),
|
||||
forceAsync(false),
|
||||
installedFile(false),
|
||||
sourceIsLazy(false),
|
||||
sourcePolicy(SAVE_SOURCE),
|
||||
introductionType(nullptr),
|
||||
introductionLineno(0),
|
||||
introductionOffset(0),
|
||||
@ -3456,7 +3442,11 @@ class JS_FRIEND_API(ReadOnlyCompileOptions)
|
||||
bool asmJSOption;
|
||||
bool forceAsync;
|
||||
bool installedFile; // 'true' iff pre-compiling js file in packaged app
|
||||
bool sourceIsLazy;
|
||||
enum SourcePolicy {
|
||||
NO_SOURCE,
|
||||
LAZY_SOURCE,
|
||||
SAVE_SOURCE
|
||||
} sourcePolicy;
|
||||
|
||||
// |introductionType| is a statically allocated C string:
|
||||
// one of "eval", "Function", or "GeneratorFunction".
|
||||
@ -3548,7 +3538,7 @@ class JS_FRIEND_API(OwningCompileOptions) : public ReadOnlyCompileOptions
|
||||
OwningCompileOptions &setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; }
|
||||
OwningCompileOptions &setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; }
|
||||
OwningCompileOptions &setCanLazilyParse(bool clp) { canLazilyParse = clp; return *this; }
|
||||
OwningCompileOptions &setSourceIsLazy(bool l) { sourceIsLazy = l; return *this; }
|
||||
OwningCompileOptions &setSourcePolicy(SourcePolicy sp) { sourcePolicy = sp; return *this; }
|
||||
OwningCompileOptions &setIntroductionType(const char *t) { introductionType = t; return *this; }
|
||||
bool setIntroductionInfo(JSContext *cx, const char *introducerFn, const char *intro,
|
||||
unsigned line, JSScript *script, uint32_t offset)
|
||||
@ -3634,7 +3624,7 @@ class MOZ_STACK_CLASS JS_FRIEND_API(CompileOptions) : public ReadOnlyCompileOpti
|
||||
CompileOptions &setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; }
|
||||
CompileOptions &setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; }
|
||||
CompileOptions &setCanLazilyParse(bool clp) { canLazilyParse = clp; return *this; }
|
||||
CompileOptions &setSourceIsLazy(bool l) { sourceIsLazy = l; return *this; }
|
||||
CompileOptions &setSourcePolicy(SourcePolicy sp) { sourcePolicy = sp; return *this; }
|
||||
CompileOptions &setIntroductionType(const char *t) { introductionType = t; return *this; }
|
||||
CompileOptions &setIntroductionInfo(const char *introducerFn, const char *intro,
|
||||
unsigned line, JSScript *script, uint32_t offset)
|
||||
|
@ -383,13 +383,13 @@ proxy_Slice(JSContext *cx, JS::HandleObject proxy, uint32_t begin, uint32_t end,
|
||||
/*
|
||||
* A class of objects that return source code on demand.
|
||||
*
|
||||
* When code is compiled with setSourceIsLazy(true), SpiderMonkey doesn't
|
||||
* retain the source code (and doesn't do lazy bytecode generation). If we ever
|
||||
* need the source code, say, in response to a call to Function.prototype.
|
||||
* toSource or Debugger.Source.prototype.text, then we call the 'load' member
|
||||
* function of the instance of this class that has hopefully been registered
|
||||
* with the runtime, passing the code's URL, and hope that it will be able to
|
||||
* find the source.
|
||||
* When code is compiled with CompileOptions::LAZY_SOURCE, SpiderMonkey
|
||||
* doesn't retain the source code (and doesn't do lazy bytecode
|
||||
* generation). If we ever need the source code, say, in response to a call
|
||||
* to Function.prototype.toSource or Debugger.Source.prototype.text, then
|
||||
* we call the 'load' member function of the instance of this class that
|
||||
* has hopefully been registered with the runtime, passing the code's URL,
|
||||
* and hope that it will be able to find the source.
|
||||
*/
|
||||
class SourceHook {
|
||||
public:
|
||||
@ -404,7 +404,7 @@ class SourceHook {
|
||||
};
|
||||
|
||||
/*
|
||||
* Have |rt| use |hook| to retrieve lazily-retrieved source code. See the
|
||||
* Have |rt| use |hook| to retrieve LAZY_SOURCE source code. See the
|
||||
* comments for SourceHook. The runtime takes ownership of the hook, and
|
||||
* will delete it when the runtime itself is deleted, or when a new hook is
|
||||
* set.
|
||||
|
@ -866,10 +866,28 @@ ParseCompileOptions(JSContext *cx, CompileOptions &options, HandleObject opts,
|
||||
options.setLine(u);
|
||||
}
|
||||
|
||||
if (!JS_GetProperty(cx, opts, "sourceIsLazy", &v))
|
||||
if (!JS_GetProperty(cx, opts, "sourcePolicy", &v))
|
||||
return false;
|
||||
if (v.isBoolean())
|
||||
options.setSourceIsLazy(v.toBoolean());
|
||||
if (!v.isUndefined()) {
|
||||
RootedString s(cx, ToString(cx, v));
|
||||
if (!s)
|
||||
return false;
|
||||
|
||||
JSAutoByteString bytes;
|
||||
char *policy = bytes.encodeUtf8(cx, s);
|
||||
if (!policy)
|
||||
return false;
|
||||
if (strcmp(policy, "NO_SOURCE") == 0) {
|
||||
options.setSourcePolicy(CompileOptions::NO_SOURCE);
|
||||
} else if (strcmp(policy, "LAZY_SOURCE") == 0) {
|
||||
options.setSourcePolicy(CompileOptions::LAZY_SOURCE);
|
||||
} else if (strcmp(policy, "SAVE_SOURCE") == 0) {
|
||||
options.setSourcePolicy(CompileOptions::SAVE_SOURCE);
|
||||
} else {
|
||||
JS_ReportError(cx, "bad 'sourcePolicy' option: '%s'", policy);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -3619,7 +3637,7 @@ OffThreadCompileScript(JSContext *cx, unsigned argc, jsval *vp)
|
||||
|
||||
// These option settings must override whatever the caller requested.
|
||||
options.setCompileAndGo(true)
|
||||
.setSourceIsLazy(false);
|
||||
.setSourcePolicy(CompileOptions::SAVE_SOURCE);
|
||||
|
||||
// We assume the caller wants caching if at all possible, ignoring
|
||||
// heuristics that make sense for a real browser.
|
||||
@ -4372,9 +4390,9 @@ static const JSFunctionSpecWithHelp shell_functions[] = {
|
||||
" provide that as the code's source map URL. If omitted, attach no\n"
|
||||
" source map URL to the code (although the code may provide one itself,\n"
|
||||
" via a //#sourceMappingURL comment).\n"
|
||||
" sourceIsLazy: if present and true, indicates that, after compilation, \n"
|
||||
"script source should not be cached by the JS engine and should be \n"
|
||||
"lazily loaded from the embedding as-needed.\n"
|
||||
" sourcePolicy: if present, the value converted to a string must be either\n"
|
||||
" 'NO_SOURCE', 'LAZY_SOURCE', or 'SAVE_SOURCE'; use the given source\n"
|
||||
" retention policy for this compilation.\n"
|
||||
" loadBytecode: if true, and if the source is a CacheEntryObject,\n"
|
||||
" the bytecode would be loaded and decoded from the cache entry instead\n"
|
||||
" of being parsed, then it would be executed as usual.\n"
|
||||
|
@ -904,6 +904,7 @@ js::FillSelfHostingCompileOptions(CompileOptions &options)
|
||||
options.setFileAndLine("self-hosted", 1);
|
||||
options.setSelfHostingMode(true);
|
||||
options.setCanLazilyParse(false);
|
||||
options.setSourcePolicy(CompileOptions::NO_SOURCE);
|
||||
options.setVersion(JSVERSION_LATEST);
|
||||
options.werrorOption = true;
|
||||
options.strictOption = true;
|
||||
@ -933,11 +934,8 @@ JSRuntime::initSelfHosting(JSContext *cx)
|
||||
RootedObject savedGlobal(cx, receivesDefaultObject
|
||||
? js::DefaultObjectForContextOrNull(cx)
|
||||
: nullptr);
|
||||
JS::CompartmentOptions compartmentOptions;
|
||||
compartmentOptions.setDiscardSource(true);
|
||||
if (!(selfHostingGlobal_ = JS_NewGlobalObject(cx, &self_hosting_global_class,
|
||||
nullptr, JS::DontFireOnNewGlobalHook,
|
||||
compartmentOptions)))
|
||||
nullptr, JS::DontFireOnNewGlobalHook)))
|
||||
return false;
|
||||
JSAutoCompartment ac(cx, selfHostingGlobal_);
|
||||
if (receivesDefaultObject)
|
||||
|
@ -814,16 +814,13 @@ mozJSComponentLoader::ObjectForLocation(nsIFile *aComponentFile,
|
||||
if (aPropagateExceptions)
|
||||
ContextOptionsRef(cx).setDontReportUncaught(true);
|
||||
|
||||
// Note - if mReuseLoaderGlobal is true, then we can't do lazy source,
|
||||
// because we compile things as functions (rather than script), and lazy
|
||||
// source isn't supported in that configuration. That's ok though,
|
||||
// because we only do mReuseLoaderGlobal on b2g, where we invoke
|
||||
// setDiscardSource(true) on the entire global.
|
||||
CompileOptions options(cx);
|
||||
options.setNoScriptRval(mReuseLoaderGlobal ? false : true)
|
||||
.setVersion(JSVERSION_LATEST)
|
||||
.setFileAndLine(nativePath.get(), 1)
|
||||
.setSourceIsLazy(!mReuseLoaderGlobal);
|
||||
.setSourcePolicy(mReuseLoaderGlobal ?
|
||||
CompileOptions::NO_SOURCE :
|
||||
CompileOptions::LAZY_SOURCE);
|
||||
|
||||
if (realFile) {
|
||||
#ifdef HAVE_PR_MEMMAP
|
||||
|
@ -164,10 +164,10 @@ mozJSSubScriptLoader::ReadScript(nsIURI *uri, JSContext *cx, JSObject *targetObj
|
||||
script.Length());
|
||||
}
|
||||
} else {
|
||||
// We only use lazy source when no special encoding is specified because
|
||||
// We only use LAZY_SOURCE when no special encoding is specified because
|
||||
// the lazy source loader doesn't know the encoding.
|
||||
if (!reuseGlobal) {
|
||||
options.setSourceIsLazy(true);
|
||||
options.setSourcePolicy(JS::CompileOptions::LAZY_SOURCE);
|
||||
*scriptp = JS::Compile(cx, target_obj, options, buf.get(), len);
|
||||
} else {
|
||||
*functionp = JS::CompileFunction(cx, target_obj, options,
|
||||
@ -498,6 +498,7 @@ ScriptPrecompiler::OnStreamComplete(nsIStreamLoader* aLoader,
|
||||
JSAutoCompartment ac(cx, js::UncheckedUnwrap(&v.toObject()));
|
||||
|
||||
JS::CompileOptions options(cx, JSVERSION_DEFAULT);
|
||||
options.setSourcePolicy(CompileOptions::NO_SOURCE);
|
||||
options.forceAsync = true;
|
||||
options.compileAndGo = true;
|
||||
options.installedFile = true;
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/WindowBinding.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "AccessCheck.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
@ -85,10 +84,11 @@ const char* const XPCJSRuntime::mStrings[] = {
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static mozilla::Atomic<bool> sDiscardSystemSource(false);
|
||||
|
||||
bool
|
||||
xpc::ShouldDiscardSystemSource() { return sDiscardSystemSource; }
|
||||
struct CX_AND_XPCRT_Data
|
||||
{
|
||||
JSContext* cx;
|
||||
XPCJSRuntime* rt;
|
||||
};
|
||||
|
||||
static void * const UNMARK_ONLY = nullptr;
|
||||
static void * const UNMARK_AND_SWEEP = (void *)1;
|
||||
@ -1552,8 +1552,6 @@ ReloadPrefsCallback(const char *pref, void *data)
|
||||
"baselinejit.unsafe_eager_compilation");
|
||||
bool useIonEager = Preferences::GetBool(JS_OPTIONS_DOT_STR "ion.unsafe_eager_compilation");
|
||||
|
||||
sDiscardSystemSource = Preferences::GetBool(JS_OPTIONS_DOT_STR "discardSystemSource");
|
||||
|
||||
JS::RuntimeOptionsRef(rt).setBaseline(useBaseline)
|
||||
.setIon(useIon)
|
||||
. setAsmJS(useAsmJS);
|
||||
|
@ -1550,11 +1550,6 @@ XRE_XPCShellMain(int argc, char **argv, char **envp)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Even if we're building in a configuration where source is
|
||||
// discarded, there's no reason to do that on XPCShell, and doing so
|
||||
// might break various automation scripts.
|
||||
JS::CompartmentOptionsRef(glob).setDiscardSource(false);
|
||||
|
||||
backstagePass->SetGlobalObject(glob);
|
||||
|
||||
JSAutoCompartment ac(cx, glob);
|
||||
|
@ -414,17 +414,6 @@ InitGlobalObject(JSContext* aJSContext, JS::Handle<JSObject*> aGlobal, uint32_t
|
||||
}
|
||||
}
|
||||
|
||||
if (ShouldDiscardSystemSource()) {
|
||||
nsIPrincipal *prin = GetObjectPrincipal(aGlobal);
|
||||
bool isSystem = nsContentUtils::IsSystemPrincipal(prin);
|
||||
if (!isSystem) {
|
||||
short status = prin->GetAppStatus();
|
||||
isSystem = status == nsIPrincipal::APP_STATUS_PRIVILEGED ||
|
||||
status == nsIPrincipal::APP_STATUS_CERTIFIED;
|
||||
}
|
||||
JS::CompartmentOptionsRef(aGlobal).setDiscardSource(isSystem);
|
||||
}
|
||||
|
||||
// Stuff coming through this path always ends up as a DOM global.
|
||||
MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL);
|
||||
|
||||
|
@ -470,11 +470,6 @@ RecordAdoptedNode(JSCompartment *c);
|
||||
void
|
||||
RecordDonatedNode(JSCompartment *c);
|
||||
|
||||
// This function may be used off-main-thread, in which case it is benignly
|
||||
// racey.
|
||||
bool
|
||||
ShouldDiscardSystemSource();
|
||||
|
||||
} // namespace xpc
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -3,8 +3,6 @@ support-files =
|
||||
bug503926.xul
|
||||
file_bug618176.xul
|
||||
file_bug996069.html
|
||||
file_discardSystemSource.html
|
||||
worker_discardSystemSource.js
|
||||
file_evalInSandbox.html
|
||||
file_expandosharing.jsm
|
||||
outoflinexulscript.js
|
||||
@ -59,7 +57,6 @@ support-files =
|
||||
[test_chrometoSource.xul]
|
||||
[test_cloneInto.xul]
|
||||
[test_cows.xul]
|
||||
[test_discardSystemSource.xul]
|
||||
[test_documentdomain.xul]
|
||||
[test_doublewrappedcompartments.xul]
|
||||
[test_evalInSandbox.xul]
|
||||
|
@ -1,18 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function canary() {
|
||||
var someBitOfSource = 42;
|
||||
}
|
||||
function inner() {
|
||||
throw new Error("some error");
|
||||
}
|
||||
function throwSomething() {
|
||||
inner();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="someBitOfSource = 42">
|
||||
</body>
|
||||
</html>
|
@ -1,4 +0,0 @@
|
||||
[DEFAULT]
|
||||
support-files =
|
||||
file_discardSystemSource.html
|
||||
worker_discardSystemSource.js
|
@ -1,9 +0,0 @@
|
||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
|
||||
MOCHITEST_MANIFESTS += ['mochitest.ini']
|
||||
|
@ -1,78 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=990353
|
||||
-->
|
||||
<window title="Mozilla Bug 990353"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=990353"
|
||||
target="_blank">Mozilla Bug 990353</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
/** Test for Bug 990353 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
const Cu = Components.utils;
|
||||
|
||||
function canary() {
|
||||
var someBitOfSource = 42;
|
||||
}
|
||||
|
||||
var gLoadCount = 0;
|
||||
function frameLoaded() {
|
||||
switch (++gLoadCount) {
|
||||
case 1:
|
||||
ok(/sourceless/.test(window[0].canary.toSource()), "System function should be sourceless: " + window[0].canary.toSource());
|
||||
ok(/sourceless/.test(window[0].onload.toSource()), "System event handler should be sourceless: " + window[0].onload.toSource());
|
||||
try {
|
||||
window[0].throwSomething();
|
||||
ok(false, "should have thrown");
|
||||
} catch (e) {
|
||||
ok(/some error/.test(e), "Threw exception as expected: " + e);
|
||||
ok(/throwSomething/.test(e.stack), "Exception stack trace works: " + e.stack);
|
||||
}
|
||||
window[0].location = "http://example.org/tests/js/xpconnect/tests/chrome/file_discardSystemSource.html";
|
||||
break;
|
||||
case 2:
|
||||
ok(/someBitOfSource/.test(Cu.waiveXrays(window[0]).canary.toSource()), "Content function should have source");
|
||||
ok(/someBitOfSource/.test(Cu.waiveXrays(window[0]).onload.toSource()), "Content event handler should have source");
|
||||
testWorker();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function testWorker() {
|
||||
var worker = new window[0].wrappedJSObject.Worker('worker_discardSystemSource.js');
|
||||
worker.onmessage = function(evt) {
|
||||
ok(/someBitOfSource/.test(evt.data), "Non-chrome worker should have source: " + evt.data);
|
||||
var chromeWorker = new Worker('worker_discardSystemSource.js');
|
||||
chromeWorker.onmessage = function(evt) {
|
||||
ok(/sourceless/.test(evt.data), "Chrome worker should not have source: " + evt.data);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function go() {
|
||||
// We should have our own source, because the pref wasn't enabled when we
|
||||
// were loaded.
|
||||
ok(/someBitOfSource/.test(canary.toSource()), "Should have own source");
|
||||
|
||||
window[0].frameElement.onload = frameLoaded;
|
||||
window[0].location = "file_discardSystemSource.html";
|
||||
}
|
||||
addLoadEvent(function() {
|
||||
SpecialPowers.pushPrefEnv({set: [['javascript.options.discardSystemSource', true]]}, go);
|
||||
});
|
||||
|
||||
]]>
|
||||
</script>
|
||||
<iframe></iframe>
|
||||
</window>
|
@ -1,5 +0,0 @@
|
||||
function canary() {
|
||||
var someBitOfSource = 42;
|
||||
}
|
||||
|
||||
postMessage(canary.toSource());
|
@ -7,11 +7,11 @@
|
||||
TEST_TOOL_DIRS += [
|
||||
'idl',
|
||||
'mochitest',
|
||||
'chrome',
|
||||
'browser',
|
||||
'components/native',
|
||||
'components/js',
|
||||
]
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
|
||||
MOCHITEST_CHROME_MANIFESTS += ['chrome/chrome.ini']
|
||||
|
||||
|
@ -781,11 +781,6 @@ pref("javascript.options.ion", true);
|
||||
pref("javascript.options.asmjs", true);
|
||||
pref("javascript.options.parallel_parsing", true);
|
||||
pref("javascript.options.ion.parallel_compilation", true);
|
||||
// This preference instructs the JS engine to discard the
|
||||
// source of any privileged JS after compilation. This saves
|
||||
// memory, but makes things like Function.prototype.toSource()
|
||||
// fail.
|
||||
pref("javascript.options.discardSystemSource", false);
|
||||
// This preference limits the memory usage of javascript.
|
||||
// If you want to change these values for your device,
|
||||
// please find Bug 417052 comment 17 and Bug 456721
|
||||
|
Loading…
Reference in New Issue
Block a user