Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2231)

Unified Diff: content/shell/renderer/layout_test/blink_test_runner.cc

Issue 1984103003: content_shell: Redirect resource requests for some local paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/forms/autocapitalize.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/renderer/layout_test/blink_test_runner.cc
diff --git a/content/shell/renderer/layout_test/blink_test_runner.cc b/content/shell/renderer/layout_test/blink_test_runner.cc
index 369f23f73a709d689c1051343048b8e55aee1ff9..82d6421610905f7e1ca62a2055e6c8a3957e2dfb 100644
--- a/content/shell/renderer/layout_test/blink_test_runner.cc
+++ b/content/shell/renderer/layout_test/blink_test_runner.cc
@@ -17,6 +17,7 @@
#include "base/compiler_specific.h"
#include "base/debug/debugger.h"
#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/md5.h"
@@ -203,6 +204,45 @@ class MockAudioCapturerSource : public media::AudioCapturerSource {
~MockAudioCapturerSource() override {}
};
+WebURL RewriteAbsolutePathInWPT(const std::string& utf8_url) {
qyearsley 2016/05/18 17:26:56 The main reason for this is so that we don't have
tkent 2016/05/20 01:00:30 Done.
+ const char kFileScheme[] = "file:///";
+ const int kFileSchemeLen = arraysize(kFileScheme) - 1;
+ if (utf8_url.compare(0, kFileSchemeLen, kFileScheme, kFileSchemeLen) != 0)
+ return WebURL();
+#if defined(OS_WIN)
+ // +3 for a drive letter, :, and /.
+ const int kFileSchemeAndDriveLen = kFileSchemeLen + 3;
+ if (utf8_url.size() <= kFileSchemeAndDriveLen)
+ return WebURL();
+ std::string path = utf8_url.substr(kFileSchemeAndDriveLen);
+#else
+ std::string path = utf8_url.substr(kFileSchemeLen);
+#endif
+ // LayoutTests use file: URLs in various ways.
+ // - The magic URL prefix "file:///tmp/LayoutTests/" to access file:
+ // resources from http resources.
+ // - $TMP to download a blob URL
+ // - out/$CONFIG/gen/ and third_party/WebKit/Source/devtools to load
+ // DevTools code.
+ // We rewite only a few patterns used in web-platform-tests because this is
+ // a short-teram workaround. We can remove this hack when we start to run
qyearsley 2016/05/18 17:26:56 short-term
tkent 2016/05/20 01:00:30 Removed.
+ // all WPT tests with wptserve.
qyearsley 2016/05/18 17:26:56 Although, we may want to still want to have most t
tkent 2016/05/20 01:00:30 I updated the comment.
+ if (base::StartsWith(path, "common/", base::CompareCase::SENSITIVE) ||
+ base::StartsWith(path, "images/", base::CompareCase::SENSITIVE) ||
+ base::StartsWith(path, "media/", base::CompareCase::SENSITIVE) ||
+ base::StartsWith(path, "resources/", base::CompareCase::SENSITIVE)) {
+ // TODO(tkent): web-platform-tests -> wpt when the renaming is completed.
+ base::FilePath new_path =
+ LayoutTestRenderThreadObserver::GetInstance()
+ ->webkit_source_dir()
+ .Append(
+ FILE_PATH_LITERAL("LayoutTests/imported/web-platform-tests/"))
+ .AppendASCII(path);
+ return WebURL(net::FilePathToFileURL(new_path));
+ }
+ return WebURL();
+}
+
} // namespace
BlinkTestRunner::BlinkTestRunner(RenderView* render_view)
@@ -308,6 +348,10 @@ WebURL BlinkTestRunner::LocalFileToDataURL(const WebURL& file_url) {
}
WebURL BlinkTestRunner::RewriteLayoutTestsURL(const std::string& utf8_url) {
+ WebURL url = RewriteAbsolutePathInWPT(utf8_url);
qyearsley 2016/05/18 17:26:56 Would rewritten_url make sense for this variable n
tkent 2016/05/20 01:00:30 Done.
+ if (!url.isEmpty())
+ return url;
+
const char kPrefix[] = "file:///tmp/LayoutTests/";
const int kPrefixLen = arraysize(kPrefix) - 1;
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/forms/autocapitalize.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698