OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/webkit_test_controller.h" | 5 #include "content/shell/browser/blink_test_controller.h" |
6 | 6 |
7 #include <iostream> | 7 #include <iostream> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "content/public/browser/devtools_agent_host.h" | 15 #include "content/public/browser/devtools_agent_host.h" |
(...skipping 18 matching lines...) Expand all Loading... |
34 #include "content/shell/common/shell_messages.h" | 34 #include "content/shell/common/shell_messages.h" |
35 #include "content/shell/common/shell_switches.h" | 35 #include "content/shell/common/shell_switches.h" |
36 #include "content/shell/common/webkit_test_helpers.h" | 36 #include "content/shell/common/webkit_test_helpers.h" |
37 #include "ui/gfx/codec/png_codec.h" | 37 #include "ui/gfx/codec/png_codec.h" |
38 | 38 |
39 namespace content { | 39 namespace content { |
40 | 40 |
41 const int kTestSVGWindowWidthDip = 480; | 41 const int kTestSVGWindowWidthDip = 480; |
42 const int kTestSVGWindowHeightDip = 360; | 42 const int kTestSVGWindowHeightDip = 360; |
43 | 43 |
44 // WebKitTestResultPrinter ---------------------------------------------------- | 44 // BlinkTestResultPrinter ---------------------------------------------------- |
45 | 45 |
46 WebKitTestResultPrinter::WebKitTestResultPrinter( | 46 BlinkTestResultPrinter::BlinkTestResultPrinter(std::ostream* output, |
47 std::ostream* output, std::ostream* error) | 47 std::ostream* error) |
48 : state_(DURING_TEST), | 48 : state_(DURING_TEST), |
49 capture_text_only_(false), | 49 capture_text_only_(false), |
50 encode_binary_data_(false), | 50 encode_binary_data_(false), |
51 output_(output), | 51 output_(output), |
52 error_(error) { | 52 error_(error) { |
53 } | 53 } |
54 | 54 |
55 WebKitTestResultPrinter::~WebKitTestResultPrinter() { | 55 BlinkTestResultPrinter::~BlinkTestResultPrinter() { |
56 } | 56 } |
57 | 57 |
58 void WebKitTestResultPrinter::PrintTextHeader() { | 58 void BlinkTestResultPrinter::PrintTextHeader() { |
59 if (state_ != DURING_TEST) | 59 if (state_ != DURING_TEST) |
60 return; | 60 return; |
61 if (!capture_text_only_) | 61 if (!capture_text_only_) |
62 *output_ << "Content-Type: text/plain\n"; | 62 *output_ << "Content-Type: text/plain\n"; |
63 state_ = IN_TEXT_BLOCK; | 63 state_ = IN_TEXT_BLOCK; |
64 } | 64 } |
65 | 65 |
66 void WebKitTestResultPrinter::PrintTextBlock(const std::string& block) { | 66 void BlinkTestResultPrinter::PrintTextBlock(const std::string& block) { |
67 if (state_ != IN_TEXT_BLOCK) | 67 if (state_ != IN_TEXT_BLOCK) |
68 return; | 68 return; |
69 *output_ << block; | 69 *output_ << block; |
70 } | 70 } |
71 | 71 |
72 void WebKitTestResultPrinter::PrintTextFooter() { | 72 void BlinkTestResultPrinter::PrintTextFooter() { |
73 if (state_ != IN_TEXT_BLOCK) | 73 if (state_ != IN_TEXT_BLOCK) |
74 return; | 74 return; |
75 if (!capture_text_only_) { | 75 if (!capture_text_only_) { |
76 *output_ << "#EOF\n"; | 76 *output_ << "#EOF\n"; |
77 output_->flush(); | 77 output_->flush(); |
78 } | 78 } |
79 state_ = IN_IMAGE_BLOCK; | 79 state_ = IN_IMAGE_BLOCK; |
80 } | 80 } |
81 | 81 |
82 void WebKitTestResultPrinter::PrintImageHeader( | 82 void BlinkTestResultPrinter::PrintImageHeader( |
83 const std::string& actual_hash, | 83 const std::string& actual_hash, |
84 const std::string& expected_hash) { | 84 const std::string& expected_hash) { |
85 if (state_ != IN_IMAGE_BLOCK || capture_text_only_) | 85 if (state_ != IN_IMAGE_BLOCK || capture_text_only_) |
86 return; | 86 return; |
87 *output_ << "\nActualHash: " << actual_hash << "\n"; | 87 *output_ << "\nActualHash: " << actual_hash << "\n"; |
88 if (!expected_hash.empty()) | 88 if (!expected_hash.empty()) |
89 *output_ << "\nExpectedHash: " << expected_hash << "\n"; | 89 *output_ << "\nExpectedHash: " << expected_hash << "\n"; |
90 } | 90 } |
91 | 91 |
92 void WebKitTestResultPrinter::PrintImageBlock( | 92 void BlinkTestResultPrinter::PrintImageBlock( |
93 const std::vector<unsigned char>& png_image) { | 93 const std::vector<unsigned char>& png_image) { |
94 if (state_ != IN_IMAGE_BLOCK || capture_text_only_) | 94 if (state_ != IN_IMAGE_BLOCK || capture_text_only_) |
95 return; | 95 return; |
96 *output_ << "Content-Type: image/png\n"; | 96 *output_ << "Content-Type: image/png\n"; |
97 if (encode_binary_data_) { | 97 if (encode_binary_data_) { |
98 PrintEncodedBinaryData(png_image); | 98 PrintEncodedBinaryData(png_image); |
99 return; | 99 return; |
100 } | 100 } |
101 | 101 |
102 *output_ << "Content-Length: " << png_image.size() << "\n"; | 102 *output_ << "Content-Length: " << png_image.size() << "\n"; |
103 output_->write( | 103 output_->write( |
104 reinterpret_cast<const char*>(&png_image[0]), png_image.size()); | 104 reinterpret_cast<const char*>(&png_image[0]), png_image.size()); |
105 } | 105 } |
106 | 106 |
107 void WebKitTestResultPrinter::PrintImageFooter() { | 107 void BlinkTestResultPrinter::PrintImageFooter() { |
108 if (state_ != IN_IMAGE_BLOCK) | 108 if (state_ != IN_IMAGE_BLOCK) |
109 return; | 109 return; |
110 if (!capture_text_only_) { | 110 if (!capture_text_only_) { |
111 *output_ << "#EOF\n"; | 111 *output_ << "#EOF\n"; |
112 output_->flush(); | 112 output_->flush(); |
113 } | 113 } |
114 state_ = AFTER_TEST; | 114 state_ = AFTER_TEST; |
115 } | 115 } |
116 | 116 |
117 void WebKitTestResultPrinter::PrintAudioHeader() { | 117 void BlinkTestResultPrinter::PrintAudioHeader() { |
118 DCHECK_EQ(state_, DURING_TEST); | 118 DCHECK_EQ(state_, DURING_TEST); |
119 if (!capture_text_only_) | 119 if (!capture_text_only_) |
120 *output_ << "Content-Type: audio/wav\n"; | 120 *output_ << "Content-Type: audio/wav\n"; |
121 state_ = IN_AUDIO_BLOCK; | 121 state_ = IN_AUDIO_BLOCK; |
122 } | 122 } |
123 | 123 |
124 void WebKitTestResultPrinter::PrintAudioBlock( | 124 void BlinkTestResultPrinter::PrintAudioBlock( |
125 const std::vector<unsigned char>& audio_data) { | 125 const std::vector<unsigned char>& audio_data) { |
126 if (state_ != IN_AUDIO_BLOCK || capture_text_only_) | 126 if (state_ != IN_AUDIO_BLOCK || capture_text_only_) |
127 return; | 127 return; |
128 if (encode_binary_data_) { | 128 if (encode_binary_data_) { |
129 PrintEncodedBinaryData(audio_data); | 129 PrintEncodedBinaryData(audio_data); |
130 return; | 130 return; |
131 } | 131 } |
132 | 132 |
133 *output_ << "Content-Length: " << audio_data.size() << "\n"; | 133 *output_ << "Content-Length: " << audio_data.size() << "\n"; |
134 output_->write( | 134 output_->write( |
135 reinterpret_cast<const char*>(&audio_data[0]), audio_data.size()); | 135 reinterpret_cast<const char*>(&audio_data[0]), audio_data.size()); |
136 } | 136 } |
137 | 137 |
138 void WebKitTestResultPrinter::PrintAudioFooter() { | 138 void BlinkTestResultPrinter::PrintAudioFooter() { |
139 if (state_ != IN_AUDIO_BLOCK) | 139 if (state_ != IN_AUDIO_BLOCK) |
140 return; | 140 return; |
141 if (!capture_text_only_) { | 141 if (!capture_text_only_) { |
142 *output_ << "#EOF\n"; | 142 *output_ << "#EOF\n"; |
143 output_->flush(); | 143 output_->flush(); |
144 } | 144 } |
145 state_ = IN_IMAGE_BLOCK; | 145 state_ = IN_IMAGE_BLOCK; |
146 } | 146 } |
147 | 147 |
148 void WebKitTestResultPrinter::AddMessage(const std::string& message) { | 148 void BlinkTestResultPrinter::AddMessage(const std::string& message) { |
149 AddMessageRaw(message + "\n"); | 149 AddMessageRaw(message + "\n"); |
150 } | 150 } |
151 | 151 |
152 void WebKitTestResultPrinter::AddMessageRaw(const std::string& message) { | 152 void BlinkTestResultPrinter::AddMessageRaw(const std::string& message) { |
153 if (state_ != DURING_TEST) | 153 if (state_ != DURING_TEST) |
154 return; | 154 return; |
155 *output_ << message; | 155 *output_ << message; |
156 } | 156 } |
157 | 157 |
158 void WebKitTestResultPrinter::AddErrorMessage(const std::string& message) { | 158 void BlinkTestResultPrinter::AddErrorMessage(const std::string& message) { |
159 if (!capture_text_only_) | 159 if (!capture_text_only_) |
160 *error_ << message << "\n"; | 160 *error_ << message << "\n"; |
161 if (state_ != DURING_TEST) | 161 if (state_ != DURING_TEST) |
162 return; | 162 return; |
163 PrintTextHeader(); | 163 PrintTextHeader(); |
164 *output_ << message << "\n"; | 164 *output_ << message << "\n"; |
165 PrintTextFooter(); | 165 PrintTextFooter(); |
166 PrintImageFooter(); | 166 PrintImageFooter(); |
167 } | 167 } |
168 | 168 |
169 void WebKitTestResultPrinter::PrintEncodedBinaryData( | 169 void BlinkTestResultPrinter::PrintEncodedBinaryData( |
170 const std::vector<unsigned char>& data) { | 170 const std::vector<unsigned char>& data) { |
171 *output_ << "Content-Transfer-Encoding: base64\n"; | 171 *output_ << "Content-Transfer-Encoding: base64\n"; |
172 | 172 |
173 std::string data_base64; | 173 std::string data_base64; |
174 base::Base64Encode( | 174 base::Base64Encode( |
175 base::StringPiece(reinterpret_cast<const char*>(&data[0]), data.size()), | 175 base::StringPiece(reinterpret_cast<const char*>(&data[0]), data.size()), |
176 &data_base64); | 176 &data_base64); |
177 | 177 |
178 *output_ << "Content-Length: " << data_base64.length() << "\n"; | 178 *output_ << "Content-Length: " << data_base64.length() << "\n"; |
179 output_->write(data_base64.c_str(), data_base64.length()); | 179 output_->write(data_base64.c_str(), data_base64.length()); |
180 } | 180 } |
181 | 181 |
182 void WebKitTestResultPrinter::CloseStderr() { | 182 void BlinkTestResultPrinter::CloseStderr() { |
183 if (state_ != AFTER_TEST) | 183 if (state_ != AFTER_TEST) |
184 return; | 184 return; |
185 if (!capture_text_only_) { | 185 if (!capture_text_only_) { |
186 *error_ << "#EOF\n"; | 186 *error_ << "#EOF\n"; |
187 error_->flush(); | 187 error_->flush(); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
| 191 // BlinkTestController ------------------------------------------------------- |
191 | 192 |
192 // WebKitTestController ------------------------------------------------------- | 193 BlinkTestController* BlinkTestController::instance_ = NULL; |
193 | |
194 WebKitTestController* WebKitTestController::instance_ = NULL; | |
195 | 194 |
196 // static | 195 // static |
197 WebKitTestController* WebKitTestController::Get() { | 196 BlinkTestController* BlinkTestController::Get() { |
198 DCHECK(instance_); | 197 DCHECK(instance_); |
199 return instance_; | 198 return instance_; |
200 } | 199 } |
201 | 200 |
202 WebKitTestController::WebKitTestController() | 201 BlinkTestController::BlinkTestController() |
203 : main_window_(NULL), | 202 : main_window_(NULL), |
204 test_phase_(BETWEEN_TESTS), | 203 test_phase_(BETWEEN_TESTS), |
205 is_leak_detection_enabled_( | 204 is_leak_detection_enabled_( |
206 base::CommandLine::ForCurrentProcess()->HasSwitch( | 205 base::CommandLine::ForCurrentProcess()->HasSwitch( |
207 switches::kEnableLeakDetection)), | 206 switches::kEnableLeakDetection)), |
208 crash_when_leak_found_(false), | 207 crash_when_leak_found_(false), |
209 devtools_frontend_(NULL) { | 208 devtools_frontend_(NULL) { |
210 CHECK(!instance_); | 209 CHECK(!instance_); |
211 instance_ = this; | 210 instance_ = this; |
212 | 211 |
213 if (is_leak_detection_enabled_) { | 212 if (is_leak_detection_enabled_) { |
214 std::string switchValue = | 213 std::string switchValue = |
215 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 214 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
216 switches::kEnableLeakDetection); | 215 switches::kEnableLeakDetection); |
217 crash_when_leak_found_ = switchValue == switches::kCrashOnFailure; | 216 crash_when_leak_found_ = switchValue == switches::kCrashOnFailure; |
218 } | 217 } |
219 | 218 |
220 printer_.reset(new WebKitTestResultPrinter(&std::cout, &std::cerr)); | 219 printer_.reset(new BlinkTestResultPrinter(&std::cout, &std::cerr)); |
221 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 220 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
222 switches::kEncodeBinary)) | 221 switches::kEncodeBinary)) |
223 printer_->set_encode_binary_data(true); | 222 printer_->set_encode_binary_data(true); |
224 registrar_.Add(this, | 223 registrar_.Add(this, |
225 NOTIFICATION_RENDERER_PROCESS_CREATED, | 224 NOTIFICATION_RENDERER_PROCESS_CREATED, |
226 NotificationService::AllSources()); | 225 NotificationService::AllSources()); |
227 GpuDataManager::GetInstance()->AddObserver(this); | 226 GpuDataManager::GetInstance()->AddObserver(this); |
228 ResetAfterLayoutTest(); | 227 ResetAfterLayoutTest(); |
229 } | 228 } |
230 | 229 |
231 WebKitTestController::~WebKitTestController() { | 230 BlinkTestController::~BlinkTestController() { |
232 DCHECK(CalledOnValidThread()); | 231 DCHECK(CalledOnValidThread()); |
233 CHECK(instance_ == this); | 232 CHECK(instance_ == this); |
234 CHECK(test_phase_ == BETWEEN_TESTS); | 233 CHECK(test_phase_ == BETWEEN_TESTS); |
235 GpuDataManager::GetInstance()->RemoveObserver(this); | 234 GpuDataManager::GetInstance()->RemoveObserver(this); |
236 DiscardMainWindow(); | 235 DiscardMainWindow(); |
237 instance_ = NULL; | 236 instance_ = NULL; |
238 } | 237 } |
239 | 238 |
240 bool WebKitTestController::PrepareForLayoutTest( | 239 bool BlinkTestController::PrepareForLayoutTest( |
241 const GURL& test_url, | 240 const GURL& test_url, |
242 const base::FilePath& current_working_directory, | 241 const base::FilePath& current_working_directory, |
243 bool enable_pixel_dumping, | 242 bool enable_pixel_dumping, |
244 const std::string& expected_pixel_hash) { | 243 const std::string& expected_pixel_hash) { |
245 DCHECK(CalledOnValidThread()); | 244 DCHECK(CalledOnValidThread()); |
246 test_phase_ = DURING_TEST; | 245 test_phase_ = DURING_TEST; |
247 current_working_directory_ = current_working_directory; | 246 current_working_directory_ = current_working_directory; |
248 enable_pixel_dumping_ = enable_pixel_dumping; | 247 enable_pixel_dumping_ = enable_pixel_dumping; |
249 expected_pixel_hash_ = expected_pixel_hash; | 248 expected_pixel_hash_ = expected_pixel_hash; |
250 test_url_ = test_url; | 249 test_url_ = test_url; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); | 286 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); |
288 params.should_clear_history_list = true; | 287 params.should_clear_history_list = true; |
289 main_window_->web_contents()->GetController().LoadURLWithParams(params); | 288 main_window_->web_contents()->GetController().LoadURLWithParams(params); |
290 main_window_->web_contents()->Focus(); | 289 main_window_->web_contents()->Focus(); |
291 } | 290 } |
292 main_window_->web_contents()->GetRenderViewHost()->SetActive(true); | 291 main_window_->web_contents()->GetRenderViewHost()->SetActive(true); |
293 main_window_->web_contents()->GetRenderViewHost()->Focus(); | 292 main_window_->web_contents()->GetRenderViewHost()->Focus(); |
294 return true; | 293 return true; |
295 } | 294 } |
296 | 295 |
297 bool WebKitTestController::ResetAfterLayoutTest() { | 296 bool BlinkTestController::ResetAfterLayoutTest() { |
298 DCHECK(CalledOnValidThread()); | 297 DCHECK(CalledOnValidThread()); |
299 printer_->PrintTextFooter(); | 298 printer_->PrintTextFooter(); |
300 printer_->PrintImageFooter(); | 299 printer_->PrintImageFooter(); |
301 printer_->CloseStderr(); | 300 printer_->CloseStderr(); |
302 send_configuration_to_next_host_ = false; | 301 send_configuration_to_next_host_ = false; |
303 test_phase_ = BETWEEN_TESTS; | 302 test_phase_ = BETWEEN_TESTS; |
304 is_compositing_test_ = false; | 303 is_compositing_test_ = false; |
305 enable_pixel_dumping_ = false; | 304 enable_pixel_dumping_ = false; |
306 expected_pixel_hash_.clear(); | 305 expected_pixel_hash_.clear(); |
307 test_url_ = GURL(); | 306 test_url_ = GURL(); |
308 prefs_ = WebPreferences(); | 307 prefs_ = WebPreferences(); |
309 should_override_prefs_ = false; | 308 should_override_prefs_ = false; |
310 | 309 |
311 #if defined(OS_ANDROID) | 310 #if defined(OS_ANDROID) |
312 // Re-using the shell's main window on Android causes issues with networking | 311 // Re-using the shell's main window on Android causes issues with networking |
313 // requests never succeeding. See http://crbug.com/277652. | 312 // requests never succeeding. See http://crbug.com/277652. |
314 DiscardMainWindow(); | 313 DiscardMainWindow(); |
315 #endif | 314 #endif |
316 return true; | 315 return true; |
317 } | 316 } |
318 | 317 |
319 void WebKitTestController::SetTempPath(const base::FilePath& temp_path) { | 318 void BlinkTestController::SetTempPath(const base::FilePath& temp_path) { |
320 temp_path_ = temp_path; | 319 temp_path_ = temp_path; |
321 } | 320 } |
322 | 321 |
323 void WebKitTestController::RendererUnresponsive() { | 322 void BlinkTestController::RendererUnresponsive() { |
324 DCHECK(CalledOnValidThread()); | 323 DCHECK(CalledOnValidThread()); |
325 LOG(WARNING) << "renderer unresponsive"; | 324 LOG(WARNING) << "renderer unresponsive"; |
326 } | 325 } |
327 | 326 |
328 void WebKitTestController::WorkerCrashed() { | 327 void BlinkTestController::WorkerCrashed() { |
329 DCHECK(CalledOnValidThread()); | 328 DCHECK(CalledOnValidThread()); |
330 printer_->AddErrorMessage("#CRASHED - worker"); | 329 printer_->AddErrorMessage("#CRASHED - worker"); |
331 DiscardMainWindow(); | 330 DiscardMainWindow(); |
332 } | 331 } |
333 | 332 |
334 void WebKitTestController::OverrideWebkitPrefs(WebPreferences* prefs) { | 333 void BlinkTestController::OverrideWebkitPrefs(WebPreferences* prefs) { |
335 if (should_override_prefs_) { | 334 if (should_override_prefs_) { |
336 *prefs = prefs_; | 335 *prefs = prefs_; |
337 } else { | 336 } else { |
338 ApplyLayoutTestDefaultPreferences(prefs); | 337 ApplyLayoutTestDefaultPreferences(prefs); |
339 if (is_compositing_test_) { | 338 if (is_compositing_test_) { |
340 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); | 339 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); |
341 if (!command_line.HasSwitch(switches::kDisableGpu)) | 340 if (!command_line.HasSwitch(switches::kDisableGpu)) |
342 prefs->accelerated_2d_canvas_enabled = true; | 341 prefs->accelerated_2d_canvas_enabled = true; |
343 prefs->mock_scrollbars_enabled = true; | 342 prefs->mock_scrollbars_enabled = true; |
344 } | 343 } |
345 } | 344 } |
346 } | 345 } |
347 | 346 |
348 void WebKitTestController::OpenURL(const GURL& url) { | 347 void BlinkTestController::OpenURL(const GURL& url) { |
349 if (test_phase_ != DURING_TEST) | 348 if (test_phase_ != DURING_TEST) |
350 return; | 349 return; |
351 | 350 |
352 Shell::CreateNewWindow(main_window_->web_contents()->GetBrowserContext(), | 351 Shell::CreateNewWindow(main_window_->web_contents()->GetBrowserContext(), |
353 url, | 352 url, |
354 main_window_->web_contents()->GetSiteInstance(), | 353 main_window_->web_contents()->GetSiteInstance(), |
355 gfx::Size()); | 354 gfx::Size()); |
356 } | 355 } |
357 | 356 |
358 void WebKitTestController::TestFinishedInSecondaryWindow() { | 357 void BlinkTestController::TestFinishedInSecondaryWindow() { |
359 RenderViewHost* render_view_host = | 358 RenderViewHost* render_view_host = |
360 main_window_->web_contents()->GetRenderViewHost(); | 359 main_window_->web_contents()->GetRenderViewHost(); |
361 render_view_host->Send( | 360 render_view_host->Send( |
362 new ShellViewMsg_NotifyDone(render_view_host->GetRoutingID())); | 361 new ShellViewMsg_NotifyDone(render_view_host->GetRoutingID())); |
363 } | 362 } |
364 | 363 |
365 bool WebKitTestController::IsMainWindow(WebContents* web_contents) const { | 364 bool BlinkTestController::IsMainWindow(WebContents* web_contents) const { |
366 return main_window_ && web_contents == main_window_->web_contents(); | 365 return main_window_ && web_contents == main_window_->web_contents(); |
367 } | 366 } |
368 | 367 |
369 bool WebKitTestController::OnMessageReceived(const IPC::Message& message) { | 368 bool BlinkTestController::OnMessageReceived(const IPC::Message& message) { |
370 DCHECK(CalledOnValidThread()); | 369 DCHECK(CalledOnValidThread()); |
371 bool handled = true; | 370 bool handled = true; |
372 IPC_BEGIN_MESSAGE_MAP(WebKitTestController, message) | 371 IPC_BEGIN_MESSAGE_MAP(BlinkTestController, message) |
373 IPC_MESSAGE_HANDLER(ShellViewHostMsg_PrintMessage, OnPrintMessage) | 372 IPC_MESSAGE_HANDLER(ShellViewHostMsg_PrintMessage, OnPrintMessage) |
374 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump) | 373 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump) |
375 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump) | 374 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump) |
376 IPC_MESSAGE_HANDLER(ShellViewHostMsg_AudioDump, OnAudioDump) | 375 IPC_MESSAGE_HANDLER(ShellViewHostMsg_AudioDump, OnAudioDump) |
377 IPC_MESSAGE_HANDLER(ShellViewHostMsg_OverridePreferences, | 376 IPC_MESSAGE_HANDLER(ShellViewHostMsg_OverridePreferences, |
378 OnOverridePreferences) | 377 OnOverridePreferences) |
379 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TestFinished, OnTestFinished) | 378 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TestFinished, OnTestFinished) |
380 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ClearDevToolsLocalStorage, | 379 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ClearDevToolsLocalStorage, |
381 OnClearDevToolsLocalStorage) | 380 OnClearDevToolsLocalStorage) |
382 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ShowDevTools, OnShowDevTools) | 381 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ShowDevTools, OnShowDevTools) |
383 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseDevTools, OnCloseDevTools) | 382 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseDevTools, OnCloseDevTools) |
384 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GoToOffset, OnGoToOffset) | 383 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GoToOffset, OnGoToOffset) |
385 IPC_MESSAGE_HANDLER(ShellViewHostMsg_Reload, OnReload) | 384 IPC_MESSAGE_HANDLER(ShellViewHostMsg_Reload, OnReload) |
386 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LoadURLForFrame, OnLoadURLForFrame) | 385 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LoadURLForFrame, OnLoadURLForFrame) |
387 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CaptureSessionHistory, | 386 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CaptureSessionHistory, |
388 OnCaptureSessionHistory) | 387 OnCaptureSessionHistory) |
389 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseRemainingWindows, | 388 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseRemainingWindows, |
390 OnCloseRemainingWindows) | 389 OnCloseRemainingWindows) |
391 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ResetDone, OnResetDone) | 390 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ResetDone, OnResetDone) |
392 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LeakDetectionDone, OnLeakDetectionDone) | 391 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LeakDetectionDone, OnLeakDetectionDone) |
393 IPC_MESSAGE_UNHANDLED(handled = false) | 392 IPC_MESSAGE_UNHANDLED(handled = false) |
394 IPC_END_MESSAGE_MAP() | 393 IPC_END_MESSAGE_MAP() |
395 | 394 |
396 return handled; | 395 return handled; |
397 } | 396 } |
398 | 397 |
399 void WebKitTestController::PluginCrashed(const base::FilePath& plugin_path, | 398 void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path, |
400 base::ProcessId plugin_pid) { | 399 base::ProcessId plugin_pid) { |
401 DCHECK(CalledOnValidThread()); | 400 DCHECK(CalledOnValidThread()); |
402 printer_->AddErrorMessage( | 401 printer_->AddErrorMessage( |
403 base::StringPrintf("#CRASHED - plugin (pid %d)", plugin_pid)); | 402 base::StringPrintf("#CRASHED - plugin (pid %d)", plugin_pid)); |
404 base::MessageLoop::current()->PostTask( | 403 base::MessageLoop::current()->PostTask( |
405 FROM_HERE, | 404 FROM_HERE, |
406 base::Bind(base::IgnoreResult(&WebKitTestController::DiscardMainWindow), | 405 base::Bind(base::IgnoreResult(&BlinkTestController::DiscardMainWindow), |
407 base::Unretained(this))); | 406 base::Unretained(this))); |
408 } | 407 } |
409 | 408 |
410 void WebKitTestController::RenderViewCreated(RenderViewHost* render_view_host) { | 409 void BlinkTestController::RenderViewCreated(RenderViewHost* render_view_host) { |
411 DCHECK(CalledOnValidThread()); | 410 DCHECK(CalledOnValidThread()); |
412 // Might be kNullProcessHandle, in which case we will receive a notification | 411 // Might be kNullProcessHandle, in which case we will receive a notification |
413 // later when the RenderProcessHost was created. | 412 // later when the RenderProcessHost was created. |
414 if (render_view_host->GetProcess()->GetHandle() != base::kNullProcessHandle) | 413 if (render_view_host->GetProcess()->GetHandle() != base::kNullProcessHandle) |
415 current_pid_ = base::GetProcId(render_view_host->GetProcess()->GetHandle()); | 414 current_pid_ = base::GetProcId(render_view_host->GetProcess()->GetHandle()); |
416 if (!send_configuration_to_next_host_) | 415 if (!send_configuration_to_next_host_) |
417 return; | 416 return; |
418 send_configuration_to_next_host_ = false; | 417 send_configuration_to_next_host_ = false; |
419 SendTestConfiguration(); | 418 SendTestConfiguration(); |
420 } | 419 } |
421 | 420 |
422 void WebKitTestController::RenderProcessGone(base::TerminationStatus status) { | 421 void BlinkTestController::RenderProcessGone(base::TerminationStatus status) { |
423 DCHECK(CalledOnValidThread()); | 422 DCHECK(CalledOnValidThread()); |
424 if (current_pid_ != base::kNullProcessId) { | 423 if (current_pid_ != base::kNullProcessId) { |
425 printer_->AddErrorMessage(std::string("#CRASHED - renderer (pid ") + | 424 printer_->AddErrorMessage(std::string("#CRASHED - renderer (pid ") + |
426 base::IntToString(current_pid_) + ")"); | 425 base::IntToString(current_pid_) + ")"); |
427 } else { | 426 } else { |
428 printer_->AddErrorMessage("#CRASHED - renderer"); | 427 printer_->AddErrorMessage("#CRASHED - renderer"); |
429 } | 428 } |
430 DiscardMainWindow(); | 429 DiscardMainWindow(); |
431 } | 430 } |
432 | 431 |
433 void WebKitTestController::DevToolsProcessCrashed() { | 432 void BlinkTestController::DevToolsProcessCrashed() { |
434 DCHECK(CalledOnValidThread()); | 433 DCHECK(CalledOnValidThread()); |
435 printer_->AddErrorMessage("#CRASHED - devtools"); | 434 printer_->AddErrorMessage("#CRASHED - devtools"); |
436 if (devtools_frontend_) | 435 if (devtools_frontend_) |
437 devtools_frontend_->Close(); | 436 devtools_frontend_->Close(); |
438 devtools_frontend_ = NULL; | 437 devtools_frontend_ = NULL; |
439 } | 438 } |
440 | 439 |
441 void WebKitTestController::WebContentsDestroyed() { | 440 void BlinkTestController::WebContentsDestroyed() { |
442 DCHECK(CalledOnValidThread()); | 441 DCHECK(CalledOnValidThread()); |
443 printer_->AddErrorMessage("FAIL: main window was destroyed"); | 442 printer_->AddErrorMessage("FAIL: main window was destroyed"); |
444 DiscardMainWindow(); | 443 DiscardMainWindow(); |
445 } | 444 } |
446 | 445 |
447 void WebKitTestController::Observe(int type, | 446 void BlinkTestController::Observe(int type, |
448 const NotificationSource& source, | 447 const NotificationSource& source, |
449 const NotificationDetails& details) { | 448 const NotificationDetails& details) { |
450 DCHECK(CalledOnValidThread()); | 449 DCHECK(CalledOnValidThread()); |
451 switch (type) { | 450 switch (type) { |
452 case NOTIFICATION_RENDERER_PROCESS_CREATED: { | 451 case NOTIFICATION_RENDERER_PROCESS_CREATED: { |
453 if (!main_window_) | 452 if (!main_window_) |
454 return; | 453 return; |
455 RenderViewHost* render_view_host = | 454 RenderViewHost* render_view_host = |
456 main_window_->web_contents()->GetRenderViewHost(); | 455 main_window_->web_contents()->GetRenderViewHost(); |
457 if (!render_view_host) | 456 if (!render_view_host) |
458 return; | 457 return; |
459 RenderProcessHost* render_process_host = | 458 RenderProcessHost* render_process_host = |
460 Source<RenderProcessHost>(source).ptr(); | 459 Source<RenderProcessHost>(source).ptr(); |
461 if (render_process_host != render_view_host->GetProcess()) | 460 if (render_process_host != render_view_host->GetProcess()) |
462 return; | 461 return; |
463 current_pid_ = base::GetProcId(render_process_host->GetHandle()); | 462 current_pid_ = base::GetProcId(render_process_host->GetHandle()); |
464 break; | 463 break; |
465 } | 464 } |
466 default: | 465 default: |
467 NOTREACHED(); | 466 NOTREACHED(); |
468 } | 467 } |
469 } | 468 } |
470 | 469 |
471 void WebKitTestController::OnGpuProcessCrashed( | 470 void BlinkTestController::OnGpuProcessCrashed( |
472 base::TerminationStatus exit_code) { | 471 base::TerminationStatus exit_code) { |
473 DCHECK(CalledOnValidThread()); | 472 DCHECK(CalledOnValidThread()); |
474 printer_->AddErrorMessage("#CRASHED - gpu"); | 473 printer_->AddErrorMessage("#CRASHED - gpu"); |
475 DiscardMainWindow(); | 474 DiscardMainWindow(); |
476 } | 475 } |
477 | 476 |
478 void WebKitTestController::DiscardMainWindow() { | 477 void BlinkTestController::DiscardMainWindow() { |
479 // If we're running a test, we need to close all windows and exit the message | 478 // If we're running a test, we need to close all windows and exit the message |
480 // loop. Otherwise, we're already outside of the message loop, and we just | 479 // loop. Otherwise, we're already outside of the message loop, and we just |
481 // discard the main window. | 480 // discard the main window. |
482 WebContentsObserver::Observe(NULL); | 481 WebContentsObserver::Observe(NULL); |
483 if (test_phase_ != BETWEEN_TESTS) { | 482 if (test_phase_ != BETWEEN_TESTS) { |
484 Shell::CloseAllWindows(); | 483 Shell::CloseAllWindows(); |
485 base::MessageLoop::current()->PostTask(FROM_HERE, | 484 base::MessageLoop::current()->PostTask(FROM_HERE, |
486 base::MessageLoop::QuitClosure()); | 485 base::MessageLoop::QuitClosure()); |
487 test_phase_ = CLEAN_UP; | 486 test_phase_ = CLEAN_UP; |
488 } else if (main_window_) { | 487 } else if (main_window_) { |
489 main_window_->Close(); | 488 main_window_->Close(); |
490 } | 489 } |
491 main_window_ = NULL; | 490 main_window_ = NULL; |
492 current_pid_ = base::kNullProcessId; | 491 current_pid_ = base::kNullProcessId; |
493 } | 492 } |
494 | 493 |
495 void WebKitTestController::SendTestConfiguration() { | 494 void BlinkTestController::SendTestConfiguration() { |
496 RenderViewHost* render_view_host = | 495 RenderViewHost* render_view_host = |
497 main_window_->web_contents()->GetRenderViewHost(); | 496 main_window_->web_contents()->GetRenderViewHost(); |
498 ShellTestConfiguration params; | 497 ShellTestConfiguration params; |
499 params.current_working_directory = current_working_directory_; | 498 params.current_working_directory = current_working_directory_; |
500 params.temp_path = temp_path_; | 499 params.temp_path = temp_path_; |
501 params.test_url = test_url_; | 500 params.test_url = test_url_; |
502 params.enable_pixel_dumping = enable_pixel_dumping_; | 501 params.enable_pixel_dumping = enable_pixel_dumping_; |
503 params.allow_external_pages = | 502 params.allow_external_pages = |
504 base::CommandLine::ForCurrentProcess()->HasSwitch( | 503 base::CommandLine::ForCurrentProcess()->HasSwitch( |
505 switches::kAllowExternalPages); | 504 switches::kAllowExternalPages); |
506 params.expected_pixel_hash = expected_pixel_hash_; | 505 params.expected_pixel_hash = expected_pixel_hash_; |
507 params.initial_size = initial_size_; | 506 params.initial_size = initial_size_; |
508 render_view_host->Send(new ShellViewMsg_SetTestConfiguration( | 507 render_view_host->Send(new ShellViewMsg_SetTestConfiguration( |
509 render_view_host->GetRoutingID(), params)); | 508 render_view_host->GetRoutingID(), params)); |
510 } | 509 } |
511 | 510 |
512 void WebKitTestController::OnTestFinished() { | 511 void BlinkTestController::OnTestFinished() { |
513 test_phase_ = CLEAN_UP; | 512 test_phase_ = CLEAN_UP; |
514 if (!printer_->output_finished()) | 513 if (!printer_->output_finished()) |
515 printer_->PrintImageFooter(); | 514 printer_->PrintImageFooter(); |
516 RenderViewHost* render_view_host = | 515 RenderViewHost* render_view_host = |
517 main_window_->web_contents()->GetRenderViewHost(); | 516 main_window_->web_contents()->GetRenderViewHost(); |
518 main_window_->web_contents()->ExitFullscreen(); | 517 main_window_->web_contents()->ExitFullscreen(); |
519 base::MessageLoop::current()->PostTask( | 518 base::MessageLoop::current()->PostTask( |
520 FROM_HERE, | 519 FROM_HERE, |
521 base::Bind(base::IgnoreResult(&WebKitTestController::Send), | 520 base::Bind(base::IgnoreResult(&BlinkTestController::Send), |
522 base::Unretained(this), | 521 base::Unretained(this), |
523 new ShellViewMsg_Reset(render_view_host->GetRoutingID()))); | 522 new ShellViewMsg_Reset(render_view_host->GetRoutingID()))); |
524 } | 523 } |
525 | 524 |
526 void WebKitTestController::OnImageDump( | 525 void BlinkTestController::OnImageDump(const std::string& actual_pixel_hash, |
527 const std::string& actual_pixel_hash, | 526 const SkBitmap& image) { |
528 const SkBitmap& image) { | |
529 SkAutoLockPixels image_lock(image); | 527 SkAutoLockPixels image_lock(image); |
530 | 528 |
531 printer_->PrintImageHeader(actual_pixel_hash, expected_pixel_hash_); | 529 printer_->PrintImageHeader(actual_pixel_hash, expected_pixel_hash_); |
532 | 530 |
533 // Only encode and dump the png if the hashes don't match. Encoding the | 531 // Only encode and dump the png if the hashes don't match. Encoding the |
534 // image is really expensive. | 532 // image is really expensive. |
535 if (actual_pixel_hash != expected_pixel_hash_) { | 533 if (actual_pixel_hash != expected_pixel_hash_) { |
536 std::vector<unsigned char> png; | 534 std::vector<unsigned char> png; |
537 | 535 |
538 bool discard_transparency = true; | 536 bool discard_transparency = true; |
(...skipping 10 matching lines...) Expand all Loading... |
549 static_cast<int>(image.rowBytes()), | 547 static_cast<int>(image.rowBytes()), |
550 discard_transparency, | 548 discard_transparency, |
551 comments, | 549 comments, |
552 &png); | 550 &png); |
553 if (success) | 551 if (success) |
554 printer_->PrintImageBlock(png); | 552 printer_->PrintImageBlock(png); |
555 } | 553 } |
556 printer_->PrintImageFooter(); | 554 printer_->PrintImageFooter(); |
557 } | 555 } |
558 | 556 |
559 void WebKitTestController::OnAudioDump(const std::vector<unsigned char>& dump) { | 557 void BlinkTestController::OnAudioDump(const std::vector<unsigned char>& dump) { |
560 printer_->PrintAudioHeader(); | 558 printer_->PrintAudioHeader(); |
561 printer_->PrintAudioBlock(dump); | 559 printer_->PrintAudioBlock(dump); |
562 printer_->PrintAudioFooter(); | 560 printer_->PrintAudioFooter(); |
563 } | 561 } |
564 | 562 |
565 void WebKitTestController::OnTextDump(const std::string& dump) { | 563 void BlinkTestController::OnTextDump(const std::string& dump) { |
566 printer_->PrintTextHeader(); | 564 printer_->PrintTextHeader(); |
567 printer_->PrintTextBlock(dump); | 565 printer_->PrintTextBlock(dump); |
568 printer_->PrintTextFooter(); | 566 printer_->PrintTextFooter(); |
569 } | 567 } |
570 | 568 |
571 void WebKitTestController::OnPrintMessage(const std::string& message) { | 569 void BlinkTestController::OnPrintMessage(const std::string& message) { |
572 printer_->AddMessageRaw(message); | 570 printer_->AddMessageRaw(message); |
573 } | 571 } |
574 | 572 |
575 void WebKitTestController::OnOverridePreferences(const WebPreferences& prefs) { | 573 void BlinkTestController::OnOverridePreferences(const WebPreferences& prefs) { |
576 should_override_prefs_ = true; | 574 should_override_prefs_ = true; |
577 prefs_ = prefs; | 575 prefs_ = prefs; |
578 } | 576 } |
579 | 577 |
580 void WebKitTestController::OnClearDevToolsLocalStorage() { | 578 void BlinkTestController::OnClearDevToolsLocalStorage() { |
581 ShellBrowserContext* browser_context = | 579 ShellBrowserContext* browser_context = |
582 ShellContentBrowserClient::Get()->browser_context(); | 580 ShellContentBrowserClient::Get()->browser_context(); |
583 StoragePartition* storage_partition = | 581 StoragePartition* storage_partition = |
584 BrowserContext::GetStoragePartition(browser_context, NULL); | 582 BrowserContext::GetStoragePartition(browser_context, NULL); |
585 storage_partition->GetDOMStorageContext()->DeleteLocalStorage( | 583 storage_partition->GetDOMStorageContext()->DeleteLocalStorage( |
586 content::LayoutTestDevToolsFrontend::GetDevToolsPathAsURL("", "") | 584 content::LayoutTestDevToolsFrontend::GetDevToolsPathAsURL("", "") |
587 .GetOrigin()); | 585 .GetOrigin()); |
588 } | 586 } |
589 | 587 |
590 void WebKitTestController::OnShowDevTools(const std::string& settings, | 588 void BlinkTestController::OnShowDevTools(const std::string& settings, |
591 const std::string& frontend_url) { | 589 const std::string& frontend_url) { |
592 if (!devtools_frontend_) { | 590 if (!devtools_frontend_) { |
593 devtools_frontend_ = LayoutTestDevToolsFrontend::Show( | 591 devtools_frontend_ = LayoutTestDevToolsFrontend::Show( |
594 main_window_->web_contents(), settings, frontend_url); | 592 main_window_->web_contents(), settings, frontend_url); |
595 } else { | 593 } else { |
596 devtools_frontend_->ReuseFrontend(settings, frontend_url); | 594 devtools_frontend_->ReuseFrontend(settings, frontend_url); |
597 } | 595 } |
598 devtools_frontend_->Activate(); | 596 devtools_frontend_->Activate(); |
599 devtools_frontend_->Focus(); | 597 devtools_frontend_->Focus(); |
600 } | 598 } |
601 | 599 |
602 void WebKitTestController::OnCloseDevTools() { | 600 void BlinkTestController::OnCloseDevTools() { |
603 if (devtools_frontend_) | 601 if (devtools_frontend_) |
604 devtools_frontend_->DisconnectFromTarget(); | 602 devtools_frontend_->DisconnectFromTarget(); |
605 } | 603 } |
606 | 604 |
607 void WebKitTestController::OnGoToOffset(int offset) { | 605 void BlinkTestController::OnGoToOffset(int offset) { |
608 main_window_->GoBackOrForward(offset); | 606 main_window_->GoBackOrForward(offset); |
609 } | 607 } |
610 | 608 |
611 void WebKitTestController::OnReload() { | 609 void BlinkTestController::OnReload() { |
612 main_window_->Reload(); | 610 main_window_->Reload(); |
613 } | 611 } |
614 | 612 |
615 void WebKitTestController::OnLoadURLForFrame(const GURL& url, | 613 void BlinkTestController::OnLoadURLForFrame(const GURL& url, |
616 const std::string& frame_name) { | 614 const std::string& frame_name) { |
617 main_window_->LoadURLForFrame(url, frame_name); | 615 main_window_->LoadURLForFrame(url, frame_name); |
618 } | 616 } |
619 | 617 |
620 void WebKitTestController::OnCaptureSessionHistory() { | 618 void BlinkTestController::OnCaptureSessionHistory() { |
621 std::vector<int> routing_ids; | 619 std::vector<int> routing_ids; |
622 std::vector<std::vector<PageState> > session_histories; | 620 std::vector<std::vector<PageState> > session_histories; |
623 std::vector<unsigned> current_entry_indexes; | 621 std::vector<unsigned> current_entry_indexes; |
624 | 622 |
625 RenderViewHost* render_view_host = | 623 RenderViewHost* render_view_host = |
626 main_window_->web_contents()->GetRenderViewHost(); | 624 main_window_->web_contents()->GetRenderViewHost(); |
627 | 625 |
628 for (std::vector<Shell*>::iterator window = Shell::windows().begin(); | 626 for (std::vector<Shell*>::iterator window = Shell::windows().begin(); |
629 window != Shell::windows().end(); | 627 window != Shell::windows().end(); |
630 ++window) { | 628 ++window) { |
(...skipping 21 matching lines...) Expand all Loading... |
652 } | 650 } |
653 session_histories.push_back(history); | 651 session_histories.push_back(history); |
654 } | 652 } |
655 | 653 |
656 Send(new ShellViewMsg_SessionHistory(render_view_host->GetRoutingID(), | 654 Send(new ShellViewMsg_SessionHistory(render_view_host->GetRoutingID(), |
657 routing_ids, | 655 routing_ids, |
658 session_histories, | 656 session_histories, |
659 current_entry_indexes)); | 657 current_entry_indexes)); |
660 } | 658 } |
661 | 659 |
662 void WebKitTestController::OnCloseRemainingWindows() { | 660 void BlinkTestController::OnCloseRemainingWindows() { |
663 DevToolsAgentHost::DetachAllClients(); | 661 DevToolsAgentHost::DetachAllClients(); |
664 std::vector<Shell*> open_windows(Shell::windows()); | 662 std::vector<Shell*> open_windows(Shell::windows()); |
665 Shell* devtools_shell = devtools_frontend_ ? | 663 Shell* devtools_shell = devtools_frontend_ ? |
666 devtools_frontend_->frontend_shell() : NULL; | 664 devtools_frontend_->frontend_shell() : NULL; |
667 for (size_t i = 0; i < open_windows.size(); ++i) { | 665 for (size_t i = 0; i < open_windows.size(); ++i) { |
668 if (open_windows[i] != main_window_ && open_windows[i] != devtools_shell) | 666 if (open_windows[i] != main_window_ && open_windows[i] != devtools_shell) |
669 open_windows[i]->Close(); | 667 open_windows[i]->Close(); |
670 } | 668 } |
671 base::MessageLoop::current()->RunUntilIdle(); | 669 base::MessageLoop::current()->RunUntilIdle(); |
672 } | 670 } |
673 | 671 |
674 void WebKitTestController::OnResetDone() { | 672 void BlinkTestController::OnResetDone() { |
675 if (is_leak_detection_enabled_) { | 673 if (is_leak_detection_enabled_) { |
676 if (main_window_ && main_window_->web_contents()) { | 674 if (main_window_ && main_window_->web_contents()) { |
677 RenderViewHost* render_view_host = | 675 RenderViewHost* render_view_host = |
678 main_window_->web_contents()->GetRenderViewHost(); | 676 main_window_->web_contents()->GetRenderViewHost(); |
679 render_view_host->Send( | 677 render_view_host->Send( |
680 new ShellViewMsg_TryLeakDetection(render_view_host->GetRoutingID())); | 678 new ShellViewMsg_TryLeakDetection(render_view_host->GetRoutingID())); |
681 } | 679 } |
682 return; | 680 return; |
683 } | 681 } |
684 | 682 |
685 base::MessageLoop::current()->PostTask(FROM_HERE, | 683 base::MessageLoop::current()->PostTask(FROM_HERE, |
686 base::MessageLoop::QuitClosure()); | 684 base::MessageLoop::QuitClosure()); |
687 } | 685 } |
688 | 686 |
689 void WebKitTestController::OnLeakDetectionDone( | 687 void BlinkTestController::OnLeakDetectionDone( |
690 const LeakDetectionResult& result) { | 688 const LeakDetectionResult& result) { |
691 if (!result.leaked) { | 689 if (!result.leaked) { |
692 base::MessageLoop::current()->PostTask(FROM_HERE, | 690 base::MessageLoop::current()->PostTask(FROM_HERE, |
693 base::MessageLoop::QuitClosure()); | 691 base::MessageLoop::QuitClosure()); |
694 return; | 692 return; |
695 } | 693 } |
696 | 694 |
697 printer_->AddErrorMessage( | 695 printer_->AddErrorMessage( |
698 base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_, | 696 base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_, |
699 result.detail.c_str())); | 697 result.detail.c_str())); |
700 CHECK(!crash_when_leak_found_); | 698 CHECK(!crash_when_leak_found_); |
701 | 699 |
702 DiscardMainWindow(); | 700 DiscardMainWindow(); |
703 } | 701 } |
704 | 702 |
705 } // namespace content | 703 } // namespace content |
OLD | NEW |