Bug 1379023, part 3 - Make WriteCachedScript assert about the system principal not require the argument. r=mrbkap
MozReview-Commit-ID: FRgjZ32ULqj
This commit is contained in:
@@ -715,8 +715,7 @@ mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo& aInfo,
|
|||||||
|
|
||||||
if (writeToCache) {
|
if (writeToCache) {
|
||||||
// We successfully compiled the script, so cache it.
|
// We successfully compiled the script, so cache it.
|
||||||
rv = WriteCachedScript(cache, cachePath, cx, mSystemPrincipal,
|
rv = WriteCachedScript(cache, cachePath, cx, script);
|
||||||
script);
|
|
||||||
|
|
||||||
// Don't treat failure to write as fatal, since we might be working
|
// Don't treat failure to write as fatal, since we might be working
|
||||||
// with a read-only cache.
|
// with a read-only cache.
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ ReadCachedScript(StartupCache* cache, nsACString& uri, JSContext* cx,
|
|||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
WriteCachedScript(StartupCache* cache, nsACString& uri, JSContext* cx,
|
WriteCachedScript(StartupCache* cache, nsACString& uri, JSContext* cx,
|
||||||
nsIPrincipal* systemPrincipal, HandleScript script)
|
HandleScript script)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(JS_GetScriptPrincipals(script) == nsJSPrincipals::get(systemPrincipal));
|
MOZ_ASSERT(nsJSPrincipals::get(JS_GetScriptPrincipals(script))->GetIsSystemPrincipal());
|
||||||
|
|
||||||
JS::TranscodeBuffer buffer;
|
JS::TranscodeBuffer buffer;
|
||||||
JS::TranscodeResult code = JS::EncodeScript(cx, buffer, script);
|
JS::TranscodeResult code = JS::EncodeScript(cx, buffer, script);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ ReadCachedScript(mozilla::scache::StartupCache* cache, nsACString& uri,
|
|||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
WriteCachedScript(mozilla::scache::StartupCache* cache, nsACString& uri,
|
WriteCachedScript(mozilla::scache::StartupCache* cache, nsACString& uri,
|
||||||
JSContext* cx, nsIPrincipal* systemPrincipal,
|
JSContext* cx, JS::HandleScript script);
|
||||||
JS::HandleScript script);
|
|
||||||
|
|
||||||
#endif /* mozJSLoaderUtils_h */
|
#endif /* mozJSLoaderUtils_h */
|
||||||
|
|||||||
@@ -204,19 +204,6 @@ EvalScript(JSContext* cx,
|
|||||||
cachePath.AppendPrintf("jssubloader/%d", version);
|
cachePath.AppendPrintf("jssubloader/%d", version);
|
||||||
PathifyURI(uri, cachePath);
|
PathifyURI(uri, cachePath);
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptSecurityManager> secman =
|
|
||||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
|
|
||||||
if (!secman) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPrincipal> principal;
|
|
||||||
nsresult rv = secman->GetSystemPrincipal(getter_AddRefs(principal));
|
|
||||||
if (NS_FAILED(rv) || !principal) {
|
|
||||||
ReportError(cx, LOAD_ERROR_NOPRINCIPALS, uri);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCString uriStr;
|
nsCString uriStr;
|
||||||
if (preloadCache && NS_SUCCEEDED(uri->GetSpec(uriStr))) {
|
if (preloadCache && NS_SUCCEEDED(uri->GetSpec(uriStr))) {
|
||||||
// Note that, when called during startup, this will keep the
|
// Note that, when called during startup, this will keep the
|
||||||
@@ -244,8 +231,7 @@ EvalScript(JSContext* cx,
|
|||||||
|
|
||||||
if (startupCache) {
|
if (startupCache) {
|
||||||
JSAutoCompartment ac(cx, script);
|
JSAutoCompartment ac(cx, script);
|
||||||
WriteCachedScript(StartupCache::GetSingleton(),
|
WriteCachedScript(StartupCache::GetSingleton(), cachePath, cx, script);
|
||||||
cachePath, cx, principal, script);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user