mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 990353 - Make discardSource a Sandbox option and use it (even in Desktop) for the precompilation scope. r=luke
This commit is contained in:
parent
ca3c38f39b
commit
415f46fd09
@ -492,6 +492,7 @@ ScriptPrecompiler::OnStreamComplete(nsIStreamLoader* aLoader,
|
||||
SandboxOptions sandboxOptions;
|
||||
sandboxOptions.sandboxName.AssignASCII("asm.js precompilation");
|
||||
sandboxOptions.invisibleToDebugger = true;
|
||||
sandboxOptions.discardSource = true;
|
||||
rv = CreateSandboxObject(cx, &v, mPrincipal, sandboxOptions);
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
|
||||
|
@ -1085,6 +1085,7 @@ xpc::CreateSandboxObject(JSContext *cx, MutableHandleValue vp, nsISupports *prin
|
||||
compartmentOptions.setZone(JS::SystemZone);
|
||||
|
||||
compartmentOptions.setInvisibleToDebugger(options.invisibleToDebugger)
|
||||
.setDiscardSource(options.discardSource)
|
||||
.setTrace(TraceXPCGlobal);
|
||||
|
||||
RootedObject sandbox(cx, xpc::CreateGlobalObject(cx, &SandboxClass,
|
||||
@ -1518,6 +1519,7 @@ SandboxOptions::Parse()
|
||||
ParseString("sandboxName", sandboxName) &&
|
||||
ParseObject("sameZoneAs", &sameZoneAs) &&
|
||||
ParseBoolean("invisibleToDebugger", &invisibleToDebugger) &&
|
||||
ParseBoolean("discardSource", &discardSource) &&
|
||||
ParseGlobalProperties() &&
|
||||
ParseValue("metadata", &metadata);
|
||||
}
|
||||
|
@ -3505,12 +3505,12 @@ XPCJSRuntime::GetCompilationScope()
|
||||
SandboxOptions options;
|
||||
options.sandboxName.AssignLiteral("XPConnect Compilation Compartment");
|
||||
options.invisibleToDebugger = true;
|
||||
options.discardSource = ShouldDiscardSystemSource();
|
||||
RootedValue v(cx);
|
||||
nsresult rv = CreateSandboxObject(cx, &v, /* principal = */ nullptr, options);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
mCompilationScope = js::UncheckedUnwrap(&v.toObject());
|
||||
CompartmentOptionsRef(mCompilationScope).setDiscardSource(ShouldDiscardSystemSource());
|
||||
}
|
||||
return mCompilationScope;
|
||||
}
|
||||
|
@ -3349,6 +3349,7 @@ public:
|
||||
, proto(cx)
|
||||
, sameZoneAs(cx)
|
||||
, invisibleToDebugger(false)
|
||||
, discardSource(false)
|
||||
, globalProperties(true)
|
||||
, metadata(cx)
|
||||
{ }
|
||||
@ -3362,6 +3363,7 @@ public:
|
||||
nsCString sandboxName;
|
||||
JS::RootedObject sameZoneAs;
|
||||
bool invisibleToDebugger;
|
||||
bool discardSource;
|
||||
GlobalProperties globalProperties;
|
||||
JS::RootedValue metadata;
|
||||
|
||||
|
@ -31,6 +31,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990353
|
||||
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());
|
||||
var sb = new Cu.Sandbox('http://www.example.com', { discardSource: true });
|
||||
Cu.evalInSandbox('function canary() { var someBitOfSource = 42; }', sb);
|
||||
ok(/sourceless/.test(sb.canary.toSource()), "Function from sandbox with explicit discarding should be sourceless");
|
||||
try {
|
||||
window[0].throwSomething();
|
||||
ok(false, "should have thrown");
|
||||
|
Loading…
Reference in New Issue
Block a user