Bug 1379023, part 3 - Make WriteCachedScript assert about the system principal not require the argument. r=mrbkap

MozReview-Commit-ID: FRgjZ32ULqj

--HG--
extra : rebase_source : be20c846efd3a5d5ba52ca1f614a0b40775d5e01
This commit is contained in:
Andrew McCreight 2017-07-07 11:27:53 -07:00
Родитель ef5af5fdf2
Коммит 93029d4038
4 изменённых файлов: 5 добавлений и 21 удалений

Просмотреть файл

@ -715,8 +715,7 @@ mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo& aInfo,
if (writeToCache) {
// We successfully compiled the script, so cache it.
rv = WriteCachedScript(cache, cachePath, cx, mSystemPrincipal,
script);
rv = WriteCachedScript(cache, cachePath, cx, script);
// Don't treat failure to write as fatal, since we might be working
// with a read-only cache.

Просмотреть файл

@ -45,9 +45,9 @@ ReadCachedScript(StartupCache* cache, nsACString& uri, JSContext* cx,
nsresult
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::TranscodeResult code = JS::EncodeScript(cx, buffer, script);

Просмотреть файл

@ -21,7 +21,6 @@ ReadCachedScript(mozilla::scache::StartupCache* cache, nsACString& uri,
nsresult
WriteCachedScript(mozilla::scache::StartupCache* cache, nsACString& uri,
JSContext* cx, nsIPrincipal* systemPrincipal,
JS::HandleScript script);
JSContext* cx, JS::HandleScript script);
#endif /* mozJSLoaderUtils_h */

Просмотреть файл

@ -204,19 +204,6 @@ EvalScript(JSContext* cx,
cachePath.AppendPrintf("jssubloader/%d", version);
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;
if (preloadCache && NS_SUCCEEDED(uri->GetSpec(uriStr))) {
// Note that, when called during startup, this will keep the
@ -244,8 +231,7 @@ EvalScript(JSContext* cx,
if (startupCache) {
JSAutoCompartment ac(cx, script);
WriteCachedScript(StartupCache::GetSingleton(),
cachePath, cx, principal, script);
WriteCachedScript(StartupCache::GetSingleton(), cachePath, cx, script);
}
}