Commit 2fe091b1 authored by mkwst's avatar mkwst Committed by Commit bot

Layout Tests should support '*.test' URLs.

We need, for example, to test that ServiceWorkers can't be registered on
unauthenticated origins[1]. This patch allows '*.test' as a valid URL
for tests, and teaches content shell how to resolve them if (and only
if) the '--dump-render-tree' flag is set.

'.test' is a reserved gTLD[3], and is also used by the W3C's Web Platform
Tests[3]; it seems like the best choice of suffix for layout tests.

[1]: http://w3c.github.io/webappsec/specs/mixedcontent/#authenticated-origin
[2]: http://newgtlds.icann.org/applicants/agb
[3]: https://github.com/w3c/web-platform-tests#running-the-tests

BUG=410190

Review URL: https://codereview.chromium.org/529403002

Cr-Commit-Position: refs/heads/master@{#293106}
parent 352a3ed7
...@@ -176,6 +176,9 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { ...@@ -176,6 +176,9 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
command_line.AppendSwitch(switches::kEnablePreciseMemoryInfo); command_line.AppendSwitch(switches::kEnablePreciseMemoryInfo);
command_line.AppendSwitchASCII(switches::kHostResolverRules,
"MAP *.test 127.0.0.1");
// Unless/until WebM files are added to the media layout tests, we need to // Unless/until WebM files are added to the media layout tests, we need to
// avoid removing MP4/H264/AAC so that layout tests can run on Android. // avoid removing MP4/H264/AAC so that layout tests can run on Android.
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/shell/renderer/test_runner/TestPlugin.h" #include "content/shell/renderer/test_runner/TestPlugin.h"
...@@ -155,6 +156,10 @@ bool IsLocalHost(const std::string& host) { ...@@ -155,6 +156,10 @@ bool IsLocalHost(const std::string& host) {
return host == "127.0.0.1" || host == "localhost"; return host == "127.0.0.1" || host == "localhost";
} }
bool IsTestHost(const std::string& host) {
return EndsWith(host, ".test", false);
}
bool HostIsUsedBySomeTestsToGenerateError(const std::string& host) { bool HostIsUsedBySomeTestsToGenerateError(const std::string& host) {
return host == "255.255.255.255"; return host == "255.255.255.255";
} }
...@@ -1082,7 +1087,7 @@ void WebTestProxyBase::WillSendRequest( ...@@ -1082,7 +1087,7 @@ void WebTestProxyBase::WillSendRequest(
std::string host = url.host(); std::string host = url.host();
if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https"))) { if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https"))) {
if (!IsLocalHost(host) && !HostIsUsedBySomeTestsToGenerateError(host) && if (!IsLocalHost(host) && !IsTestHost(host) && !HostIsUsedBySomeTestsToGenerateError(host) &&
((!main_document_url.SchemeIs("http") && ((!main_document_url.SchemeIs("http") &&
!main_document_url.SchemeIs("https")) || !main_document_url.SchemeIs("https")) ||
IsLocalHost(main_document_url.host())) && IsLocalHost(main_document_url.host())) &&
......
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