Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: content/shell/webkit_test_runner.cc

Issue 13795002: [content shell] add support for invoking testRunner.notifyDone in a different process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/shell/webkit_test_runner.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 #include <clocale> 8 #include <clocale>
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 29 matching lines...) Expand all
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebArrayBufferView.h" 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebArrayBufferView.h"
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h"
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDeviceOrientation. h" 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDeviceOrientation. h"
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" 48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h" 51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h"
51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
52 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web Task.h" 53 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web Task.h"
53 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestInterfaces.h" 54 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestInterfaces.h"
54 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestProxy.h" 55 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestProxy.h"
55 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestRunner.h" 56 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestRunner.h"
56 #include "ui/gfx/rect.h" 57 #include "ui/gfx/rect.h"
57 #include "webkit/base/file_path_string_conversions.h" 58 #include "webkit/base/file_path_string_conversions.h"
58 #include "webkit/glue/glue_serialize.h" 59 #include "webkit/glue/glue_serialize.h"
59 #include "webkit/glue/webkit_glue.h" 60 #include "webkit/glue/webkit_glue.h"
60 #include "webkit/glue/webpreferences.h" 61 #include "webkit/glue/webpreferences.h"
61 #include "webkit/mocks/test_media_stream_client.h" 62 #include "webkit/mocks/test_media_stream_client.h"
62 63
63 using WebKit::Platform; 64 using WebKit::Platform;
64 using WebKit::WebArrayBufferView; 65 using WebKit::WebArrayBufferView;
65 using WebKit::WebContextMenuData; 66 using WebKit::WebContextMenuData;
66 using WebKit::WebDevToolsAgent; 67 using WebKit::WebDevToolsAgent;
67 using WebKit::WebDeviceOrientation; 68 using WebKit::WebDeviceOrientation;
68 using WebKit::WebElement; 69 using WebKit::WebElement;
69 using WebKit::WebFrame; 70 using WebKit::WebFrame;
70 using WebKit::WebGamepads; 71 using WebKit::WebGamepads;
71 using WebKit::WebHistoryItem; 72 using WebKit::WebHistoryItem;
72 using WebKit::WebMediaPlayer; 73 using WebKit::WebMediaPlayer;
73 using WebKit::WebMediaPlayerClient; 74 using WebKit::WebMediaPlayerClient;
74 using WebKit::WebPoint; 75 using WebKit::WebPoint;
75 using WebKit::WebRect; 76 using WebKit::WebRect;
77 using WebKit::WebScriptSource;
76 using WebKit::WebSize; 78 using WebKit::WebSize;
77 using WebKit::WebString; 79 using WebKit::WebString;
78 using WebKit::WebURL; 80 using WebKit::WebURL;
79 using WebKit::WebURLError; 81 using WebKit::WebURLError;
80 using WebKit::WebURLRequest; 82 using WebKit::WebURLRequest;
81 using WebKit::WebTestingSupport; 83 using WebKit::WebTestingSupport;
82 using WebKit::WebVector; 84 using WebKit::WebVector;
83 using WebKit::WebView; 85 using WebKit::WebView;
84 using WebTestRunner::WebPreferences; 86 using WebTestRunner::WebPreferences;
85 using WebTestRunner::WebTask; 87 using WebTestRunner::WebTask;
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 result.substr(strlen("file:////")); 400 result.substr(strlen("file:////"));
399 } 401 }
400 return rewriteLayoutTestsURL(result).spec(); 402 return rewriteLayoutTestsURL(result).spec();
401 } 403 }
402 404
403 void WebKitTestRunner::setLocale(const std::string& locale) { 405 void WebKitTestRunner::setLocale(const std::string& locale) {
404 setlocale(LC_ALL, locale.c_str()); 406 setlocale(LC_ALL, locale.c_str());
405 } 407 }
406 408
407 void WebKitTestRunner::testFinished() { 409 void WebKitTestRunner::testFinished() {
408 if (!is_main_window_) 410 if (!is_main_window_) {
411 Send(new ShellViewHostMsg_TestFinishedInSecondaryWindow(routing_id()));
409 return; 412 return;
413 }
410 WebTestInterfaces* interfaces = 414 WebTestInterfaces* interfaces =
411 ShellRenderProcessObserver::GetInstance()->test_interfaces(); 415 ShellRenderProcessObserver::GetInstance()->test_interfaces();
412 interfaces->setTestIsRunning(false); 416 interfaces->setTestIsRunning(false);
413 if (interfaces->testRunner()->shouldDumpBackForwardList()) { 417 if (interfaces->testRunner()->shouldDumpBackForwardList()) {
414 SyncNavigationStateVisitor visitor; 418 SyncNavigationStateVisitor visitor;
415 RenderView::ForEach(&visitor); 419 RenderView::ForEach(&visitor);
416 Send(new ShellViewHostMsg_CaptureSessionHistory(routing_id())); 420 Send(new ShellViewHostMsg_CaptureSessionHistory(routing_id()));
417 } else { 421 } else {
418 CaptureDump(); 422 CaptureDump();
419 } 423 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 ShellRenderProcessObserver::GetInstance()->test_interfaces()->bindTo(frame); 514 ShellRenderProcessObserver::GetInstance()->test_interfaces()->bindTo(frame);
511 } 515 }
512 516
513 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { 517 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) {
514 bool handled = true; 518 bool handled = true;
515 IPC_BEGIN_MESSAGE_MAP(WebKitTestRunner, message) 519 IPC_BEGIN_MESSAGE_MAP(WebKitTestRunner, message)
516 IPC_MESSAGE_HANDLER(ShellViewMsg_SetTestConfiguration, 520 IPC_MESSAGE_HANDLER(ShellViewMsg_SetTestConfiguration,
517 OnSetTestConfiguration) 521 OnSetTestConfiguration)
518 IPC_MESSAGE_HANDLER(ShellViewMsg_SessionHistory, OnSessionHistory) 522 IPC_MESSAGE_HANDLER(ShellViewMsg_SessionHistory, OnSessionHistory)
519 IPC_MESSAGE_HANDLER(ShellViewMsg_Reset, OnReset) 523 IPC_MESSAGE_HANDLER(ShellViewMsg_Reset, OnReset)
524 IPC_MESSAGE_HANDLER(ShellViewMsg_NotifyDone, OnNotifyDone)
520 IPC_MESSAGE_UNHANDLED(handled = false) 525 IPC_MESSAGE_UNHANDLED(handled = false)
521 IPC_END_MESSAGE_MAP() 526 IPC_END_MESSAGE_MAP()
522 527
523 return handled; 528 return handled;
524 } 529 }
525 530
526 void WebKitTestRunner::Navigate(const GURL& url) { 531 void WebKitTestRunner::Navigate(const GURL& url) {
527 focus_on_next_commit_ = true; 532 focus_on_next_commit_ = true;
533 if (!is_main_window_ &&
534 ShellRenderProcessObserver::GetInstance()->main_test_runner() == this) {
535 WebTestInterfaces* interfaces =
536 ShellRenderProcessObserver::GetInstance()->test_interfaces();
537 interfaces->setTestIsRunning(true);
538 interfaces->configureForTestWithURL(GURL(), false);
539 }
528 } 540 }
529 541
530 void WebKitTestRunner::DidCommitProvisionalLoad(WebFrame* frame, 542 void WebKitTestRunner::DidCommitProvisionalLoad(WebFrame* frame,
531 bool is_new_navigation) { 543 bool is_new_navigation) {
532 if (!focus_on_next_commit_) 544 if (!focus_on_next_commit_)
533 return; 545 return;
534 focus_on_next_commit_ = false; 546 focus_on_next_commit_ = false;
535 render_view()->GetWebView()->setFocusedFrame(frame); 547 render_view()->GetWebView()->setFocusedFrame(frame);
536 } 548 }
537 549
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 void WebKitTestRunner::OnReset() { 666 void WebKitTestRunner::OnReset() {
655 ShellRenderProcessObserver::GetInstance()->test_interfaces()->resetAll(); 667 ShellRenderProcessObserver::GetInstance()->test_interfaces()->resetAll();
656 Reset(); 668 Reset();
657 // Navigating to about:blank will make sure that no new loads are initiated 669 // Navigating to about:blank will make sure that no new loads are initiated
658 // by the renderer. 670 // by the renderer.
659 render_view()->GetWebView()->mainFrame() 671 render_view()->GetWebView()->mainFrame()
660 ->loadRequest(WebURLRequest(GURL("about:blank"))); 672 ->loadRequest(WebURLRequest(GURL("about:blank")));
661 Send(new ShellViewHostMsg_ResetDone(routing_id())); 673 Send(new ShellViewHostMsg_ResetDone(routing_id()));
662 } 674 }
663 675
676 void WebKitTestRunner::OnNotifyDone() {
677 render_view()->GetWebView()->mainFrame()->executeScript(
678 WebScriptSource(WebString::fromUTF8("testRunner.notifyDone();")));
679 }
680
664 } // namespace content 681 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/webkit_test_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698