Commit 070aa6af authored by Asami Doi's avatar Asami Doi Committed by Chromium LUCI CQ

Replace manifest().scope with manifest().start_url for CheckOfflineCapability

Originally, the installability check verified whether or not the
manifest scope is within a service worker's scope. Today, we want to
also check if the page specified by `start_url` in a manifest has a
service worker and works well offline.

Bug: 1157242, 965802
Change-Id: Ibe0a8a76a34bccecd461d9b106590e00807b531f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2583674
Commit-Queue: Asami Doi <asamidoi@chromium.org>
Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836936}
parent d2a83142
......@@ -1647,7 +1647,7 @@ IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
EXPECT_EQ(std::vector<InstallableStatusCode>(
{START_URL_NOT_VALID, MANIFEST_MISSING_NAME_OR_SHORT_NAME,
MANIFEST_DISPLAY_NOT_SUPPORTED, MANIFEST_MISSING_SUITABLE_ICON,
NO_ACCEPTABLE_ICON}),
NO_URL_FOR_SERVICE_WORKER, NO_ACCEPTABLE_ICON}),
tester->errors());
}
......@@ -1698,12 +1698,13 @@ IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
}
IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
GetAllInatallabilityErrorsWithPlayAppManifest) {
GetAllInstallabilityErrorsWithPlayAppManifest) {
EXPECT_EQ(std::vector<content::InstallabilityError>(
{GetInstallabilityError(START_URL_NOT_VALID),
GetInstallabilityError(MANIFEST_MISSING_NAME_OR_SHORT_NAME),
GetInstallabilityError(MANIFEST_DISPLAY_NOT_SUPPORTED),
GetInstallabilityError(MANIFEST_MISSING_SUITABLE_ICON),
GetInstallabilityError(NO_URL_FOR_SERVICE_WORKER),
GetInstallabilityError(NO_ACCEPTABLE_ICON)}),
NavigateAndGetAllInstallabilityErrors(
browser(), GetURLOfPageWithServiceWorkerAndManifest(
......
......@@ -730,13 +730,22 @@ void InstallableManager::OnDidCheckHasServiceWorker(
(blink::features::kCheckOfflineCapabilityParam.Get() ==
blink::features::CheckOfflineCapabilityMode::kEnforce);
if (!manifest().start_url.is_valid()) {
worker_->has_worker = false;
worker_->error = NO_URL_FOR_SERVICE_WORKER;
worker_->fetched = true;
WorkOnTask();
return;
}
// Dispatch a fetch event to `start_url` while simulating an offline
// environment and see if the site supports an offline page.
service_worker_context_->CheckOfflineCapability(
manifest().scope,
manifest().start_url,
base::BindOnce(&InstallableManager::OnDidCheckOfflineCapability,
weak_factory_.GetWeakPtr(),
check_service_worker_start_time,
enforce_offline_capability));
return;
}
worker_->has_worker = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment