| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "headless/test/headless_browser_test.h" | 5 #include "headless/test/headless_browser_test.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 content::RenderProcessHost::AllHostsIterator()); | 144 content::RenderProcessHost::AllHostsIterator()); |
| 145 !i.IsAtEnd(); i.Advance()) { | 145 !i.IsAtEnd(); i.Advance()) { |
| 146 i.GetCurrentValue()->FastShutdownIfPossible(); | 146 i.GetCurrentValue()->FastShutdownIfPossible(); |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 HeadlessBrowser* HeadlessBrowserTest::browser() const { | 150 HeadlessBrowser* HeadlessBrowserTest::browser() const { |
| 151 return HeadlessContentMainDelegate::GetInstance()->browser(); | 151 return HeadlessContentMainDelegate::GetInstance()->browser(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 HeadlessBrowser::Options* HeadlessBrowserTest::options() const { |
| 155 return HeadlessContentMainDelegate::GetInstance()->browser()->options(); |
| 156 } |
| 157 |
| 154 bool HeadlessBrowserTest::WaitForLoad(HeadlessWebContents* web_contents) { | 158 bool HeadlessBrowserTest::WaitForLoad(HeadlessWebContents* web_contents) { |
| 155 SynchronousLoadObserver load_observer(this, web_contents); | 159 SynchronousLoadObserver load_observer(this, web_contents); |
| 156 RunAsynchronousTest(); | 160 RunAsynchronousTest(); |
| 157 return load_observer.navigation_succeeded(); | 161 return load_observer.navigation_succeeded(); |
| 158 } | 162 } |
| 159 | 163 |
| 160 std::unique_ptr<runtime::EvaluateResult> HeadlessBrowserTest::EvaluateScript( | 164 std::unique_ptr<runtime::EvaluateResult> HeadlessBrowserTest::EvaluateScript( |
| 161 HeadlessWebContents* web_contents, | 165 HeadlessWebContents* web_contents, |
| 162 const std::string& script) { | 166 const std::string& script) { |
| 163 EvaluateHelper helper(this, web_contents, script); | 167 EvaluateHelper helper(this, web_contents, script); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 204 |
| 201 web_contents_->GetDevToolsTarget()->DetachClient(devtools_client_.get()); | 205 web_contents_->GetDevToolsTarget()->DetachClient(devtools_client_.get()); |
| 202 web_contents_->RemoveObserver(this); | 206 web_contents_->RemoveObserver(this); |
| 203 web_contents_->Close(); | 207 web_contents_->Close(); |
| 204 web_contents_ = nullptr; | 208 web_contents_ = nullptr; |
| 205 browser_context_->Close(); | 209 browser_context_->Close(); |
| 206 browser_context_ = nullptr; | 210 browser_context_ = nullptr; |
| 207 } | 211 } |
| 208 | 212 |
| 209 } // namespace headless | 213 } // namespace headless |
| OLD | NEW |