OLD | NEW |
---|---|
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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
536 if (render_view) // Check whether |web_view| has been already closed. | 536 if (render_view) // Check whether |web_view| has been already closed. |
537 SetFocusAndActivate(render_view, focus); | 537 SetFocusAndActivate(render_view, focus); |
538 } | 538 } |
539 | 539 |
540 void BlinkTestRunner::SetAcceptAllCookies(bool accept) { | 540 void BlinkTestRunner::SetAcceptAllCookies(bool accept) { |
541 Send(new LayoutTestHostMsg_AcceptAllCookies(routing_id(), accept)); | 541 Send(new LayoutTestHostMsg_AcceptAllCookies(routing_id(), accept)); |
542 } | 542 } |
543 | 543 |
544 std::string BlinkTestRunner::PathToLocalResource(const std::string& resource) { | 544 std::string BlinkTestRunner::PathToLocalResource(const std::string& resource) { |
545 #if defined(OS_WIN) | 545 #if defined(OS_WIN) |
546 if (resource.find("/tmp/") == 0) { | 546 if (base::StartsWith(resource, "/tmp/", base::CompareCase::SENSITIVE)) { |
547 // We want a temp file. | 547 // We want a temp file. |
548 GURL base_url = net::FilePathToFileURL(test_config_.temp_path); | 548 GURL base_url = net::FilePathToFileURL(test_config_.temp_path); |
549 return base_url.Resolve(resource.substr(strlen("/tmp/"))).spec(); | 549 return base_url.Resolve(resource.substr(sizeof("/tmp/") - 1)).spec(); |
550 } | 550 } |
551 #endif | 551 #endif |
552 | 552 |
553 // Some layout tests use file://// which we resolve as a UNC path. Normalize | 553 // Some layout tests use file://// which we resolve as a UNC path. Normalize |
554 // them to just file:///. | 554 // them to just file:///. |
555 std::string result = resource; | 555 std::string result = resource; |
556 while (base::ToLowerASCII(result).find("file:////") == 0) { | 556 static const size_t kFileLen = sizeof("file:///") - 1; |
557 result = result.substr(0, strlen("file:///")) + | 557 while (base::StartsWith(base::ToLowerASCII(result), "file:////", |
558 result.substr(strlen("file:////")); | 558 base::CompareCase::SENSITIVE)) { |
559 result = result.substr(0, kFileLen) + result.substr(kFileLen); | |
piman
2016/07/11 21:29:54
I think the previous code was doing result = resul
Lei Zhang
2016/07/11 22:19:48
Thanks for catching this. *blink* *blink*
| |
559 } | 560 } |
560 return RewriteLayoutTestsURL(result, false /* is_wpt_mode */).string().utf8(); | 561 return RewriteLayoutTestsURL(result, false /* is_wpt_mode */).string().utf8(); |
561 } | 562 } |
562 | 563 |
563 void BlinkTestRunner::SetLocale(const std::string& locale) { | 564 void BlinkTestRunner::SetLocale(const std::string& locale) { |
564 setlocale(LC_ALL, locale.c_str()); | 565 setlocale(LC_ALL, locale.c_str()); |
565 } | 566 } |
566 | 567 |
567 void BlinkTestRunner::OnLayoutTestRuntimeFlagsChanged( | 568 void BlinkTestRunner::OnLayoutTestRuntimeFlagsChanged( |
568 const base::DictionaryValue& changed_values) { | 569 const base::DictionaryValue& changed_values) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 const base::Callback<void(const blink::WebURLResponse& response, | 651 const base::Callback<void(const blink::WebURLResponse& response, |
651 const std::string& data)>& callback) { | 652 const std::string& data)>& callback) { |
652 ::content::FetchManifest(view, url, callback); | 653 ::content::FetchManifest(view, url, callback); |
653 } | 654 } |
654 | 655 |
655 void BlinkTestRunner::SetPermission(const std::string& name, | 656 void BlinkTestRunner::SetPermission(const std::string& name, |
656 const std::string& value, | 657 const std::string& value, |
657 const GURL& origin, | 658 const GURL& origin, |
658 const GURL& embedding_origin) { | 659 const GURL& embedding_origin) { |
659 blink::mojom::PermissionStatus status; | 660 blink::mojom::PermissionStatus status; |
660 if (value == "granted") | 661 if (value == "granted") { |
661 status = blink::mojom::PermissionStatus::GRANTED; | 662 status = blink::mojom::PermissionStatus::GRANTED; |
662 else if (value == "prompt") | 663 } else if (value == "prompt") { |
663 status = blink::mojom::PermissionStatus::ASK; | 664 status = blink::mojom::PermissionStatus::ASK; |
664 else if (value == "denied") | 665 } else if (value == "denied") { |
665 status = blink::mojom::PermissionStatus::DENIED; | 666 status = blink::mojom::PermissionStatus::DENIED; |
666 else { | 667 } else { |
667 NOTREACHED(); | 668 NOTREACHED(); |
668 status = blink::mojom::PermissionStatus::DENIED; | 669 status = blink::mojom::PermissionStatus::DENIED; |
669 } | 670 } |
670 | 671 |
671 Send(new LayoutTestHostMsg_SetPermission( | 672 Send(new LayoutTestHostMsg_SetPermission( |
672 routing_id(), name, status, origin, embedding_origin)); | 673 routing_id(), name, status, origin, embedding_origin)); |
673 } | 674 } |
674 | 675 |
675 void BlinkTestRunner::ResetPermissions() { | 676 void BlinkTestRunner::ResetPermissions() { |
676 Send(new LayoutTestHostMsg_ResetPermissions(routing_id())); | 677 Send(new LayoutTestHostMsg_ResetPermissions(routing_id())); |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1015 void BlinkTestRunner::ReportLeakDetectionResult( | 1016 void BlinkTestRunner::ReportLeakDetectionResult( |
1016 const LeakDetectionResult& report) { | 1017 const LeakDetectionResult& report) { |
1017 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); | 1018 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); |
1018 } | 1019 } |
1019 | 1020 |
1020 void BlinkTestRunner::OnDestruct() { | 1021 void BlinkTestRunner::OnDestruct() { |
1021 delete this; | 1022 delete this; |
1022 } | 1023 } |
1023 | 1024 |
1024 } // namespace content | 1025 } // namespace content |
OLD | NEW |