Commit 81fad32f authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Remove *://localhost/* exception for Hangouts component extension

This was only needed for testing, but tests can start a test server and
have all names resolve to 127.0.0.1.  In this case, a little additional
work is also required due to the HTTPS requirement.

Bug: 819406
Change-Id: I07af6e568a53e1eda54e5d553d05001b2a12a213
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536071Reviewed-by: default avatarElad Alon <eladalon@chromium.org>
Reviewed-by: default avatarHenrik Grunell <grunell@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827463}
parent 09f1f16d
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "chrome/common/buildflags.h" #include "chrome/common/buildflags.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "content/public/browser/audio_service.h" #include "content/public/browser/audio_service.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/media_device_id.h" #include "content/public/browser/media_device_id.h"
...@@ -42,6 +43,7 @@ ...@@ -42,6 +43,7 @@
#include "media/audio/audio_device_description.h" #include "media/audio/audio_device_description.h"
#include "media/audio/audio_system.h" #include "media/audio/audio_system.h"
#include "media/base/media_switches.h" #include "media/base/media_switches.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h" #include "net/test/embedded_test_server/http_response.h"
...@@ -237,6 +239,9 @@ IN_PROC_BROWSER_TEST_F(WebrtcAudioPrivateTest, TriggerEvent) { ...@@ -237,6 +239,9 @@ IN_PROC_BROWSER_TEST_F(WebrtcAudioPrivateTest, TriggerEvent) {
class HangoutServicesBrowserTest : public AudioWaitingExtensionTest { class HangoutServicesBrowserTest : public AudioWaitingExtensionTest {
public: public:
HangoutServicesBrowserTest()
: https_server_(net::EmbeddedTestServer::TYPE_HTTPS) {}
void SetUp() override { void SetUp() override {
// Make sure the Hangout Services component extension gets loaded. // Make sure the Hangout Services component extension gets loaded.
ComponentLoader::EnableBackgroundExtensionsForTesting(); ComponentLoader::EnableBackgroundExtensionsForTesting();
...@@ -248,7 +253,20 @@ class HangoutServicesBrowserTest : public AudioWaitingExtensionTest { ...@@ -248,7 +253,20 @@ class HangoutServicesBrowserTest : public AudioWaitingExtensionTest {
command_line->AppendSwitchASCII( command_line->AppendSwitchASCII(
switches::kAutoplayPolicy, switches::kAutoplayPolicy,
switches::autoplay::kNoUserGestureRequiredPolicy); switches::autoplay::kNoUserGestureRequiredPolicy);
// This is necessary to use https with arbitrary hostnames.
command_line->AppendSwitch(switches::kIgnoreCertificateErrors);
} }
void SetUpOnMainThread() override {
https_server().AddDefaultHandlers(GetChromeTestDataDir());
host_resolver()->AddRule("*", "127.0.0.1");
AudioWaitingExtensionTest::SetUpOnMainThread();
}
net::EmbeddedTestServer& https_server() { return https_server_; }
private:
net::EmbeddedTestServer https_server_;
}; };
#if BUILDFLAG(ENABLE_HANGOUT_SERVICES_EXTENSION) #if BUILDFLAG(ENABLE_HANGOUT_SERVICES_EXTENSION)
...@@ -257,7 +275,7 @@ IN_PROC_BROWSER_TEST_F(HangoutServicesBrowserTest, ...@@ -257,7 +275,7 @@ IN_PROC_BROWSER_TEST_F(HangoutServicesBrowserTest,
constexpr char kLogUploadUrlPath[] = "/upload_webrtc_log"; constexpr char kLogUploadUrlPath[] = "/upload_webrtc_log";
// Set up handling of the log upload request. // Set up handling of the log upload request.
embedded_test_server()->RegisterRequestHandler(base::BindLambdaForTesting( https_server().RegisterRequestHandler(base::BindLambdaForTesting(
[&](const net::test_server::HttpRequest& request) [&](const net::test_server::HttpRequest& request)
-> std::unique_ptr<net::test_server::HttpResponse> { -> std::unique_ptr<net::test_server::HttpResponse> {
if (request.relative_url == kLogUploadUrlPath) { if (request.relative_url == kLogUploadUrlPath) {
...@@ -270,27 +288,22 @@ IN_PROC_BROWSER_TEST_F(HangoutServicesBrowserTest, ...@@ -270,27 +288,22 @@ IN_PROC_BROWSER_TEST_F(HangoutServicesBrowserTest,
return nullptr; return nullptr;
})); }));
ASSERT_TRUE(https_server().Start());
// This runs the end-to-end JavaScript test for the Hangout Services // This runs the end-to-end JavaScript test for the Hangout Services
// component extension, which uses the webrtcAudioPrivate API among // component extension, which uses the webrtcAudioPrivate API among
// others. // others.
ASSERT_TRUE(StartEmbeddedTestServer()); ui_test_utils::NavigateToURL(
GURL url(embedded_test_server()->GetURL( browser(),
"/extensions/hangout_services_test.html")); https_server().GetURL("any-subdomain.google.com",
// The "externally connectable" extension permission doesn't seem to "/extensions/hangout_services_test.html"));
// like when we use 127.0.0.1 as the host, but using localhost works.
std::string url_spec = url.spec();
base::ReplaceFirstSubstringAfterOffset(
&url_spec, 0, "127.0.0.1", "localhost");
GURL localhost_url(url_spec);
ui_test_utils::NavigateToURL(browser(), localhost_url);
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
WaitUntilAudioIsPlaying(tab); WaitUntilAudioIsPlaying(tab);
// Use a test server URL for uploading. // Use a test server URL for uploading.
g_browser_process->webrtc_log_uploader()->SetUploadUrlForTesting( g_browser_process->webrtc_log_uploader()->SetUploadUrlForTesting(
embedded_test_server()->GetURL(kLogUploadUrlPath)); https_server().GetURL("any-subdomain.google.com", kLogUploadUrlPath));
ASSERT_TRUE(content::ExecuteScript(tab, "browsertestRunAllTests();")); ASSERT_TRUE(content::ExecuteScript(tab, "browsertestRunAllTests();"));
......
...@@ -5,13 +5,11 @@ ...@@ -5,13 +5,11 @@
"name": "Google Hangouts", "name": "Google Hangouts",
// Note: Always update the version number when this file is updated. Chrome // Note: Always update the version number when this file is updated. Chrome
// triggers extension preferences update on the version increase. // triggers extension preferences update on the version increase.
"version": "1.3.15", "version": "1.3.16",
"manifest_version": 2, "manifest_version": 2,
"externally_connectable": { "externally_connectable": {
"matches": [ "matches": [
"https://*.google.com/*", "https://*.google.com/*"
// For tests.
"*://localhost/*"
] ]
}, },
"background": { "background": {
......
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