зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1637039 - Notify script preload when the loading channel synchronously fails to open, remove a used script preload from Document, r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D76364
This commit is contained in:
Родитель
3e13f22e1b
Коммит
07f63ad409
|
@ -1497,15 +1497,23 @@ nsresult ScriptLoader::StartLoad(ScriptLoadRequest* aRequest) {
|
||||||
rv = NS_NewIncrementalStreamLoader(getter_AddRefs(loader), handler);
|
rv = NS_NewIncrementalStreamLoader(getter_AddRefs(loader), handler);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = channel->AsyncOpen(loader);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
auto key = PreloadHashKey::CreateAsScript(
|
auto key = PreloadHashKey::CreateAsScript(
|
||||||
aRequest->mURI, aRequest->CORSMode(), aRequest->mKind,
|
aRequest->mURI, aRequest->CORSMode(), aRequest->mKind,
|
||||||
aRequest->ReferrerPolicy());
|
aRequest->ReferrerPolicy());
|
||||||
aRequest->NotifyOpen(&key, channel, mDocument,
|
aRequest->NotifyOpen(&key, channel, mDocument,
|
||||||
aRequest->IsLinkPreloadScript());
|
aRequest->IsLinkPreloadScript());
|
||||||
|
|
||||||
|
rv = channel->AsyncOpen(loader);
|
||||||
|
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
// Make sure to inform any <link preload> tags about failure to load the
|
||||||
|
// resource.
|
||||||
|
aRequest->NotifyStart(channel);
|
||||||
|
aRequest->NotifyStop(rv);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (aRequest->IsModuleRequest()) {
|
if (aRequest->IsModuleRequest()) {
|
||||||
// We successfully started fetching a module so put its URL in the module
|
// We successfully started fetching a module so put its URL in the module
|
||||||
// map and mark it as fetching.
|
// map and mark it as fetching.
|
||||||
|
@ -1966,6 +1974,10 @@ ScriptLoadRequest* ScriptLoader::LookupPreloadRequest(
|
||||||
// This makes sure the pending preload (if exists) for this resource is
|
// This makes sure the pending preload (if exists) for this resource is
|
||||||
// properly marked as used and thus not notified in the console as unused.
|
// properly marked as used and thus not notified in the console as unused.
|
||||||
request->NotifyUsage();
|
request->NotifyUsage();
|
||||||
|
// A used preload must no longer be found in the Document's hash table. Any
|
||||||
|
// <link preload> tag after the <script> tag will start a new request, that
|
||||||
|
// can be satisfied from a different cache, but not from the preload cache.
|
||||||
|
request->RemoveSelf(mDocument);
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче