Bug 1589054 - Part 4: Run DisplayLoadError in a script runner, r=farre

Differential Revision: https://phabricator.services.mozilla.com/D50025

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-10-22 13:57:01 +00:00
parent d9c800fe18
commit 2f4515047c

View File

@ -165,20 +165,25 @@ void nsFrameLoaderOwner::ChangeRemoteness(
const mozilla::dom::RemotenessOptions& aOptions, mozilla::ErrorResult& rv) {
std::function<void()> frameLoaderInit = [&] {
if (aOptions.mError.WasPassed()) {
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), "about:blank");
if (NS_WARN_IF(rv.Failed())) {
return;
}
nsDocShell* docShell = mFrameLoader->GetDocShell(rv);
if (NS_WARN_IF(rv.Failed())) {
return;
}
bool displayed = false;
docShell->DisplayLoadError(static_cast<nsresult>(aOptions.mError.Value()),
uri, u"about:blank", nullptr, &displayed);
RefPtr<nsFrameLoader> frameLoader = mFrameLoader;
nsresult error = static_cast<nsresult>(aOptions.mError.Value());
nsContentUtils::AddScriptRunner(NS_NewRunnableFunction(
"nsFrameLoaderOwner::DisplayLoadError", [frameLoader, error]() {
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), "about:blank");
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
RefPtr<nsDocShell> docShell =
frameLoader->GetDocShell(IgnoreErrors());
if (NS_WARN_IF(!docShell)) {
return;
}
bool displayed = false;
docShell->DisplayLoadError(error, uri, u"about:blank", nullptr,
&displayed);
}));
} else if (aOptions.mPendingSwitchID.WasPassed()) {
mFrameLoader->ResumeLoad(aOptions.mPendingSwitchID.Value());
} else {