Commit 99cdb31d authored by Eric Willigers's avatar Eric Willigers Committed by Commit Bot

WebAppControllerBrowserTest starts https server

WebAppControllerBrowserTest::SetUpOnMainThread() now starts its
https server, avoiding the need to start the server in each
test case.

The http server and cert verifier in CustomTabBarViewBrowserTest
are retired, as this functionality is already provided by
WebAppControllerBrowserTest.

Change-Id: I67bcd661bca0ed647d3b2e9c8efa2217f19978cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2089441
Commit-Queue: calamity <calamity@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Reviewed-by: default avatarCollin Baker <collinbaker@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Auto-Submit: Eric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750848}
parent d1d40661
......@@ -2523,11 +2523,6 @@ class WebAppPictureInPictureWindowControllerBrowserTest
web_app::WebAppControllerBrowserTest::SetUpCommandLine(command_line);
}
void SetUpOnMainThread() override {
web_app::WebAppControllerBrowserTest::SetUpOnMainThread();
ASSERT_TRUE(https_server()->Start());
}
GURL main_url() {
return https_server()->GetURL(
"/extensions/auto_picture_in_picture/main.html");
......
......@@ -72,7 +72,6 @@ class BrowserNonClientFrameViewMacBrowserTest
IN_PROC_BROWSER_TEST_P(BrowserNonClientFrameViewMacBrowserTest, TitleUpdates) {
ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen;
ASSERT_TRUE(https_server()->Start());
const GURL app_url = GetInstallableAppURL();
const web_app::AppId app_id = InstallPWA(app_url);
Browser* const browser = LaunchWebAppBrowser(app_id);
......
......@@ -169,26 +169,15 @@ class UrlHidingWebContentsObserver : public content::WebContentsObserver {
class CustomTabBarViewBrowserTest
: public web_app::WebAppControllerBrowserTest {
public:
CustomTabBarViewBrowserTest()
: https_server_(net::EmbeddedTestServer::TYPE_HTTPS) {}
~CustomTabBarViewBrowserTest() override {}
CustomTabBarViewBrowserTest() = default;
~CustomTabBarViewBrowserTest() override = default;
protected:
void SetUpInProcessBrowserTestFixture() override {
web_app::WebAppControllerBrowserTest::SetUpInProcessBrowserTestFixture();
cert_verifier_.SetUpInProcessBrowserTestFixture();
}
void TearDownInProcessBrowserTestFixture() override {
web_app::WebAppControllerBrowserTest::TearDownInProcessBrowserTestFixture();
cert_verifier_.TearDownInProcessBrowserTestFixture();
}
void SetUpCommandLine(base::CommandLine* command_line) override {
web_app::WebAppControllerBrowserTest::SetUpCommandLine(command_line);
// Browser will both run and display insecure content.
command_line->AppendSwitch(switches::kAllowRunningInsecureContent);
cert_verifier_.SetUpCommandLine(command_line);
}
void SetUp() override {
......@@ -198,12 +187,7 @@ class CustomTabBarViewBrowserTest
}
void SetUpOnMainThread() override {
https_server_.AddDefaultHandlers(GetChromeTestDataDir());
// Everything should be redirected to the http server.
host_resolver()->AddRule("*", "127.0.0.1");
// All SSL cert checks should be valid.
cert_verifier_.mock_cert_verifier()->set_default_result(net::OK);
web_app::WebAppControllerBrowserTest::SetUpOnMainThread();
browser_view_ = BrowserView::GetBrowserViewForBrowser(browser());
......@@ -233,8 +217,6 @@ class CustomTabBarViewBrowserTest
CustomTabBarView* custom_tab_bar_;
web_app::AppBrowserController* app_controller_;
net::EmbeddedTestServer* https_server() { return &https_server_; }
private:
void Install(std::unique_ptr<WebApplicationInfo> web_app_info) {
const GURL app_url = web_app_info->app_url;
......@@ -254,11 +236,6 @@ class CustomTabBarViewBrowserTest
base::test::ScopedFeatureList feature_list_;
net::EmbeddedTestServer https_server_;
// Similar to net::MockCertVerifier, but also updates the CertVerifier
// used by the NetworkService.
content::ContentMockCertVerifier cert_verifier_;
DISALLOW_COPY_AND_ASSIGN(CustomTabBarViewBrowserTest);
};
......@@ -288,8 +265,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, IsNotCreatedInPopup) {
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
BackToAppButtonIsNotVisibleInOutOfScopePopups) {
ASSERT_TRUE(https_server()->Start());
const GURL& app_url = https_server()->GetURL("app.com", "/ssl/google.html");
const GURL& out_of_scope_url = GURL("https://example.com");
......@@ -313,7 +288,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
// Check the custom tab will be used for a Desktop PWA.
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, IsUsedForDesktopPWA) {
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
const GURL& url = https_server()->GetURL("app.com", "/ssl/google.html");
......@@ -333,7 +307,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, IsUsedForDesktopPWA) {
// Check the CustomTabBarView appears when a PWA window attempts to load
// insecure content.
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, ShowsWithMixedContent) {
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
const GURL& url = https_server()->GetURL("app.com", "/ssl/google.html");
......@@ -362,8 +335,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, ShowsWithMixedContent) {
// The custom tab bar should update with the title and location of the current
// page.
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, TitleAndLocationUpdate) {
ASSERT_TRUE(https_server()->Start());
const GURL& app_url = https_server()->GetURL("app.com", "/ssl/google.html");
// This url is out of scope, because the CustomTabBar is not updated when it
......@@ -391,8 +362,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, TitleAndLocationUpdate) {
// If the page doesn't specify a title, we should use the origin.
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
UsesLocationInsteadOfEmptyTitles) {
ASSERT_TRUE(https_server()->Start());
const GURL& app_url = https_server()->GetURL("app.com", "/ssl/google.html");
InstallPWA(app_url);
......@@ -413,8 +382,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
// Closing the CCT should take you back to the last in scope url.
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
OutOfScopeUrlShouldBeClosable) {
ASSERT_TRUE(https_server()->Start());
const GURL& app_url = https_server()->GetURL("app.com", "/ssl/google.html");
InstallPWA(app_url);
......@@ -452,8 +419,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
#endif
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
MAYBE_RightClickMenuShowsCopyUrl) {
ASSERT_TRUE(https_server()->Start());
const GURL& app_url = https_server()->GetURL("app.com", "/ssl/google.html");
InstallPWA(app_url);
......@@ -485,8 +450,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
// the CustomTabBar.
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
ScopeAboveLaunchURLShouldBeOutOfScopeAndClosable) {
ASSERT_TRUE(https_server()->Start());
const GURL& app_url = https_server()->GetURL("app.com", "/ssl/google.html");
InstallPWA(app_url);
......@@ -522,8 +485,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
IN_PROC_BROWSER_TEST_P(
CustomTabBarViewBrowserTest,
WhenNoHistoryIsInScopeCloseShouldNavigateToAppLaunchURL) {
ASSERT_TRUE(https_server()->Start());
const GURL& app_url = https_server()->GetURL("app.com", "/ssl/google.html");
InstallPWA(app_url);
......@@ -554,8 +515,6 @@ IN_PROC_BROWSER_TEST_P(
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
OriginsWithEmojiArePunyCoded) {
ASSERT_TRUE(https_server()->Start());
const GURL& app_url = https_server()->GetURL("app.com", "/ssl/google.html");
const GURL& navigate_to = GURL("https://🔒.example/ssl/blank_page.html");
......@@ -577,8 +536,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
OriginsWithNonASCIICharactersDisplayNormally) {
ASSERT_TRUE(https_server()->Start());
const GURL& app_url = https_server()->GetURL("app.com", "/ssl/google.html");
const GURL& navigate_to = GURL("https://ΐ.example/ssl/blank_page.html");
......@@ -601,7 +558,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
BackToAppButtonIsNotVisibleInScope) {
ASSERT_TRUE(embedded_test_server()->Start());
ASSERT_TRUE(https_server()->Start());
// We install over http because it's the easiest way to get a custom tab bar
// in scope. A PWA won't be installed over http in the real world (it'd make a
......@@ -653,7 +609,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
BackToAppButtonIsNotVisibleInBookmarkAppOnOrigin) {
ASSERT_TRUE(embedded_test_server()->Start());
ASSERT_TRUE(https_server()->Start());
const GURL& app_url =
embedded_test_server()->GetURL("app.com", "/ssl/google.html");
......@@ -686,7 +641,6 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest,
// Verify that interstitials that hide origin have their preference respected.
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, InterstitialCanHideOrigin) {
ASSERT_TRUE(embedded_test_server()->Start());
ASSERT_TRUE(https_server()->Start());
InstallPWA(https_server()->GetURL("app.com", "/ssl/google.html"));
EXPECT_TRUE(app_browser_);
......
......@@ -45,13 +45,11 @@ class CreateShortcutBrowserTest : public WebAppControllerBrowserTest {
CHECK(provider);
return provider->registry_controller();
}
};
IN_PROC_BROWSER_TEST_P(CreateShortcutBrowserTest,
CreateShortcutForInstallableSite) {
base::UserActionTester user_action_tester;
ASSERT_TRUE(https_server()->Start());
NavigateToURLAndWait(browser(), GetInstallableAppURL());
AppId app_id = InstallShortcutAppForCurrentUrl();
......@@ -65,8 +63,6 @@ IN_PROC_BROWSER_TEST_P(CreateShortcutBrowserTest,
IN_PROC_BROWSER_TEST_P(CreateShortcutBrowserTest,
CanInstallOverTabShortcutApp) {
ASSERT_TRUE(https_server()->Start());
NavigateToURLAndWait(browser(), GetInstallableAppURL());
InstallShortcutAppForCurrentUrl();
......@@ -81,8 +77,6 @@ IN_PROC_BROWSER_TEST_P(CreateShortcutBrowserTest,
IN_PROC_BROWSER_TEST_P(CreateShortcutBrowserTest,
CannotInstallOverWindowShortcutApp) {
ASSERT_TRUE(https_server()->Start());
NavigateToURLAndWait(browser(), GetInstallableAppURL());
AppId app_id = InstallShortcutAppForCurrentUrl();
// Change launch container to open in window.
......
......@@ -98,8 +98,6 @@ class PWAMixedContentBrowserTestWithAutoupgradesDisabled
// a non-installable site.
IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTest,
ShortcutMenuOptionsForNonInstallableSite) {
ASSERT_TRUE(https_server()->Start());
EXPECT_FALSE(
NavigateAndAwaitInstallabilityCheck(browser(), GetMixedContentAppURL()));
......@@ -110,7 +108,6 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTest,
// Tests that mixed content is loaded inside PWA windows.
IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
MixedContentInPWA) {
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
const GURL app_url = GetMixedContentAppURL();
......@@ -124,7 +121,6 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
// tab.
IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
MixedContentOpenInChrome) {
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
const GURL app_url = GetMixedContentAppURL();
......@@ -162,7 +158,6 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
// content cannot be loaded in the new app window.
IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
MixedContentReparentWebContentsIntoAppBrowser) {
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
const GURL app_url = GetMixedContentAppURL();
......@@ -201,8 +196,6 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
// Tests that mixed content is not loaded inside iframes in PWA windows.
IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTest, IFrameMixedContentInPWA) {
ASSERT_TRUE(https_server()->Start());
const GURL app_url = GetSecureIFrameAppURL();
const AppId app_id = InstallPWA(app_url);
Browser* const app_browser = LaunchWebAppBrowserAndWait(app_id);
......@@ -215,7 +208,6 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTest, IFrameMixedContentInPWA) {
IN_PROC_BROWSER_TEST_P(
PWAMixedContentBrowserTestWithAutoupgradesDisabled,
IFrameDynamicMixedContentInPWAReparentWebContentsIntoAppBrowser) {
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
const GURL app_url = GetSecureIFrameAppURL();
......@@ -241,7 +233,6 @@ IN_PROC_BROWSER_TEST_P(
// tab, when the iframe was created in a PWA window.
IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
IFrameDynamicMixedContentInPWAOpenInChrome) {
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
const GURL app_url = GetSecureIFrameAppURL();
......
......@@ -32,7 +32,6 @@ class WebAppBadgingBrowserTest : public WebAppControllerBrowserTest {
WebAppControllerBrowserTest::SetUpOnMainThread();
ASSERT_TRUE(cross_origin_https_server_.Start());
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
GURL cross_site_frame_url =
......
......@@ -168,6 +168,7 @@ void WebAppControllerBrowserTest::SetUpCommandLine(
void WebAppControllerBrowserTest::SetUpOnMainThread() {
extensions::ExtensionBrowserTest::SetUpOnMainThread();
host_resolver()->AddRule("*", "127.0.0.1");
ASSERT_TRUE(https_server()->Start());
// By default, all SSL cert checks are valid. Can be overridden in tests.
cert_verifier_.mock_cert_verifier()->set_default_result(net::OK);
......
......@@ -190,8 +190,6 @@ class WebAppFileHandlingBrowserTest : public WebAppFileHandlingTestBase {
IN_PROC_BROWSER_TEST_P(WebAppFileHandlingBrowserTest,
LaunchConsumerIsNotTriggeredWithNoFiles) {
ASSERT_TRUE(https_server()->Start());
InstallFileHandlingPWA();
content::WebContents* web_contents =
LaunchWithFiles(app_id(), GetSecureAppURL(), {});
......@@ -200,8 +198,6 @@ IN_PROC_BROWSER_TEST_P(WebAppFileHandlingBrowserTest,
IN_PROC_BROWSER_TEST_P(WebAppFileHandlingBrowserTest,
PWAsCanReceiveFileLaunchParams) {
ASSERT_TRUE(https_server()->Start());
InstallFileHandlingPWA();
base::FilePath test_file_path = NewTestFilePath(FILE_PATH_LITERAL("txt"));
content::WebContents* web_contents = LaunchWithFiles(
......@@ -215,8 +211,6 @@ IN_PROC_BROWSER_TEST_P(WebAppFileHandlingBrowserTest,
IN_PROC_BROWSER_TEST_P(WebAppFileHandlingBrowserTest,
PWAsCanReceiveFileLaunchParamsInTab) {
ASSERT_TRUE(https_server()->Start());
InstallFileHandlingPWA();
base::FilePath test_file_path = NewTestFilePath(FILE_PATH_LITERAL("txt"));
content::WebContents* web_contents =
......@@ -231,8 +225,6 @@ IN_PROC_BROWSER_TEST_P(WebAppFileHandlingBrowserTest,
IN_PROC_BROWSER_TEST_P(WebAppFileHandlingBrowserTest,
PWAsDispatchOnCorrectFileHandlingURL) {
ASSERT_TRUE(https_server()->Start());
InstallFileHandlingPWA();
// Test that file handler dispatches correct URL based on file extension.
......@@ -266,7 +258,6 @@ class WebAppFileHandlingOriginTrialBrowserTest
void SetUpOnMainThread() override {
WebAppFileHandlingTestBase::SetUpOnMainThread();
ASSERT_TRUE(https_server()->Start());
}
void SetUpInterceptorNavigateToAppAndMaybeWait() {
......
......@@ -48,8 +48,6 @@ class WebAppUninstallBrowserTest : public WebAppControllerBrowserTest {
// Tests that app windows are restored in a tab if the app is uninstalled.
IN_PROC_BROWSER_TEST_P(WebAppUninstallBrowserTest,
RestoreAppWindowForUninstalledApp) {
ASSERT_TRUE(https_server()->Start());
const GURL app_url = GetSecureAppURL();
const AppId app_id = InstallPWA(app_url);
......@@ -80,7 +78,6 @@ IN_PROC_BROWSER_TEST_P(WebAppUninstallBrowserTest,
// Check that uninstalling a PWA with a window opened doesn't crash.
IN_PROC_BROWSER_TEST_P(WebAppUninstallBrowserTest,
UninstallPwaWithWindowOpened) {
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
const GURL app_url = GetSecureAppURL();
......@@ -97,7 +94,6 @@ IN_PROC_BROWSER_TEST_P(WebAppUninstallBrowserTest,
// PWAs moved to tabbed browsers should not get closed when uninstalled.
IN_PROC_BROWSER_TEST_P(WebAppUninstallBrowserTest,
UninstallPwaWithWindowMovedToTab) {
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
const GURL app_url = GetSecureAppURL();
......
......@@ -50,7 +50,6 @@ class ClearBrowsingDataHandlerBrowserTest
web_ui(), browser()->profile());
handler_->AllowJavascriptForTesting();
handler_->RegisterMessages();
ASSERT_TRUE(https_server()->Start());
}
void TearDownOnMainThread() override { handler_.reset(); }
......
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