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/webkit_test_runner.h" | 5 #include "content/shell/webkit_test_runner.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/md5.h" | 10 #include "base/md5.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // Only the expected PNGs for Mac have a valid alpha channel. | 148 // Only the expected PNGs for Mac have a valid alpha channel. |
149 MakeBitmapOpaque(snapshot); | 149 MakeBitmapOpaque(snapshot); |
150 #endif | 150 #endif |
151 | 151 |
152 } | 152 } |
153 | 153 |
154 } // namespace | 154 } // namespace |
155 | 155 |
156 WebKitTestRunner::WebKitTestRunner(RenderView* render_view) | 156 WebKitTestRunner::WebKitTestRunner(RenderView* render_view) |
157 : RenderViewObserver(render_view), | 157 : RenderViewObserver(render_view), |
158 dump_editing_callbacks_(false) { | 158 dump_editing_callbacks_(false), |
| 159 dump_frame_load_callbacks_(false), |
| 160 dump_user_gesture_in_frame_load_callbacks_(false), |
| 161 stop_provisional_frame_loads_(false), |
| 162 dump_title_changes_(false), |
| 163 test_is_running_(true), |
| 164 wait_until_done_(false) { |
159 } | 165 } |
160 | 166 |
161 WebKitTestRunner::~WebKitTestRunner() { | 167 WebKitTestRunner::~WebKitTestRunner() { |
162 } | 168 } |
163 | 169 |
164 // WebTestDelegate ----------------------------------------------------------- | 170 // WebTestDelegate ----------------------------------------------------------- |
165 | 171 |
166 void WebKitTestRunner::clearContextMenuData() { | 172 void WebKitTestRunner::clearContextMenuData() { |
167 last_context_menu_data_.reset(); | 173 last_context_menu_data_.reset(); |
168 } | 174 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 render_view()->SetWebkitPreferences(prefs); | 296 render_view()->SetWebkitPreferences(prefs); |
291 Send(new ShellViewHostMsg_OverridePreferences(routing_id(), prefs)); | 297 Send(new ShellViewHostMsg_OverridePreferences(routing_id(), prefs)); |
292 } | 298 } |
293 | 299 |
294 // WebTestRunner ------------------------------------------------------------- | 300 // WebTestRunner ------------------------------------------------------------- |
295 | 301 |
296 bool WebKitTestRunner::shouldDumpEditingCallbacks() const { | 302 bool WebKitTestRunner::shouldDumpEditingCallbacks() const { |
297 return dump_editing_callbacks_; | 303 return dump_editing_callbacks_; |
298 } | 304 } |
299 | 305 |
| 306 bool WebKitTestRunner::shouldDumpFrameLoadCallbacks() const { |
| 307 return test_is_running_ && dump_frame_load_callbacks_; |
| 308 } |
| 309 |
| 310 bool WebKitTestRunner::shouldDumpUserGestureInFrameLoadCallbacks() const { |
| 311 return test_is_running_ && dump_user_gesture_in_frame_load_callbacks_; |
| 312 } |
| 313 |
| 314 bool WebKitTestRunner::stopProvisionalFrameLoads() const { |
| 315 return stop_provisional_frame_loads_; |
| 316 } |
| 317 |
| 318 bool WebKitTestRunner::shouldDumpTitleChanges() const { |
| 319 return dump_title_changes_; |
| 320 } |
| 321 |
300 // RenderViewObserver -------------------------------------------------------- | 322 // RenderViewObserver -------------------------------------------------------- |
301 | 323 |
302 void WebKitTestRunner::DidClearWindowObject(WebFrame* frame) { | 324 void WebKitTestRunner::DidClearWindowObject(WebFrame* frame) { |
303 ShellRenderProcessObserver::GetInstance()->BindTestRunnersToWindow(frame); | 325 ShellRenderProcessObserver::GetInstance()->BindTestRunnersToWindow(frame); |
304 } | 326 } |
305 | 327 |
306 void WebKitTestRunner::DidFinishLoad(WebFrame* frame) { | 328 void WebKitTestRunner::DidFinishLoad(WebFrame* frame) { |
307 if (!frame->parent()) | 329 if (!frame->parent()) { |
| 330 if (!wait_until_done_) |
| 331 test_is_running_ = false; |
308 Send(new ShellViewHostMsg_DidFinishLoad(routing_id())); | 332 Send(new ShellViewHostMsg_DidFinishLoad(routing_id())); |
| 333 } |
309 } | 334 } |
310 | 335 |
311 void WebKitTestRunner::DidRequestShowContextMenu( | 336 void WebKitTestRunner::DidRequestShowContextMenu( |
312 WebFrame* frame, | 337 WebFrame* frame, |
313 const WebContextMenuData& data) { | 338 const WebContextMenuData& data) { |
314 last_context_menu_data_.reset(new WebContextMenuData(data)); | 339 last_context_menu_data_.reset(new WebContextMenuData(data)); |
315 } | 340 } |
316 | 341 |
317 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { | 342 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { |
318 bool handled = true; | 343 bool handled = true; |
(...skipping 17 matching lines...) Expand all Loading... |
336 PaintInvalidatedRegion(); | 361 PaintInvalidatedRegion(); |
337 DisplayRepaintMask(); | 362 DisplayRepaintMask(); |
338 } | 363 } |
339 | 364 |
340 void WebKitTestRunner::SetXSSAuditorEnabled(bool enabled) { | 365 void WebKitTestRunner::SetXSSAuditorEnabled(bool enabled) { |
341 prefs_.XSSAuditorEnabled = enabled; | 366 prefs_.XSSAuditorEnabled = enabled; |
342 applyPreferences(); | 367 applyPreferences(); |
343 } | 368 } |
344 | 369 |
345 void WebKitTestRunner::NotifyDone() { | 370 void WebKitTestRunner::NotifyDone() { |
| 371 test_is_running_ = false; |
346 Send(new ShellViewHostMsg_NotifyDone(routing_id())); | 372 Send(new ShellViewHostMsg_NotifyDone(routing_id())); |
347 } | 373 } |
348 | 374 |
349 void WebKitTestRunner::DumpAsText() { | 375 void WebKitTestRunner::DumpAsText() { |
350 Send(new ShellViewHostMsg_DumpAsText(routing_id())); | 376 Send(new ShellViewHostMsg_DumpAsText(routing_id())); |
351 } | 377 } |
352 | 378 |
353 void WebKitTestRunner::DumpChildFramesAsText() { | 379 void WebKitTestRunner::DumpChildFramesAsText() { |
354 Send(new ShellViewHostMsg_DumpChildFramesAsText(routing_id())); | 380 Send(new ShellViewHostMsg_DumpChildFramesAsText(routing_id())); |
355 } | 381 } |
356 | 382 |
357 void WebKitTestRunner::SetPrinting() { | 383 void WebKitTestRunner::SetPrinting() { |
358 Send(new ShellViewHostMsg_SetPrinting(routing_id())); | 384 Send(new ShellViewHostMsg_SetPrinting(routing_id())); |
359 } | 385 } |
360 | 386 |
361 void WebKitTestRunner::SetShouldStayOnPageAfterHandlingBeforeUnload( | 387 void WebKitTestRunner::SetShouldStayOnPageAfterHandlingBeforeUnload( |
362 bool should_stay_on_page) { | 388 bool should_stay_on_page) { |
363 Send(new ShellViewHostMsg_SetShouldStayOnPageAfterHandlingBeforeUnload( | 389 Send(new ShellViewHostMsg_SetShouldStayOnPageAfterHandlingBeforeUnload( |
364 routing_id(), should_stay_on_page)); | 390 routing_id(), should_stay_on_page)); |
365 } | 391 } |
366 | 392 |
367 void WebKitTestRunner::WaitUntilDone() { | 393 void WebKitTestRunner::WaitUntilDone() { |
| 394 wait_until_done_ = true; |
368 Send(new ShellViewHostMsg_WaitUntilDone(routing_id())); | 395 Send(new ShellViewHostMsg_WaitUntilDone(routing_id())); |
369 } | 396 } |
370 | 397 |
371 void WebKitTestRunner::CanOpenWindows() { | 398 void WebKitTestRunner::CanOpenWindows() { |
372 Send(new ShellViewHostMsg_CanOpenWindows(routing_id())); | 399 Send(new ShellViewHostMsg_CanOpenWindows(routing_id())); |
373 } | 400 } |
374 | 401 |
375 void WebKitTestRunner::ShowWebInspector() { | 402 void WebKitTestRunner::ShowWebInspector() { |
376 Send(new ShellViewHostMsg_ShowWebInspector(routing_id())); | 403 Send(new ShellViewHostMsg_ShowWebInspector(routing_id())); |
377 } | 404 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 std::string message("CONSOLE MESSAGE: Invalid name for preference: "); | 471 std::string message("CONSOLE MESSAGE: Invalid name for preference: "); |
445 printMessage(message + key + "\n"); | 472 printMessage(message + key + "\n"); |
446 } | 473 } |
447 applyPreferences(); | 474 applyPreferences(); |
448 } | 475 } |
449 | 476 |
450 void WebKitTestRunner::DumpEditingCallbacks() { | 477 void WebKitTestRunner::DumpEditingCallbacks() { |
451 dump_editing_callbacks_ = true; | 478 dump_editing_callbacks_ = true; |
452 } | 479 } |
453 | 480 |
| 481 void WebKitTestRunner::DumpFrameLoadCallbacks() { |
| 482 dump_frame_load_callbacks_ = true; |
| 483 } |
| 484 |
| 485 void WebKitTestRunner::DumpUserGestureInFrameLoadCallbacks() { |
| 486 dump_user_gesture_in_frame_load_callbacks_ = true; |
| 487 } |
| 488 |
| 489 void WebKitTestRunner::StopProvisionalFrameLoads() { |
| 490 stop_provisional_frame_loads_ = true; |
| 491 } |
| 492 |
| 493 void WebKitTestRunner::DumpTitleChanges() { |
| 494 dump_title_changes_ = true; |
| 495 } |
| 496 |
454 void WebKitTestRunner::NotImplemented(const std::string& object, | 497 void WebKitTestRunner::NotImplemented(const std::string& object, |
455 const std::string& method) { | 498 const std::string& method) { |
456 Send(new ShellViewHostMsg_NotImplemented(routing_id(), object, method)); | 499 Send(new ShellViewHostMsg_NotImplemented(routing_id(), object, method)); |
457 } | 500 } |
458 | 501 |
459 void WebKitTestRunner::Reset() { | 502 void WebKitTestRunner::Reset() { |
460 prefs_.reset(); | 503 prefs_.reset(); |
461 webkit_glue::WebPreferences prefs = render_view()->GetWebkitPreferences(); | 504 webkit_glue::WebPreferences prefs = render_view()->GetWebkitPreferences(); |
462 ExportLayoutTestSpecificPreferences(prefs_, &prefs); | 505 ExportLayoutTestSpecificPreferences(prefs_, &prefs); |
463 render_view()->SetWebkitPreferences(prefs); | 506 render_view()->SetWebkitPreferences(prefs); |
464 dump_editing_callbacks_ = false; | 507 dump_editing_callbacks_ = false; |
| 508 dump_frame_load_callbacks_ = false; |
| 509 dump_user_gesture_in_frame_load_callbacks_ = false; |
| 510 stop_provisional_frame_loads_ = false; |
| 511 dump_title_changes_ = false; |
| 512 test_is_running_ = true; |
| 513 wait_until_done_ = false; |
465 } | 514 } |
466 | 515 |
467 // Private methods ----------------------------------------------------------- | 516 // Private methods ----------------------------------------------------------- |
468 | 517 |
469 void WebKitTestRunner::OnCaptureTextDump(bool as_text, | 518 void WebKitTestRunner::OnCaptureTextDump(bool as_text, |
470 bool printing, | 519 bool printing, |
471 bool recursive) { | 520 bool recursive) { |
472 WebFrame* frame = render_view()->GetWebView()->mainFrame(); | 521 WebFrame* frame = render_view()->GetWebView()->mainFrame(); |
473 std::string dump; | 522 std::string dump; |
474 if (as_text) { | 523 if (as_text) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 PaintRect(rect); | 633 PaintRect(rect); |
585 } | 634 } |
586 CHECK(proxy_->paintRect().isEmpty()); | 635 CHECK(proxy_->paintRect().isEmpty()); |
587 } | 636 } |
588 | 637 |
589 void WebKitTestRunner::DisplayRepaintMask() { | 638 void WebKitTestRunner::DisplayRepaintMask() { |
590 GetCanvas()->drawARGB(167, 0, 0, 0); | 639 GetCanvas()->drawARGB(167, 0, 0, 0); |
591 } | 640 } |
592 | 641 |
593 } // namespace content | 642 } // namespace content |
OLD | NEW |