| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/location.h" | 6 #include "base/location.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 IN_PROC_BROWSER_TEST_F(DomDistillerJsTest, RunJsTests) { | 102 IN_PROC_BROWSER_TEST_F(DomDistillerJsTest, RunJsTests) { |
| 103 // Load the test file in content shell and wait until it has fully loaded. | 103 // Load the test file in content shell and wait until it has fully loaded. |
| 104 content::WebContents* web_contents = shell()->web_contents(); | 104 content::WebContents* web_contents = shell()->web_contents(); |
| 105 dom_distiller::WebContentsMainFrameObserver::CreateForWebContents( | 105 dom_distiller::WebContentsMainFrameObserver::CreateForWebContents( |
| 106 web_contents); | 106 web_contents); |
| 107 base::RunLoop url_loaded_runner; | 107 base::RunLoop url_loaded_runner; |
| 108 WebContentsMainFrameHelper main_frame_loaded(web_contents, | 108 WebContentsMainFrameHelper main_frame_loaded(web_contents, |
| 109 url_loaded_runner.QuitClosure()); | 109 url_loaded_runner.QuitClosure()); |
| 110 web_contents->GetController().LoadURL( | 110 web_contents->GetController().LoadURL( |
| 111 embedded_test_server()->GetURL(kTestFilePath), | 111 embedded_test_server()->GetURL(kTestFilePath), content::Referrer(), |
| 112 content::Referrer(), | 112 ui::PAGE_TRANSITION_TYPED, std::string()); |
| 113 ui::PAGE_TRANSITION_TYPED, | |
| 114 std::string()); | |
| 115 url_loaded_runner.Run(); | 113 url_loaded_runner.Run(); |
| 116 | 114 |
| 117 // Execute the JS to run the tests, and wait until it has finished. | 115 // Execute the JS to run the tests, and wait until it has finished. |
| 118 base::RunLoop run_loop; | 116 base::RunLoop run_loop; |
| 119 js_test_execution_done_callback_ = run_loop.QuitClosure(); | 117 js_test_execution_done_callback_ = run_loop.QuitClosure(); |
| 120 // Add timeout in case JS Test execution fails. It is safe to call the | 118 // Add timeout in case JS Test execution fails. It is safe to call the |
| 121 // QuitClosure multiple times. | 119 // QuitClosure multiple times. |
| 122 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 120 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 123 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(15)); | 121 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(15)); |
| 124 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( | 122 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // Only print the log if there was an error. | 157 // Only print the log if there was an error. |
| 160 if (!success) { | 158 if (!success) { |
| 161 ASSERT_TRUE(dict->HasKey("log")); | 159 ASSERT_TRUE(dict->HasKey("log")); |
| 162 std::string console_log; | 160 std::string console_log; |
| 163 ASSERT_TRUE(dict->GetString("log", &console_log)); | 161 ASSERT_TRUE(dict->GetString("log", &console_log)); |
| 164 VLOG(0) << "Console log:\n" << console_log; | 162 VLOG(0) << "Console log:\n" << console_log; |
| 165 } | 163 } |
| 166 } | 164 } |
| 167 | 165 |
| 168 } // namespace dom_distiller | 166 } // namespace dom_distiller |
| OLD | NEW |