Bug 1204863 - Ignore frames from self-hosted scripts; r=shu

This commit is contained in:
Nick Fitzgerald 2015-09-29 09:03:14 -07:00
parent 6482c81f9b
commit 797b65ebd2
3 changed files with 17 additions and 2 deletions

View File

@ -37,6 +37,10 @@ it ought not to introduce security holes, so in principle it could be made
available to content as well; but it is hard to justify the security risks
of the additional attack surface.
The `Debugger` API cannot currently observe self-hosted JavaScript. This is not
inherent in the API's design, but simply that the self-hosting infrastructure
isn't prepared for the kind of invasions the `Debugger` API can perform.
## Debugger Instances and Shadow Objects

View File

@ -0,0 +1,5 @@
var dbg = newGlobal().Debugger(this);
dbg.onExceptionUnwind = function (frame, exc) {
return { return:"sproon" };
};
Intl.Collator.supportedLocalesOf([2]);

View File

@ -455,6 +455,7 @@ Debugger::getScriptFrameWithIter(JSContext* cx, AbstractFramePtr frame,
const ScriptFrameIter* maybeIter, MutableHandleValue vp)
{
MOZ_ASSERT_IF(maybeIter, maybeIter->abstractFramePtr() == frame);
MOZ_ASSERT(!frame.script()->selfHosted());
FrameMap::AddPtr p = frames.lookupForAdd(frame);
if (!p) {
@ -726,6 +727,10 @@ Debugger::slowPathOnExceptionUnwind(JSContext* cx, AbstractFramePtr frame)
if (cx->isThrowingOverRecursed() || cx->isThrowingOutOfMemory())
return JSTRAP_CONTINUE;
// The Debugger API mustn't muck with frames from self-hosted scripts.
if (frame.script()->selfHosted())
return JSTRAP_CONTINUE;
RootedValue rval(cx);
JSTrapStatus status = dispatchHook(
cx,
@ -5265,8 +5270,9 @@ Debugger::observesScript(JSScript* script) const
{
if (!enabled)
return false;
return observesGlobal(&script->global()) && (!script->selfHosted() ||
SelfHostedFramesVisible());
// Don't ever observe self-hosted scripts: the Debugger API can break
// self-hosted invariants.
return observesGlobal(&script->global()) && !script->selfHosted();
}
/* static */ bool