Commit 024a8a61 authored by Eric Willigers's avatar Eric Willigers Committed by Commit Bot

Desktop PWAs: Test installing a PWA with unavailable manifest

With a flaky network connection, ExternalWebAppManager may request an
app whose manifest cannot currently be retrieved.

We emulate this scenario in a browser test by specifying a manifest
known not to exist.

Note that when the requested user display mode is 'standalone', the
effective display mode will be 'minimal-ui' as the app display mode
defaults to 'browser' in the absence of a manifest.

Bug: 1055523
Change-Id: Ie7ebf42f95891f7e3eb65d3328d85104585f749a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2076739
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Auto-Submit: Eric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744900}
parent 1a17b4d2
...@@ -348,6 +348,52 @@ IN_PROC_BROWSER_TEST_P(PendingAppManagerImplBrowserTest, AlreadyRegistered) { ...@@ -348,6 +348,52 @@ IN_PROC_BROWSER_TEST_P(PendingAppManagerImplBrowserTest, AlreadyRegistered) {
} }
} }
IN_PROC_BROWSER_TEST_P(PendingAppManagerImplBrowserTest, CannotFetchManifest) {
// With a flaky network connection, clients may request an app whose manifest
// cannot currently be retrieved. The app display mode is then assumed to be
// 'browser'.
ASSERT_TRUE(embedded_test_server()->Start());
const GURL app_url(embedded_test_server()->GetURL(
"/banners/manifest_test_page.html?manifest=does_not_exist.json"));
std::vector<ExternalInstallOptions> desired_apps_install_options;
{
ExternalInstallOptions install_options(
app_url, DisplayMode::kStandalone,
ExternalInstallSource::kExternalPolicy);
install_options.add_to_applications_menu = false;
install_options.add_to_desktop = false;
install_options.add_to_quick_launch_bar = false;
install_options.require_manifest = false;
desired_apps_install_options.push_back(std::move(install_options));
}
base::RunLoop run_loop;
pending_app_manager().SynchronizeInstalledApps(
std::move(desired_apps_install_options),
ExternalInstallSource::kExternalPolicy,
base::BindLambdaForTesting(
[&run_loop, &app_url](
std::map<GURL, InstallResultCode> install_results,
std::map<GURL, bool> uninstall_results) {
EXPECT_TRUE(uninstall_results.empty());
EXPECT_EQ(install_results.size(), 1U);
EXPECT_EQ(install_results[app_url],
InstallResultCode ::kSuccessNewInstall);
run_loop.Quit();
}));
run_loop.Run();
base::Optional<AppId> app_id = registrar().FindAppWithUrlInScope(app_url);
DCHECK(app_id.has_value());
EXPECT_EQ(registrar().GetAppDisplayMode(*app_id), DisplayMode::kBrowser);
EXPECT_EQ(registrar().GetAppUserDisplayMode(*app_id),
DisplayMode::kStandalone);
EXPECT_EQ(registrar().GetAppEffectiveDisplayMode(*app_id),
DisplayMode::kMinimalUi);
EXPECT_FALSE(registrar().GetAppThemeColor(*app_id).has_value());
}
IN_PROC_BROWSER_TEST_P(PendingAppManagerImplBrowserTest, RegistrationTimeout) { IN_PROC_BROWSER_TEST_P(PendingAppManagerImplBrowserTest, RegistrationTimeout) {
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
PendingAppRegistrationTask::SetTimeoutForTesting(0); PendingAppRegistrationTask::SetTimeoutForTesting(0);
......
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