Index: components/test_runner/web_frame_test_client.cc |
diff --git a/components/test_runner/web_frame_test_client.cc b/components/test_runner/web_frame_test_client.cc |
index 97f704b78286454d468959a2c408ef7bdb215eca..e45a167b3c7440172386471244f1b6a0e1205988 100644 |
--- a/components/test_runner/web_frame_test_client.cc |
+++ b/components/test_runner/web_frame_test_client.cc |
@@ -166,15 +166,12 @@ const char* WebNavigationTypeToString(blink::WebNavigationType type) { |
WebFrameTestClient::WebFrameTestClient( |
TestRunner* test_runner, |
- WebTestDelegate* delegate, |
WebViewTestProxyBase* web_view_test_proxy_base, |
WebFrameTestProxyBase* web_frame_test_proxy_base) |
: test_runner_(test_runner), |
- delegate_(delegate), |
web_view_test_proxy_base_(web_view_test_proxy_base), |
web_frame_test_proxy_base_(web_frame_test_proxy_base) { |
DCHECK(test_runner); |
- DCHECK(delegate_); |
DCHECK(web_view_test_proxy_base_); |
} |
@@ -185,18 +182,18 @@ blink::WebColorChooser* WebFrameTestClient::createColorChooser( |
const blink::WebColor& color, |
const blink::WebVector<blink::WebColorSuggestion>& suggestions) { |
// This instance is deleted by WebCore::ColorInputType |
- return new MockColorChooser(client, delegate_, test_runner_); |
+ return new MockColorChooser(client, delegate(), test_runner_); |
} |
void WebFrameTestClient::runModalAlertDialog(const blink::WebString& message) { |
- delegate_->PrintMessage(std::string("ALERT: ") + message.utf8().data() + |
- "\n"); |
+ delegate()->PrintMessage(std::string("ALERT: ") + message.utf8().data() + |
+ "\n"); |
} |
bool WebFrameTestClient::runModalConfirmDialog( |
const blink::WebString& message) { |
- delegate_->PrintMessage(std::string("CONFIRM: ") + message.utf8().data() + |
- "\n"); |
+ delegate()->PrintMessage(std::string("CONFIRM: ") + message.utf8().data() + |
+ "\n"); |
return true; |
} |
@@ -204,14 +201,14 @@ bool WebFrameTestClient::runModalPromptDialog( |
const blink::WebString& message, |
const blink::WebString& default_value, |
blink::WebString* actual_value) { |
- delegate_->PrintMessage(std::string("PROMPT: ") + message.utf8().data() + |
- ", default text: " + default_value.utf8().data() + |
- "\n"); |
+ delegate()->PrintMessage(std::string("PROMPT: ") + message.utf8().data() + |
+ ", default text: " + default_value.utf8().data() + |
+ "\n"); |
return true; |
} |
bool WebFrameTestClient::runModalBeforeUnloadDialog(bool is_reload) { |
- delegate_->PrintMessage(std::string("CONFIRM NAVIGATION\n")); |
+ delegate()->PrintMessage(std::string("CONFIRM NAVIGATION\n")); |
return !test_runner_->shouldStayOnPageAfterHandlingBeforeUnload(); |
} |
@@ -350,13 +347,13 @@ void WebFrameTestClient::postAccessibilityEvent(const blink::WebAXObject& obj, |
} |
} |
- delegate_->PrintMessage(message + "\n"); |
+ delegate()->PrintMessage(message + "\n"); |
} |
} |
void WebFrameTestClient::didChangeSelection(bool is_empty_callback) { |
if (test_runner_->shouldDumpEditingCallbacks()) |
- delegate_->PrintMessage( |
+ delegate()->PrintMessage( |
"EDITING DELEGATE: " |
"webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n"); |
} |
@@ -365,8 +362,8 @@ blink::WebPlugin* WebFrameTestClient::createPlugin( |
blink::WebLocalFrame* frame, |
const blink::WebPluginParams& params) { |
if (TestPlugin::IsSupportedMimeType(params.mimeType)) |
- return TestPlugin::create(frame, params, delegate_); |
- return delegate_->CreatePluginPlaceholder(frame, params); |
+ return TestPlugin::create(frame, params, delegate()); |
+ return delegate()->CreatePluginPlaceholder(frame, params); |
} |
void WebFrameTestClient::showContextMenu( |
@@ -386,14 +383,14 @@ void WebFrameTestClient::loadURLExternally( |
bool replaces_current_history_item) { |
if (test_runner_->shouldWaitUntilExternalURLLoad()) { |
if (policy == blink::WebNavigationPolicyDownload) { |
- delegate_->PrintMessage( |
+ delegate()->PrintMessage( |
std::string("Downloading URL with suggested filename \"") + |
suggested_name.utf8() + "\"\n"); |
} else { |
- delegate_->PrintMessage(std::string("Loading URL externally - \"") + |
- URLDescription(request.url()) + "\"\n"); |
+ delegate()->PrintMessage(std::string("Loading URL externally - \"") + |
+ URLDescription(request.url()) + "\"\n"); |
} |
- delegate_->TestFinished(); |
+ delegate()->TestFinished(); |
} |
} |
@@ -402,12 +399,12 @@ void WebFrameTestClient::didStartProvisionalLoad(blink::WebLocalFrame* frame, |
test_runner_->tryToSetTopLoadingFrame(frame); |
if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
- PrintFrameDescription(delegate_, frame); |
- delegate_->PrintMessage(" - didStartProvisionalLoadForFrame\n"); |
+ PrintFrameDescription(delegate(), frame); |
+ delegate()->PrintMessage(" - didStartProvisionalLoadForFrame\n"); |
} |
if (test_runner_->shouldDumpUserGestureInFrameLoadCallbacks()) { |
- PrintFrameuserGestureStatus(delegate_, frame, |
+ PrintFrameuserGestureStatus(delegate(), frame, |
" - in didStartProvisionalLoadForFrame\n"); |
} |
} |
@@ -415,8 +412,8 @@ void WebFrameTestClient::didStartProvisionalLoad(blink::WebLocalFrame* frame, |
void WebFrameTestClient::didReceiveServerRedirectForProvisionalLoad( |
blink::WebLocalFrame* frame) { |
if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
- PrintFrameDescription(delegate_, frame); |
- delegate_->PrintMessage( |
+ PrintFrameDescription(delegate(), frame); |
+ delegate()->PrintMessage( |
" - didReceiveServerRedirectForProvisionalLoadForFrame\n"); |
} |
} |
@@ -426,8 +423,8 @@ void WebFrameTestClient::didFailProvisionalLoad( |
const blink::WebURLError& error, |
blink::WebHistoryCommitType commit_type) { |
if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
- PrintFrameDescription(delegate_, frame); |
- delegate_->PrintMessage(" - didFailProvisionalLoadWithError\n"); |
+ PrintFrameDescription(delegate(), frame); |
+ delegate()->PrintMessage(" - didFailProvisionalLoadWithError\n"); |
} |
} |
@@ -436,8 +433,8 @@ void WebFrameTestClient::didCommitProvisionalLoad( |
const blink::WebHistoryItem& history_item, |
blink::WebHistoryCommitType history_type) { |
if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
- PrintFrameDescription(delegate_, frame); |
- delegate_->PrintMessage(" - didCommitLoadForFrame\n"); |
+ PrintFrameDescription(delegate(), frame); |
+ delegate()->PrintMessage(" - didCommitLoadForFrame\n"); |
} |
} |
@@ -445,35 +442,35 @@ void WebFrameTestClient::didReceiveTitle(blink::WebLocalFrame* frame, |
const blink::WebString& title, |
blink::WebTextDirection direction) { |
if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
- PrintFrameDescription(delegate_, frame); |
- delegate_->PrintMessage(std::string(" - didReceiveTitle: ") + title.utf8() + |
- "\n"); |
+ PrintFrameDescription(delegate(), frame); |
+ delegate()->PrintMessage(std::string(" - didReceiveTitle: ") + |
+ title.utf8() + "\n"); |
} |
if (test_runner_->shouldDumpTitleChanges()) |
- delegate_->PrintMessage(std::string("TITLE CHANGED: '") + title.utf8() + |
- "'\n"); |
+ delegate()->PrintMessage(std::string("TITLE CHANGED: '") + title.utf8() + |
+ "'\n"); |
} |
void WebFrameTestClient::didChangeIcon(blink::WebLocalFrame* frame, |
blink::WebIconURL::Type icon_type) { |
if (test_runner_->shouldDumpIconChanges()) { |
- PrintFrameDescription(delegate_, frame); |
- delegate_->PrintMessage(std::string(" - didChangeIcons\n")); |
+ PrintFrameDescription(delegate(), frame); |
+ delegate()->PrintMessage(std::string(" - didChangeIcons\n")); |
} |
} |
void WebFrameTestClient::didFinishDocumentLoad(blink::WebLocalFrame* frame) { |
if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
- PrintFrameDescription(delegate_, frame); |
- delegate_->PrintMessage(" - didFinishDocumentLoadForFrame\n"); |
+ PrintFrameDescription(delegate(), frame); |
+ delegate()->PrintMessage(" - didFinishDocumentLoadForFrame\n"); |
} |
} |
void WebFrameTestClient::didHandleOnloadEvents(blink::WebLocalFrame* frame) { |
if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
- PrintFrameDescription(delegate_, frame); |
- delegate_->PrintMessage(" - didHandleOnloadEventsForFrame\n"); |
+ PrintFrameDescription(delegate(), frame); |
+ delegate()->PrintMessage(" - didHandleOnloadEventsForFrame\n"); |
} |
} |
@@ -481,15 +478,15 @@ void WebFrameTestClient::didFailLoad(blink::WebLocalFrame* frame, |
const blink::WebURLError& error, |
blink::WebHistoryCommitType commit_type) { |
if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
- PrintFrameDescription(delegate_, frame); |
- delegate_->PrintMessage(" - didFailLoadWithError\n"); |
+ PrintFrameDescription(delegate(), frame); |
+ delegate()->PrintMessage(" - didFailLoadWithError\n"); |
} |
} |
void WebFrameTestClient::didFinishLoad(blink::WebLocalFrame* frame) { |
if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
- PrintFrameDescription(delegate_, frame); |
- delegate_->PrintMessage(" - didFinishLoadForFrame\n"); |
+ PrintFrameDescription(delegate(), frame); |
+ delegate()->PrintMessage(" - didFinishLoadForFrame\n"); |
} |
} |
@@ -513,13 +510,13 @@ void WebFrameTestClient::didStopLoading() { |
void WebFrameTestClient::didDetectXSS(const blink::WebURL& insecure_url, |
bool did_block_entire_page) { |
if (test_runner_->shouldDumpFrameLoadCallbacks()) |
- delegate_->PrintMessage("didDetectXSS\n"); |
+ delegate()->PrintMessage("didDetectXSS\n"); |
} |
void WebFrameTestClient::didDispatchPingLoader(const blink::WebURL& url) { |
if (test_runner_->shouldDumpPingLoaderCallbacks()) |
- delegate_->PrintMessage(std::string("PingLoader dispatched to '") + |
- URLDescription(url).c_str() + "'.\n"); |
+ delegate()->PrintMessage(std::string("PingLoader dispatched to '") + |
+ URLDescription(url).c_str() + "'.\n"); |
} |
void WebFrameTestClient::willSendRequest(blink::WebLocalFrame* frame, |
@@ -531,15 +528,15 @@ void WebFrameTestClient::willSendRequest(blink::WebLocalFrame* frame, |
GURL main_document_url = request.firstPartyForCookies(); |
if (test_runner_->shouldDumpResourceLoadCallbacks()) { |
- delegate_->PrintMessage(DescriptionSuitableForTestResult(request_url)); |
- delegate_->PrintMessage(" - willSendRequest <NSURLRequest URL "); |
- delegate_->PrintMessage( |
+ delegate()->PrintMessage(DescriptionSuitableForTestResult(request_url)); |
+ delegate()->PrintMessage(" - willSendRequest <NSURLRequest URL "); |
+ delegate()->PrintMessage( |
DescriptionSuitableForTestResult(request_url).c_str()); |
- delegate_->PrintMessage(", main document URL "); |
- delegate_->PrintMessage(URLDescription(main_document_url).c_str()); |
- delegate_->PrintMessage(", http method "); |
- delegate_->PrintMessage(request.httpMethod().utf8().data()); |
- delegate_->PrintMessage(">\n"); |
+ delegate()->PrintMessage(", main document URL "); |
+ delegate()->PrintMessage(URLDescription(main_document_url).c_str()); |
+ delegate()->PrintMessage(", http method "); |
+ delegate()->PrintMessage(request.httpMethod().utf8().data()); |
+ delegate()->PrintMessage(">\n"); |
} |
if (test_runner_->httpHeadersToClear()) { |
@@ -558,16 +555,16 @@ void WebFrameTestClient::willSendRequest(blink::WebLocalFrame* frame, |
((!main_document_url.SchemeIs(url::kHttpScheme) && |
!main_document_url.SchemeIs(url::kHttpsScheme)) || |
IsLocalHost(main_document_url.host())) && |
- !delegate_->AllowExternalPages()) { |
- delegate_->PrintMessage(std::string("Blocked access to external URL ") + |
- request_url + "\n"); |
+ !delegate()->AllowExternalPages()) { |
+ delegate()->PrintMessage(std::string("Blocked access to external URL ") + |
+ request_url + "\n"); |
BlockRequest(request); |
return; |
} |
} |
// Set the new substituted URL. |
- request.setURL(delegate_->RewriteLayoutTestsURL( |
+ request.setURL(delegate()->RewriteLayoutTestsURL( |
request.url().string().utf8(), |
test_runner_->is_web_platform_tests_mode())); |
} |
@@ -575,22 +572,22 @@ void WebFrameTestClient::willSendRequest(blink::WebLocalFrame* frame, |
void WebFrameTestClient::didReceiveResponse( |
const blink::WebURLResponse& response) { |
if (test_runner_->shouldDumpResourceLoadCallbacks()) { |
- delegate_->PrintMessage(DescriptionSuitableForTestResult( |
+ delegate()->PrintMessage(DescriptionSuitableForTestResult( |
GURL(response.url()).possibly_invalid_spec())); |
- delegate_->PrintMessage(" - didReceiveResponse "); |
- PrintResponseDescription(delegate_, response); |
- delegate_->PrintMessage("\n"); |
+ delegate()->PrintMessage(" - didReceiveResponse "); |
+ PrintResponseDescription(delegate(), response); |
+ delegate()->PrintMessage("\n"); |
} |
if (test_runner_->shouldDumpResourceResponseMIMETypes()) { |
GURL url = response.url(); |
blink::WebString mime_type = response.mimeType(); |
- delegate_->PrintMessage(url.ExtractFileName()); |
- delegate_->PrintMessage(" has MIME type "); |
+ delegate()->PrintMessage(url.ExtractFileName()); |
+ delegate()->PrintMessage(" has MIME type "); |
// Simulate NSURLResponse's mapping of empty/unknown MIME types to |
// application/octet-stream |
- delegate_->PrintMessage(mime_type.isEmpty() ? "application/octet-stream" |
- : mime_type.utf8().data()); |
- delegate_->PrintMessage("\n"); |
+ delegate()->PrintMessage(mime_type.isEmpty() ? "application/octet-stream" |
+ : mime_type.utf8().data()); |
+ delegate()->PrintMessage("\n"); |
} |
} |
@@ -621,9 +618,9 @@ void WebFrameTestClient::didAddMessageToConsole( |
default: |
level = "MESSAGE"; |
} |
- delegate_->PrintMessage(std::string("CONSOLE ") + level + ": "); |
+ delegate()->PrintMessage(std::string("CONSOLE ") + level + ": "); |
if (source_line) { |
- delegate_->PrintMessage(base::StringPrintf("line %d: ", source_line)); |
+ delegate()->PrintMessage(base::StringPrintf("line %d: ", source_line)); |
} |
if (!message.text.isEmpty()) { |
std::string new_message; |
@@ -633,25 +630,25 @@ void WebFrameTestClient::didAddMessageToConsole( |
new_message = new_message.substr(0, file_protocol) + |
URLSuitableForTestResult(new_message.substr(file_protocol)); |
} |
- delegate_->PrintMessage(new_message); |
+ delegate()->PrintMessage(new_message); |
} |
- delegate_->PrintMessage(std::string("\n")); |
+ delegate()->PrintMessage(std::string("\n")); |
} |
blink::WebNavigationPolicy WebFrameTestClient::decidePolicyForNavigation( |
const blink::WebFrameClient::NavigationPolicyInfo& info) { |
if (test_runner_->shouldDumpNavigationPolicy()) { |
- delegate_->PrintMessage("Default policy for navigation to '" + |
- URLDescription(info.urlRequest.url()) + "' is '" + |
- WebNavigationPolicyToString(info.defaultPolicy) + |
- "'\n"); |
+ delegate()->PrintMessage("Default policy for navigation to '" + |
+ URLDescription(info.urlRequest.url()) + "' is '" + |
+ WebNavigationPolicyToString(info.defaultPolicy) + |
+ "'\n"); |
} |
blink::WebNavigationPolicy result; |
if (!test_runner_->policyDelegateEnabled()) |
return info.defaultPolicy; |
- delegate_->PrintMessage( |
+ delegate()->PrintMessage( |
std::string("Policy delegate: attempt to load ") + |
URLDescription(info.urlRequest.url()) + " with navigation type '" + |
WebNavigationTypeToString(info.navigationType) + "'\n"); |
@@ -690,9 +687,13 @@ void WebFrameTestClient::didClearWindowObject(blink::WebLocalFrame* frame) { |
bool WebFrameTestClient::runFileChooser( |
const blink::WebFileChooserParams& params, |
blink::WebFileChooserCompletion* completion) { |
- delegate_->PrintMessage("Mock: Opening a file chooser.\n"); |
+ delegate()->PrintMessage("Mock: Opening a file chooser.\n"); |
// FIXME: Add ability to set file names to a file upload control. |
return false; |
} |
+WebTestDelegate* WebFrameTestClient::delegate() { |
+ return web_view_test_proxy_base_->delegate(); |
+} |
+ |
} // namespace test_runner |