Bug 946813 - Part 1: Expose invisibleToDebugger as a sandbox flag. r=bholley

--HG--
extra : rebase_source : 7d4963efc10423bb3e451da0eb1f6a03d7531831
This commit is contained in:
J. Ryan Stinnett 2013-12-19 17:31:05 -06:00
parent dfcd4337d1
commit 440369fc24
3 changed files with 27 additions and 0 deletions

View File

@ -1053,6 +1053,9 @@ xpc::CreateSandboxObject(JSContext *cx, MutableHandleValue vp, nsISupports *prin
compartmentOptions.setSameZoneAs(js::UncheckedUnwrap(options.sameZoneAs));
else
compartmentOptions.setZone(JS::SystemZone);
compartmentOptions.setInvisibleToDebugger(options.invisibleToDebugger);
RootedObject sandbox(cx, xpc::CreateGlobalObject(cx, &SandboxClass,
principal, compartmentOptions));
if (!sandbox)
@ -1486,6 +1489,7 @@ SandboxOptions::Parse()
ParseBoolean("wantExportHelpers", &wantExportHelpers) &&
ParseString("sandboxName", sandboxName) &&
ParseObject("sameZoneAs", &sameZoneAs) &&
ParseBoolean("invisibleToDebugger", &invisibleToDebugger) &&
ParseGlobalProperties() &&
ParseValue("metadata", &metadata);
}

View File

@ -3425,6 +3425,7 @@ public:
, wantExportHelpers(false)
, proto(cx)
, sameZoneAs(cx)
, invisibleToDebugger(false)
, metadata(cx)
{ }
@ -3436,6 +3437,7 @@ public:
JS::RootedObject proto;
nsCString sandboxName;
JS::RootedObject sameZoneAs;
bool invisibleToDebugger;
GlobalProperties globalProperties;
JS::RootedValue metadata;

View File

@ -150,5 +150,26 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=533596
catch (e) {
ok(false, "sameZoneAs works");
}
Cu.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
try {
let dbg = new Debugger();
let sandbox = new Cu.Sandbox(this, { invisibleToDebugger: false });
dbg.addDebuggee(sandbox);
ok(true, "debugger added visible value");
} catch(e) {
ok(false, "debugger could not add visible value");
}
try {
let dbg = new Debugger();
let sandbox = new Cu.Sandbox(this, { invisibleToDebugger: true });
dbg.addDebuggee(sandbox);
ok(false, "debugger added invisible value");
} catch(e) {
ok(true, "debugger did not add invisible value");
}
]]></script>
</window>