зеркало из https://github.com/mozilla/gecko-dev.git
Back out 316d6a49a603 and 98617f7b667b (bug 624621) for jsreftest failures
This commit is contained in:
Родитель
8e61642d6a
Коммит
6755b58eda
|
@ -120,7 +120,7 @@ public:
|
|||
nsString mScriptText; // Holds script for loaded scripts
|
||||
PRUint32 mJSVersion;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIPrincipal> mOriginPrincipal;
|
||||
nsCOMPtr<nsIURI> mFinalURI;
|
||||
PRInt32 mLineNo;
|
||||
};
|
||||
|
||||
|
@ -882,6 +882,8 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsIURI* uri = aRequest->mFinalURI ? aRequest->mFinalURI : aRequest->mURI;
|
||||
|
||||
bool oldProcessingScriptTag = context->GetProcessingScriptTag();
|
||||
context->SetProcessingScriptTag(true);
|
||||
|
||||
|
@ -889,17 +891,14 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
|
|||
nsCOMPtr<nsIScriptElement> oldCurrent = mCurrentScript;
|
||||
mCurrentScript = aRequest->mElement;
|
||||
|
||||
// It's very important to use aRequest->mURI, not the final URI of the channel
|
||||
// aRequest ended up getting script data from, as the script filename.
|
||||
nsCAutoString url;
|
||||
nsContentUtils::GetWrapperSafeScriptFilename(mDocument, aRequest->mURI, url);
|
||||
nsContentUtils::GetWrapperSafeScriptFilename(mDocument, uri, url);
|
||||
|
||||
bool isUndefined;
|
||||
rv = context->EvaluateString(aScript, globalObject->GetGlobalJSObject(),
|
||||
mDocument->NodePrincipal(),
|
||||
aRequest->mOriginPrincipal,
|
||||
url.get(), aRequest->mLineNo,
|
||||
aRequest->mJSVersion, nsnull, &isUndefined);
|
||||
mDocument->NodePrincipal(), url.get(),
|
||||
aRequest->mLineNo, aRequest->mJSVersion, nsnull,
|
||||
&isUndefined);
|
||||
|
||||
// Put the old script back in case it wants to do anything else.
|
||||
mCurrentScript = oldCurrent;
|
||||
|
@ -1214,10 +1213,7 @@ nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(req);
|
||||
rv = nsContentUtils::GetSecurityManager()->
|
||||
GetChannelPrincipal(channel, getter_AddRefs(aRequest->mOriginPrincipal));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_GetFinalChannelURI(channel, getter_AddRefs(aRequest->mFinalURI));
|
||||
if (aStringLen) {
|
||||
// Check the charset attribute to determine script charset.
|
||||
nsAutoString hintCharset;
|
||||
|
|
|
@ -19,9 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=461735
|
|||
var errorFired = false;
|
||||
window.onerror = function(message, uri, line) {
|
||||
is(message, "Script error.", "Should have empty error message");
|
||||
is(uri,
|
||||
"http://mochi.test:8888/tests/content/base/test/bug461735-redirect1.sjs",
|
||||
"Should have pre-redirect error location URI");
|
||||
is(uri, "", "Should have empty error location URI");
|
||||
is(line, 0, "Shouldn't have a line here");
|
||||
errorFired = true;
|
||||
}
|
||||
|
@ -34,9 +32,7 @@ window.onerror = function(message, uri, line) {
|
|||
<script type="application/javascript">
|
||||
window.onerror = function(message, uri, line) {
|
||||
is(message, "c is not defined", "Should have correct error message");
|
||||
is(uri,
|
||||
"http://mochi.test:8888/tests/content/base/test/bug461735-redirect2.sjs",
|
||||
"Unexpected error location URI");
|
||||
is(uri, "http://mochi.test:8888/tests/content/base/test/bug461735-post-redirect.js", "Unexpected error location URI");
|
||||
is(line, 3, "Should have a line here");
|
||||
errorFired = true;
|
||||
}
|
||||
|
|
|
@ -9261,8 +9261,7 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
|
|||
|
||||
bool is_undefined;
|
||||
scx->EvaluateString(nsDependentString(script), FastGetGlobalJSObject(),
|
||||
timeout->mPrincipal, timeout->mPrincipal,
|
||||
filename, lineNo,
|
||||
timeout->mPrincipal, filename, lineNo,
|
||||
handler->GetScriptVersion(), nsnull,
|
||||
&is_undefined);
|
||||
} else {
|
||||
|
|
|
@ -74,8 +74,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptContextPrincipal,
|
|||
NS_ISCRIPTCONTEXTPRINCIPAL_IID)
|
||||
|
||||
#define NS_ISCRIPTCONTEXT_IID \
|
||||
{ 0xf3840057, 0x4fe5, 0x4f92, \
|
||||
{ 0xa3, 0xb8, 0x27, 0xd7, 0x44, 0x6f, 0x72, 0x4d } }
|
||||
{ 0xb36103bd, 0x304e, 0x4ef2, \
|
||||
{ 0x81, 0x12, 0x83, 0x42, 0xe5, 0xbd, 0xf3, 0xd4 } }
|
||||
|
||||
/* This MUST match JSVERSION_DEFAULT. This version stuff if we don't
|
||||
know what language we have is a little silly... */
|
||||
|
@ -99,9 +99,7 @@ public:
|
|||
* @param aScript a string representing the script to be executed
|
||||
* @param aScopeObject a script object for the scope to execute in, or
|
||||
* nsnull to use a default scope
|
||||
* @param aPrincipal the principal the script should be evaluated with
|
||||
* @param aOriginPrincipal the principal the script originates from. If null,
|
||||
* aPrincipal is used.
|
||||
* @param aPrincipal the principal that produced the script
|
||||
* @param aURL the URL or filename for error messages
|
||||
* @param aLineNo the starting line number of the script for error messages
|
||||
* @param aVersion the script language version to use when executing
|
||||
|
@ -117,7 +115,6 @@ public:
|
|||
virtual nsresult EvaluateString(const nsAString& aScript,
|
||||
JSObject* aScopeObject,
|
||||
nsIPrincipal *aPrincipal,
|
||||
nsIPrincipal *aOriginPrincipal,
|
||||
const char *aURL,
|
||||
PRUint32 aLineNo,
|
||||
PRUint32 aVersion,
|
||||
|
|
|
@ -89,8 +89,6 @@
|
|||
#include "nsGlobalWindow.h"
|
||||
#include "nsScriptNameSpaceManager.h"
|
||||
|
||||
#include "nsJSPrincipals.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// AssertMacros.h defines 'check' and conflicts with AccessCheck.h
|
||||
#undef check
|
||||
|
@ -285,15 +283,13 @@ class ScriptErrorEvent : public nsRunnable
|
|||
{
|
||||
public:
|
||||
ScriptErrorEvent(nsIScriptGlobalObject* aScriptGlobal,
|
||||
nsIPrincipal* aScriptOriginPrincipal,
|
||||
PRUint32 aLineNr, PRUint32 aColumn, PRUint32 aFlags,
|
||||
const nsAString& aErrorMsg,
|
||||
const nsAString& aFileName,
|
||||
const nsAString& aSourceLine,
|
||||
bool aDispatchEvent,
|
||||
PRUint64 aInnerWindowID)
|
||||
: mScriptGlobal(aScriptGlobal), mOriginPrincipal(aScriptOriginPrincipal),
|
||||
mLineNr(aLineNr), mColumn(aColumn),
|
||||
: mScriptGlobal(aScriptGlobal), mLineNr(aLineNr), mColumn(aColumn),
|
||||
mFlags(aFlags), mErrorMsg(aErrorMsg), mFileName(aFileName),
|
||||
mSourceLine(aSourceLine), mDispatchEvent(aDispatchEvent),
|
||||
mInnerWindowID(aInnerWindowID)
|
||||
|
@ -324,11 +320,17 @@ public:
|
|||
nsIPrincipal* p = sop->GetPrincipal();
|
||||
NS_ENSURE_STATE(p);
|
||||
|
||||
bool sameOrigin = !mOriginPrincipal;
|
||||
bool sameOrigin = mFileName.IsVoid();
|
||||
|
||||
if (p && !sameOrigin) {
|
||||
if (NS_FAILED(p->Subsumes(mOriginPrincipal, &sameOrigin))) {
|
||||
sameOrigin = false;
|
||||
nsCOMPtr<nsIURI> errorURI;
|
||||
NS_NewURI(getter_AddRefs(errorURI), mFileName);
|
||||
if (errorURI) {
|
||||
// FIXME: Once error reports contain the origin of the
|
||||
// error (principals) we should change this to do the
|
||||
// security check based on the principals and not
|
||||
// URIs. See bug 387476.
|
||||
sameOrigin = NS_SUCCEEDED(p->CheckMayLoad(errorURI, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,6 +342,13 @@ public:
|
|||
NS_WARNING("Not same origin error!");
|
||||
errorevent.errorMsg = xoriginMsg.get();
|
||||
errorevent.lineNr = 0;
|
||||
// FIXME: once the principal of the script is not tied to
|
||||
// the filename, we can stop using the post-redirect
|
||||
// filename if we want and remove this line. Note that
|
||||
// apparently we can't handle null filenames in the error
|
||||
// event dispatching code.
|
||||
static PRUnichar nullFilename[] = { PRUnichar(0) };
|
||||
errorevent.fileName = nullFilename;
|
||||
}
|
||||
|
||||
nsEventDispatcher::Dispatch(win, presContext, &errorevent, nsnull,
|
||||
|
@ -398,7 +407,6 @@ public:
|
|||
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> mScriptGlobal;
|
||||
nsCOMPtr<nsIPrincipal> mOriginPrincipal;
|
||||
PRUint32 mLineNr;
|
||||
PRUint32 mColumn;
|
||||
PRUint32 mFlags;
|
||||
|
@ -494,11 +502,8 @@ NS_ScriptErrorReporter(JSContext *cx,
|
|||
innerWindowID = innerWin->WindowID();
|
||||
}
|
||||
}
|
||||
JSPrincipals *prin = report->originPrincipals;
|
||||
nsIPrincipal *principal =
|
||||
prin ? static_cast<nsJSPrincipals*>(prin)->nsIPrincipalPtr : nsnull;
|
||||
nsContentUtils::AddScriptRunner(
|
||||
new ScriptErrorEvent(globalObject, principal, report->lineno,
|
||||
new ScriptErrorEvent(globalObject, report->lineno,
|
||||
report->uctokenptr - report->uclinebuf,
|
||||
report->flags, msg, fileName, sourceLine,
|
||||
report->errorNumber != JSMSG_OUT_OF_MEMORY,
|
||||
|
@ -1384,7 +1389,6 @@ nsresult
|
|||
nsJSContext::EvaluateString(const nsAString& aScript,
|
||||
JSObject* aScopeObject,
|
||||
nsIPrincipal *aPrincipal,
|
||||
nsIPrincipal *aOriginPrincipal,
|
||||
const char *aURL,
|
||||
PRUint32 aLineNo,
|
||||
PRUint32 aVersion,
|
||||
|
@ -1432,13 +1436,6 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
|||
principal->GetJSPrincipals(mContext, &jsprin);
|
||||
}
|
||||
|
||||
JSPrincipals *originJSprin;
|
||||
if (aOriginPrincipal) {
|
||||
aOriginPrincipal->GetJSPrincipals(mContext, &originJSprin);
|
||||
} else {
|
||||
originJSprin = nsnull;
|
||||
}
|
||||
|
||||
// From here on, we must JSPRINCIPALS_DROP(jsprin) before returning...
|
||||
|
||||
bool ok = false;
|
||||
|
@ -1446,9 +1443,6 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
|||
nsresult rv = sSecurityManager->CanExecuteScripts(mContext, principal, &ok);
|
||||
if (NS_FAILED(rv)) {
|
||||
JSPRINCIPALS_DROP(mContext, jsprin);
|
||||
if (originJSprin) {
|
||||
JSPRINCIPALS_DROP(mContext, originJSprin);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -1460,9 +1454,6 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
|||
do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
|
||||
if (NS_FAILED(rv) || NS_FAILED(stack->Push(mContext))) {
|
||||
JSPRINCIPALS_DROP(mContext, jsprin);
|
||||
if (originJSprin) {
|
||||
JSPRINCIPALS_DROP(mContext, originJSprin);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -1488,14 +1479,11 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
|||
if (!ac.enter(mContext, aScopeObject)) {
|
||||
stack->Pop(nsnull);
|
||||
JSPRINCIPALS_DROP(mContext, jsprin);
|
||||
if (originJSprin) {
|
||||
JSPRINCIPALS_DROP(mContext, originJSprin);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
ok = JS_EvaluateUCScriptForPrincipalsVersionOrigin(
|
||||
mContext, aScopeObject, jsprin, originJSprin,
|
||||
ok = JS_EvaluateUCScriptForPrincipalsVersion(
|
||||
mContext, aScopeObject, jsprin,
|
||||
static_cast<const jschar*>(PromiseFlatString(aScript).get()),
|
||||
aScript.Length(), aURL, aLineNo, vp, JSVersion(aVersion));
|
||||
|
||||
|
@ -1510,9 +1498,6 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
|||
|
||||
// Whew! Finally done with these manually ref-counted things.
|
||||
JSPRINCIPALS_DROP(mContext, jsprin);
|
||||
if (originJSprin) {
|
||||
JSPRINCIPALS_DROP(mContext, originJSprin);
|
||||
}
|
||||
|
||||
// If all went well, convert val to a string if one is wanted.
|
||||
if (ok) {
|
||||
|
|
|
@ -75,7 +75,6 @@ public:
|
|||
virtual nsresult EvaluateString(const nsAString& aScript,
|
||||
JSObject* aScopeObject,
|
||||
nsIPrincipal *principal,
|
||||
nsIPrincipal *originPrincipal,
|
||||
const char *aURL,
|
||||
PRUint32 aLineNo,
|
||||
PRUint32 aVersion,
|
||||
|
|
|
@ -360,7 +360,6 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
|
|||
rv = scriptContext->EvaluateString(NS_ConvertUTF8toUTF16(script),
|
||||
globalJSObject, // obj
|
||||
principal,
|
||||
principal,
|
||||
mURL.get(), // url
|
||||
1, // line no
|
||||
nsnull,
|
||||
|
|
|
@ -51,7 +51,7 @@ if (typeof window == 'undefined')
|
|||
}
|
||||
else
|
||||
{
|
||||
expect = /(Script error.|Permission denied for to get property XPCComponents.classes)/;
|
||||
expect = /(Script error.|uncaught exception: Permission denied to get property UnnamedClass.classes)/;
|
||||
|
||||
window._onerror = window.onerror;
|
||||
window.onerror = (function (msg, page, line) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче