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

Side by Side Diff: content/shell/renderer/layout_test/blink_test_runner.cc

Issue 2511333002: Cleanup after enabling WPTServe. (Closed)
Patch Set: Update a comment, remove the right testharnessreport.js Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/PRESUBMIT.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/renderer/layout_test/blink_test_runner.h" 5 #include "content/shell/renderer/layout_test/blink_test_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <clocale> 10 #include <clocale>
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 int session_id) override {} 211 int session_id) override {}
212 void Start() override {} 212 void Start() override {}
213 void Stop() override {} 213 void Stop() override {}
214 void SetVolume(double volume) override {} 214 void SetVolume(double volume) override {}
215 void SetAutomaticGainControl(bool enable) override {} 215 void SetAutomaticGainControl(bool enable) override {}
216 216
217 protected: 217 protected:
218 ~MockAudioCapturerSource() override {} 218 ~MockAudioCapturerSource() override {}
219 }; 219 };
220 220
221 // Tests in web-platform-tests use absolute path links such as 221 // Tests in csswg-test use absolute path links such as
222 // <script src="/resources/testharness.js">. 222 // <script src="/resources/testharness.js">.
223 // Because we load the tests as local files, such links don't work. 223 // Because we load the tests as local files, such links don't work.
224 // This function fixes this issue by rewriting file: URLs which were produced 224 // This function fixes this issue by rewriting file: URLs which were produced
225 // from such links so that they point actual files in wpt/. 225 // from such links so that they point actual files in LayoutTests/resources/.
226 WebURL RewriteAbsolutePathInWPT(const std::string& utf8_url) { 226 //
227 // Note that this isn't applied to external/wpt because tests in external/wpt
228 // are accessed via http.
229 WebURL RewriteAbsolutePathInCsswgTest(const std::string& utf8_url) {
227 const char kFileScheme[] = "file:///"; 230 const char kFileScheme[] = "file:///";
228 const int kFileSchemeLen = arraysize(kFileScheme) - 1; 231 const int kFileSchemeLen = arraysize(kFileScheme) - 1;
229 if (utf8_url.compare(0, kFileSchemeLen, kFileScheme, kFileSchemeLen) != 0) 232 if (utf8_url.compare(0, kFileSchemeLen, kFileScheme, kFileSchemeLen) != 0)
230 return WebURL(); 233 return WebURL();
231 if (utf8_url.find("/LayoutTests/") != std::string::npos) 234 if (utf8_url.find("/LayoutTests/") != std::string::npos)
232 return WebURL(); 235 return WebURL();
233 #if defined(OS_WIN) 236 #if defined(OS_WIN)
234 // +3 for a drive letter, :, and /. 237 // +3 for a drive letter, :, and /.
235 const int kFileSchemeAndDriveLen = kFileSchemeLen + 3; 238 const int kFileSchemeAndDriveLen = kFileSchemeLen + 3;
236 if (utf8_url.size() <= kFileSchemeAndDriveLen) 239 if (utf8_url.size() <= kFileSchemeAndDriveLen)
237 return WebURL(); 240 return WebURL();
238 std::string path = utf8_url.substr(kFileSchemeAndDriveLen); 241 std::string path = utf8_url.substr(kFileSchemeAndDriveLen);
239 #else 242 #else
240 std::string path = utf8_url.substr(kFileSchemeLen); 243 std::string path = utf8_url.substr(kFileSchemeLen);
241 #endif 244 #endif
242 base::FilePath new_path = 245 base::FilePath new_path =
243 LayoutTestRenderThreadObserver::GetInstance() 246 LayoutTestRenderThreadObserver::GetInstance()
244 ->webkit_source_dir() 247 ->webkit_source_dir()
245 .Append(FILE_PATH_LITERAL("LayoutTests/external/wpt/")) 248 .Append(FILE_PATH_LITERAL("LayoutTests/"))
246 .AppendASCII(path); 249 .AppendASCII(path);
247 return WebURL(net::FilePathToFileURL(new_path)); 250 return WebURL(net::FilePathToFileURL(new_path));
248 } 251 }
249 252
250 } // namespace 253 } // namespace
251 254
252 BlinkTestRunner::BlinkTestRunner(RenderView* render_view) 255 BlinkTestRunner::BlinkTestRunner(RenderView* render_view)
253 : RenderViewObserver(render_view), 256 : RenderViewObserver(render_view),
254 RenderViewObserverTracker<BlinkTestRunner>(render_view), 257 RenderViewObserverTracker<BlinkTestRunner>(render_view),
255 is_main_window_(false), 258 is_main_window_(false),
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 std::string contents_base64; 351 std::string contents_base64;
349 base::Base64Encode(contents, &contents_base64); 352 base::Base64Encode(contents, &contents_base64);
350 353
351 const char data_url_prefix[] = "data:text/css:charset=utf-8;base64,"; 354 const char data_url_prefix[] = "data:text/css:charset=utf-8;base64,";
352 return WebURL(GURL(data_url_prefix + contents_base64)); 355 return WebURL(GURL(data_url_prefix + contents_base64));
353 } 356 }
354 357
355 WebURL BlinkTestRunner::RewriteLayoutTestsURL(const std::string& utf8_url, 358 WebURL BlinkTestRunner::RewriteLayoutTestsURL(const std::string& utf8_url,
356 bool is_wpt_mode) { 359 bool is_wpt_mode) {
357 if (is_wpt_mode) { 360 if (is_wpt_mode) {
358 WebURL rewritten_url = RewriteAbsolutePathInWPT(utf8_url); 361 WebURL rewritten_url = RewriteAbsolutePathInCsswgTest(utf8_url);
359 if (!rewritten_url.isEmpty()) 362 if (!rewritten_url.isEmpty())
360 return rewritten_url; 363 return rewritten_url;
361 return WebURL(GURL(utf8_url)); 364 return WebURL(GURL(utf8_url));
362 } 365 }
363 366
364 const char kPrefix[] = "file:///tmp/LayoutTests/"; 367 const char kPrefix[] = "file:///tmp/LayoutTests/";
365 const int kPrefixLen = arraysize(kPrefix) - 1; 368 const int kPrefixLen = arraysize(kPrefix) - 1;
366 369
367 if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen)) 370 if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen))
368 return WebURL(GURL(utf8_url)); 371 return WebURL(GURL(utf8_url));
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 void BlinkTestRunner::ReportLeakDetectionResult( 1034 void BlinkTestRunner::ReportLeakDetectionResult(
1032 const LeakDetectionResult& report) { 1035 const LeakDetectionResult& report) {
1033 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); 1036 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report));
1034 } 1037 }
1035 1038
1036 void BlinkTestRunner::OnDestruct() { 1039 void BlinkTestRunner::OnDestruct() {
1037 delete this; 1040 delete this;
1038 } 1041 }
1039 1042
1040 } // namespace content 1043 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/PRESUBMIT.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698