OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/test_runner/test_runner.h" | 5 #include "content/shell/test_runner/test_runner.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 2022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 | 2033 |
2034 void TestRunner::QueueReload() { | 2034 void TestRunner::QueueReload() { |
2035 work_queue_.AddWork(new WorkItemReload()); | 2035 work_queue_.AddWork(new WorkItemReload()); |
2036 } | 2036 } |
2037 | 2037 |
2038 class WorkItemLoadingScript : public TestRunner::WorkItem { | 2038 class WorkItemLoadingScript : public TestRunner::WorkItem { |
2039 public: | 2039 public: |
2040 WorkItemLoadingScript(const std::string& script) : script_(script) {} | 2040 WorkItemLoadingScript(const std::string& script) : script_(script) {} |
2041 | 2041 |
2042 bool Run(WebTestDelegate*, WebView* web_view) override { | 2042 bool Run(WebTestDelegate*, WebView* web_view) override { |
2043 web_view->MainFrame()->ExecuteScript( | 2043 blink::WebFrame* main_frame = web_view->MainFrame(); |
| 2044 if (!main_frame->IsWebLocalFrame()) { |
| 2045 CHECK(false) << "This function cannot be called if the main frame is not " |
| 2046 "a local frame."; |
| 2047 return false; |
| 2048 } |
| 2049 main_frame->ToWebLocalFrame()->ExecuteScript( |
2044 WebScriptSource(WebString::FromUTF8(script_))); | 2050 WebScriptSource(WebString::FromUTF8(script_))); |
2045 return true; // FIXME: Did it really start a navigation? | 2051 return true; // FIXME: Did it really start a navigation? |
2046 } | 2052 } |
2047 | 2053 |
2048 private: | 2054 private: |
2049 std::string script_; | 2055 std::string script_; |
2050 }; | 2056 }; |
2051 | 2057 |
2052 void TestRunner::QueueLoadingScript(const std::string& script) { | 2058 void TestRunner::QueueLoadingScript(const std::string& script) { |
2053 work_queue_.AddWork(new WorkItemLoadingScript(script)); | 2059 work_queue_.AddWork(new WorkItemLoadingScript(script)); |
2054 } | 2060 } |
2055 | 2061 |
2056 class WorkItemNonLoadingScript : public TestRunner::WorkItem { | 2062 class WorkItemNonLoadingScript : public TestRunner::WorkItem { |
2057 public: | 2063 public: |
2058 WorkItemNonLoadingScript(const std::string& script) : script_(script) {} | 2064 WorkItemNonLoadingScript(const std::string& script) : script_(script) {} |
2059 | 2065 |
2060 bool Run(WebTestDelegate*, WebView* web_view) override { | 2066 bool Run(WebTestDelegate*, WebView* web_view) override { |
2061 web_view->MainFrame()->ExecuteScript( | 2067 blink::WebFrame* main_frame = web_view->MainFrame(); |
| 2068 if (!main_frame->IsWebLocalFrame()) { |
| 2069 CHECK(false) << "This function cannot be called if the main frame is not " |
| 2070 "a local frame."; |
| 2071 return false; |
| 2072 } |
| 2073 main_frame->ToWebLocalFrame()->ExecuteScript( |
2062 WebScriptSource(WebString::FromUTF8(script_))); | 2074 WebScriptSource(WebString::FromUTF8(script_))); |
2063 return false; | 2075 return false; |
2064 } | 2076 } |
2065 | 2077 |
2066 private: | 2078 private: |
2067 std::string script_; | 2079 std::string script_; |
2068 }; | 2080 }; |
2069 | 2081 |
2070 void TestRunner::QueueNonLoadingScript(const std::string& script) { | 2082 void TestRunner::QueueNonLoadingScript(const std::string& script) { |
2071 work_queue_.AddWork(new WorkItemNonLoadingScript(script)); | 2083 work_queue_.AddWork(new WorkItemNonLoadingScript(script)); |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2794 | 2806 |
2795 void TestRunner::NotifyDone() { | 2807 void TestRunner::NotifyDone() { |
2796 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && | 2808 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && |
2797 !will_navigate_ && work_queue_.is_empty()) | 2809 !will_navigate_ && work_queue_.is_empty()) |
2798 delegate_->TestFinished(); | 2810 delegate_->TestFinished(); |
2799 layout_test_runtime_flags_.set_wait_until_done(false); | 2811 layout_test_runtime_flags_.set_wait_until_done(false); |
2800 OnLayoutTestRuntimeFlagsChanged(); | 2812 OnLayoutTestRuntimeFlagsChanged(); |
2801 } | 2813 } |
2802 | 2814 |
2803 } // namespace test_runner | 2815 } // namespace test_runner |
OLD | NEW |