mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Remove simple JS_FrameIterator use from content, DOM, and caps (bug 744617, r=mrbkap).
--HG-- extra : rebase_source : 003a5285b549845d47c9298606d737620db5bb3d
This commit is contained in:
parent
3fab15f4fb
commit
94ccb204aa
@ -611,23 +611,14 @@ nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(JSContext *cx)
|
||||
if (!evalOK) {
|
||||
// get the script filename, script sample, and line number
|
||||
// to log with the violation
|
||||
JSStackFrame *fp = nsnull;
|
||||
nsAutoString fileName;
|
||||
PRUint32 lineNum = 0;
|
||||
unsigned lineNum = 0;
|
||||
NS_NAMED_LITERAL_STRING(scriptSample, "call to eval() or related function blocked by CSP");
|
||||
|
||||
fp = JS_FrameIterator(cx, &fp);
|
||||
if (fp) {
|
||||
JSScript *script = JS_GetFrameScript(cx, fp);
|
||||
if (script) {
|
||||
const char *file = JS_GetScriptFilename(cx, script);
|
||||
if (file) {
|
||||
CopyUTF8toUTF16(nsDependentCString(file), fileName);
|
||||
}
|
||||
jsbytecode *pc = JS_GetFramePC(cx, fp);
|
||||
if (pc) {
|
||||
lineNum = JS_PCToLineNumber(cx, script, pc);
|
||||
}
|
||||
JSScript *script;
|
||||
if (JS_DescribeScriptedCaller(cx, &script, &lineNum)) {
|
||||
if (const char *file = JS_GetScriptFilename(cx, script)) {
|
||||
CopyUTF8toUTF16(nsDependentCString(file), fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5732,18 +5732,15 @@ nsContentUtils::CanAccessNativeAnon()
|
||||
sSecurityManager->GetCxSubjectPrincipalAndFrame(cx, &fp);
|
||||
NS_ENSURE_TRUE(principal, false);
|
||||
|
||||
JSScript *script = nsnull;
|
||||
if (!fp) {
|
||||
if (!JS_FrameIterator(cx, &fp)) {
|
||||
if (!JS_DescribeScriptedCaller(cx, &script, nsnull)) {
|
||||
// No code at all is running. So we must be arriving here as the result
|
||||
// of C++ code asking us to do something. Allow access.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Some code is running, we can't make the assumption, as above, but we
|
||||
// can't use a native frame, so clear fp.
|
||||
fp = nsnull;
|
||||
} else if (!JS_IsScriptFrame(cx, fp)) {
|
||||
fp = nsnull;
|
||||
} else if (JS_IsScriptFrame(cx, fp)) {
|
||||
script = JS_GetFrameScript(cx, fp);
|
||||
}
|
||||
|
||||
bool privileged;
|
||||
@ -5757,8 +5754,8 @@ nsContentUtils::CanAccessNativeAnon()
|
||||
// if they've been cloned into less privileged contexts.
|
||||
static const char prefix[] = "chrome://global/";
|
||||
const char *filename;
|
||||
if (fp && JS_IsScriptFrame(cx, fp) &&
|
||||
(filename = JS_GetScriptFilename(cx, JS_GetFrameScript(cx, fp))) &&
|
||||
if (script &&
|
||||
(filename = JS_GetScriptFilename(cx, script)) &&
|
||||
!strncmp(filename, prefix, ArrayLength(prefix) - 1)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1834,21 +1834,13 @@ PrintWarningOnConsole(JSContext *cx, const char *stringBundleProperty)
|
||||
return;
|
||||
}
|
||||
|
||||
JSStackFrame *fp, *iterator = nsnull;
|
||||
fp = ::JS_FrameIterator(cx, &iterator);
|
||||
PRUint32 lineno = 0;
|
||||
unsigned lineno = 0;
|
||||
JSScript *script;
|
||||
nsAutoString sourcefile;
|
||||
if (fp) {
|
||||
JSScript* script = ::JS_GetFrameScript(cx, fp);
|
||||
if (script) {
|
||||
const char* filename = ::JS_GetScriptFilename(cx, script);
|
||||
if (filename) {
|
||||
CopyUTF8toUTF16(nsDependentCString(filename), sourcefile);
|
||||
}
|
||||
jsbytecode* pc = ::JS_GetFramePC(cx, fp);
|
||||
if (pc) {
|
||||
lineno = ::JS_PCToLineNumber(cx, script, pc);
|
||||
}
|
||||
|
||||
if (JS_DescribeScriptedCaller(cx, &script, &lineno)) {
|
||||
if (const char *filename = ::JS_GetScriptFilename(cx, script)) {
|
||||
CopyUTF8toUTF16(nsDependentCString(filename), sourcefile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,11 +445,8 @@ NS_ScriptErrorReporter(JSContext *cx,
|
||||
// We don't want to report exceptions too eagerly, but warnings in the
|
||||
// absence of werror are swallowed whole, so report those now.
|
||||
if (!JSREPORT_IS_WARNING(report->flags)) {
|
||||
JSStackFrame * fp = nsnull;
|
||||
while ((fp = JS_FrameIterator(cx, &fp))) {
|
||||
if (JS_IsScriptFrame(cx, fp)) {
|
||||
return;
|
||||
}
|
||||
if (JS_DescribeScriptedCaller(cx, nsnull, nsnull)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
|
@ -67,35 +67,17 @@ JSBool
|
||||
nsJSUtils::GetCallingLocation(JSContext* aContext, const char* *aFilename,
|
||||
PRUint32* aLineno)
|
||||
{
|
||||
// Get the current filename and line number
|
||||
JSStackFrame* frame = nsnull;
|
||||
JSScript* script = nsnull;
|
||||
do {
|
||||
frame = ::JS_FrameIterator(aContext, &frame);
|
||||
unsigned lineno = 0;
|
||||
|
||||
if (frame) {
|
||||
script = ::JS_GetFrameScript(aContext, frame);
|
||||
}
|
||||
} while (frame && !script);
|
||||
|
||||
if (script) {
|
||||
const char* filename = ::JS_GetScriptFilename(aContext, script);
|
||||
|
||||
if (filename) {
|
||||
PRUint32 lineno = 0;
|
||||
jsbytecode* bytecode = ::JS_GetFramePC(aContext, frame);
|
||||
|
||||
if (bytecode) {
|
||||
lineno = ::JS_PCToLineNumber(aContext, script, bytecode);
|
||||
}
|
||||
|
||||
*aFilename = filename;
|
||||
*aLineno = lineno;
|
||||
return JS_TRUE;
|
||||
}
|
||||
if (!JS_DescribeScriptedCaller(aContext, &script, &lineno)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_FALSE;
|
||||
*aFilename = ::JS_GetScriptFilename(aContext, script);
|
||||
*aLineno = lineno;
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
nsIScriptGlobalObject *
|
||||
|
@ -136,15 +136,12 @@ ScriptErrorReporter(JSContext *cx,
|
||||
int i, j, k, n;
|
||||
char *prefix = NULL, *tmp;
|
||||
const char *ctmp;
|
||||
JSStackFrame * fp = nsnull;
|
||||
nsCOMPtr<nsIXPConnect> xpc;
|
||||
|
||||
// Don't report an exception from inner JS frames as the callers may intend
|
||||
// to handle it.
|
||||
while ((fp = JS_FrameIterator(cx, &fp))) {
|
||||
if (JS_IsScriptFrame(cx, fp)) {
|
||||
return;
|
||||
}
|
||||
if (JS_DescribeScriptedCaller(cx, nsnull, nsnull)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// In some cases cx->fp is null here so use XPConnect to tell us about inner
|
||||
|
Loading…
Reference in New Issue
Block a user