Index: content/shell/renderer/test_runner/web_test_proxy.cc |
diff --git a/content/shell/renderer/test_runner/WebTestProxy.cpp b/content/shell/renderer/test_runner/web_test_proxy.cc |
similarity index 17% |
rename from content/shell/renderer/test_runner/WebTestProxy.cpp |
rename to content/shell/renderer/test_runner/web_test_proxy.cc |
index 1cc010328583596ab4d09925fbefe3fc2312f8b1..0cd7af7f92e137e0e009eb89c2a568e83577a26e 100644 |
--- a/content/shell/renderer/test_runner/WebTestProxy.cpp |
+++ b/content/shell/renderer/test_runner/web_test_proxy.cc |
@@ -2,14 +2,13 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "content/shell/renderer/test_runner/WebTestProxy.h" |
+#include "content/shell/renderer/test_runner/web_test_proxy.h" |
#include <cctype> |
#include "base/callback_helpers.h" |
#include "base/debug/trace_event.h" |
#include "base/logging.h" |
-#include "content/shell/renderer/test_runner/event_sender.h" |
#include "content/shell/renderer/test_runner/MockColorChooser.h" |
#include "content/shell/renderer/test_runner/MockWebSpeechRecognizer.h" |
#include "content/shell/renderer/test_runner/SpellCheckClient.h" |
@@ -21,6 +20,7 @@ |
#include "content/shell/renderer/test_runner/WebTestRunner.h" |
#include "content/shell/renderer/test_runner/WebUserMediaClientMock.h" |
#include "content/shell/renderer/test_runner/accessibility_controller.h" |
+#include "content/shell/renderer/test_runner/event_sender.h" |
#include "content/shell/renderer/test_runner/test_runner.h" |
// FIXME: Including platform_canvas.h here is a layering violation. |
#include "skia/ext/platform_canvas.h" |
@@ -53,135 +53,122 @@ namespace content { |
namespace { |
class HostMethodTask : public WebMethodTask<WebTestProxyBase> { |
-public: |
- typedef void (WebTestProxyBase::*CallbackMethodType)(); |
- HostMethodTask(WebTestProxyBase* object, CallbackMethodType callback) |
- : WebMethodTask<WebTestProxyBase>(object) |
- , m_callback(callback) |
- { } |
+ public: |
+ typedef void (WebTestProxyBase::*CallbackMethodType)(); |
+ HostMethodTask(WebTestProxyBase* object, CallbackMethodType callback) |
+ : WebMethodTask<WebTestProxyBase>(object), m_callback(callback) {} |
- virtual void runIfValid() OVERRIDE { (m_object->*m_callback)(); } |
+ virtual void runIfValid() OVERRIDE { (m_object->*m_callback)(); } |
-private: |
- CallbackMethodType m_callback; |
+ private: |
+ CallbackMethodType m_callback; |
}; |
-void printFrameDescription(WebTestDelegate* delegate, WebFrame* frame) |
-{ |
- string name8 = frame->uniqueName().utf8(); |
- if (frame == frame->view()->mainFrame()) { |
- if (!name8.length()) { |
- delegate->printMessage("main frame"); |
- return; |
- } |
- delegate->printMessage(string("main frame \"") + name8 + "\""); |
- return; |
- } |
+void printFrameDescription(WebTestDelegate* delegate, WebFrame* frame) { |
+ string name8 = frame->uniqueName().utf8(); |
+ if (frame == frame->view()->mainFrame()) { |
if (!name8.length()) { |
- delegate->printMessage("frame (anonymous)"); |
- return; |
+ delegate->printMessage("main frame"); |
+ return; |
} |
- delegate->printMessage(string("frame \"") + name8 + "\""); |
+ delegate->printMessage(string("main frame \"") + name8 + "\""); |
+ return; |
+ } |
+ if (!name8.length()) { |
+ delegate->printMessage("frame (anonymous)"); |
+ return; |
+ } |
+ delegate->printMessage(string("frame \"") + name8 + "\""); |
} |
-void printFrameUserGestureStatus(WebTestDelegate* delegate, WebFrame* frame, const char* msg) |
-{ |
- bool isUserGesture = WebUserGestureIndicator::isProcessingUserGesture(); |
- delegate->printMessage(string("Frame with user gesture \"") + (isUserGesture ? "true" : "false") + "\"" + msg); |
+void printFrameUserGestureStatus(WebTestDelegate* delegate, WebFrame* frame, |
+ const char* msg) { |
+ bool isUserGesture = WebUserGestureIndicator::isProcessingUserGesture(); |
+ delegate->printMessage(string("Frame with user gesture \"") + |
+ (isUserGesture ? "true" : "false") + "\"" + msg); |
} |
// Used to write a platform neutral file:/// URL by taking the |
// filename and its directory. (e.g., converts |
// "file:///tmp/foo/bar.txt" to just "bar.txt"). |
-string descriptionSuitableForTestResult(const string& url) |
-{ |
- if (url.empty() || string::npos == url.find("file://")) |
- return url; |
- |
- size_t pos = url.rfind('/'); |
- if (pos == string::npos || !pos) |
- return "ERROR:" + url; |
- pos = url.rfind('/', pos - 1); |
- if (pos == string::npos) |
- return "ERROR:" + url; |
- |
- return url.substr(pos + 1); |
-} |
- |
-void printResponseDescription(WebTestDelegate* delegate, const WebURLResponse& response) |
-{ |
- if (response.isNull()) { |
- delegate->printMessage("(null)"); |
- return; |
- } |
- string url = response.url().spec(); |
- char data[100]; |
- snprintf(data, sizeof(data), "%d", response. httpStatusCode()); |
- delegate->printMessage(string("<NSURLResponse ") + descriptionSuitableForTestResult(url) + ", http status code " + data + ">"); |
+string descriptionSuitableForTestResult(const string& url) { |
+ if (url.empty() || string::npos == url.find("file://")) return url; |
+ |
+ size_t pos = url.rfind('/'); |
+ if (pos == string::npos || !pos) return "ERROR:" + url; |
+ pos = url.rfind('/', pos - 1); |
+ if (pos == string::npos) return "ERROR:" + url; |
+ |
+ return url.substr(pos + 1); |
} |
-string URLDescription(const GURL& url) |
-{ |
- if (url.SchemeIs("file")) |
- return url.ExtractFileName(); |
- return url.possibly_invalid_spec(); |
+void printResponseDescription(WebTestDelegate* delegate, |
+ const WebURLResponse& response) { |
+ if (response.isNull()) { |
+ delegate->printMessage("(null)"); |
+ return; |
+ } |
+ string url = response.url().spec(); |
+ char data[100]; |
+ snprintf(data, sizeof(data), "%d", response.httpStatusCode()); |
+ delegate->printMessage(string("<NSURLResponse ") + |
+ descriptionSuitableForTestResult(url) + |
+ ", http status code " + data + ">"); |
} |
-string PriorityDescription(const WebURLRequest::Priority& priority) |
-{ |
- switch (priority) { |
+string URLDescription(const GURL& url) { |
+ if (url.SchemeIs("file")) return url.ExtractFileName(); |
+ return url.possibly_invalid_spec(); |
+} |
+ |
+string PriorityDescription(const WebURLRequest::Priority& priority) { |
+ switch (priority) { |
case WebURLRequest::PriorityVeryLow: |
- return "VeryLow"; |
+ return "VeryLow"; |
case WebURLRequest::PriorityLow: |
- return "Low"; |
+ return "Low"; |
case WebURLRequest::PriorityMedium: |
- return "Medium"; |
+ return "Medium"; |
case WebURLRequest::PriorityHigh: |
- return "High"; |
+ return "High"; |
case WebURLRequest::PriorityVeryHigh: |
- return "VeryHigh"; |
+ return "VeryHigh"; |
case WebURLRequest::PriorityUnresolved: |
default: |
- return "Unresolved"; |
- } |
+ return "Unresolved"; |
+ } |
} |
-void blockRequest(WebURLRequest& request) |
-{ |
- request.setURL(GURL("255.255.255.255")); |
+void blockRequest(WebURLRequest& request) { |
+ request.setURL(GURL("255.255.255.255")); |
} |
-bool isLocalhost(const string& host) |
-{ |
- return host == "127.0.0.1" || host == "localhost"; |
+bool isLocalhost(const string& host) { |
+ return host == "127.0.0.1" || host == "localhost"; |
} |
-bool hostIsUsedBySomeTestsToGenerateError(const string& host) |
-{ |
- return host == "255.255.255.255"; |
+bool hostIsUsedBySomeTestsToGenerateError(const string& host) { |
+ return host == "255.255.255.255"; |
} |
// Used to write a platform neutral file:/// URL by only taking the filename |
// (e.g., converts "file:///tmp/foo.txt" to just "foo.txt"). |
-string urlSuitableForTestResult(const string& url) |
-{ |
- if (url.empty() || string::npos == url.find("file://")) |
- return url; |
+string urlSuitableForTestResult(const string& url) { |
+ if (url.empty() || string::npos == url.find("file://")) return url; |
- size_t pos = url.rfind('/'); |
- if (pos == string::npos) { |
+ size_t pos = url.rfind('/'); |
+ if (pos == string::npos) { |
#ifdef WIN32 |
- pos = url.rfind('\\'); |
- if (pos == string::npos) |
- pos = 0; |
+ pos = url.rfind('\\'); |
+ if (pos == string::npos) pos = 0; |
#else |
- pos = 0; |
+ pos = 0; |
#endif |
- } |
- string filename = url.substr(pos + 1); |
- if (filename.empty()) |
- return "file:"; // A WebKit test has this in its expected output. |
- return filename; |
+ } |
+ string filename = url.substr(pos + 1); |
+ if (filename.empty()) |
+ return "file:"; // A WebKit test has this in its expected output. |
+ return filename; |
} |
// WebNavigationType debugging strings taken from PolicyDelegate.mm. |
@@ -194,266 +181,243 @@ const char* otherString = "other"; |
const char* illegalString = "illegal value"; |
// Get a debugging string from a WebNavigationType. |
-const char* webNavigationTypeToString(WebNavigationType type) |
-{ |
- switch (type) { |
+const char* webNavigationTypeToString(WebNavigationType type) { |
+ switch (type) { |
case blink::WebNavigationTypeLinkClicked: |
- return linkClickedString; |
+ return linkClickedString; |
case blink::WebNavigationTypeFormSubmitted: |
- return formSubmittedString; |
+ return formSubmittedString; |
case blink::WebNavigationTypeBackForward: |
- return backForwardString; |
+ return backForwardString; |
case blink::WebNavigationTypeReload: |
- return reloadString; |
+ return reloadString; |
case blink::WebNavigationTypeFormResubmitted: |
- return formResubmittedString; |
+ return formResubmittedString; |
case blink::WebNavigationTypeOther: |
- return otherString; |
- } |
- return illegalString; |
+ return otherString; |
+ } |
+ return illegalString; |
} |
-string dumpDocumentText(WebFrame* frame) |
-{ |
- // We use the document element's text instead of the body text here because |
- // not all documents have a body, such as XML documents. |
- WebElement documentElement = frame->document().documentElement(); |
- if (documentElement.isNull()) |
- return string(); |
- return documentElement.innerText().utf8(); |
+string dumpDocumentText(WebFrame* frame) { |
+ // We use the document element's text instead of the body text here because |
+ // not all documents have a body, such as XML documents. |
+ WebElement documentElement = frame->document().documentElement(); |
+ if (documentElement.isNull()) return string(); |
+ return documentElement.innerText().utf8(); |
} |
-string dumpFramesAsText(WebFrame* frame, bool recursive) |
-{ |
- string result; |
+string dumpFramesAsText(WebFrame* frame, bool recursive) { |
+ string result; |
- // Add header for all but the main frame. Skip empty frames. |
- if (frame->parent() && !frame->document().documentElement().isNull()) { |
- result.append("\n--------\nFrame: '"); |
- result.append(frame->uniqueName().utf8().data()); |
- result.append("'\n--------\n"); |
- } |
+ // Add header for all but the main frame. Skip empty frames. |
+ if (frame->parent() && !frame->document().documentElement().isNull()) { |
+ result.append("\n--------\nFrame: '"); |
+ result.append(frame->uniqueName().utf8().data()); |
+ result.append("'\n--------\n"); |
+ } |
- result.append(dumpDocumentText(frame)); |
- result.append("\n"); |
+ result.append(dumpDocumentText(frame)); |
+ result.append("\n"); |
- if (recursive) { |
- for (WebFrame* child = frame->firstChild(); child; child = child->nextSibling()) |
- result.append(dumpFramesAsText(child, recursive)); |
- } |
+ if (recursive) { |
+ for (WebFrame* child = frame->firstChild(); child; |
+ child = child->nextSibling()) |
+ result.append(dumpFramesAsText(child, recursive)); |
+ } |
- return result; |
+ return result; |
} |
-string dumpFramesAsPrintedText(WebFrame* frame, bool recursive) |
-{ |
- string result; |
+string dumpFramesAsPrintedText(WebFrame* frame, bool recursive) { |
+ string result; |
- // Cannot do printed format for anything other than HTML |
- if (!frame->document().isHTMLDocument()) |
- return string(); |
+ // Cannot do printed format for anything other than HTML |
+ if (!frame->document().isHTMLDocument()) return string(); |
- // Add header for all but the main frame. Skip empty frames. |
- if (frame->parent() && !frame->document().documentElement().isNull()) { |
- result.append("\n--------\nFrame: '"); |
- result.append(frame->uniqueName().utf8().data()); |
- result.append("'\n--------\n"); |
- } |
+ // Add header for all but the main frame. Skip empty frames. |
+ if (frame->parent() && !frame->document().documentElement().isNull()) { |
+ result.append("\n--------\nFrame: '"); |
+ result.append(frame->uniqueName().utf8().data()); |
+ result.append("'\n--------\n"); |
+ } |
- result.append(frame->renderTreeAsText(WebFrame::RenderAsTextPrinting).utf8()); |
- result.append("\n"); |
+ result.append(frame->renderTreeAsText(WebFrame::RenderAsTextPrinting).utf8()); |
+ result.append("\n"); |
- if (recursive) { |
- for (WebFrame* child = frame->firstChild(); child; child = child->nextSibling()) |
- result.append(dumpFramesAsPrintedText(child, recursive)); |
- } |
+ if (recursive) { |
+ for (WebFrame* child = frame->firstChild(); child; |
+ child = child->nextSibling()) |
+ result.append(dumpFramesAsPrintedText(child, recursive)); |
+ } |
- return result; |
+ return result; |
} |
-string dumpFrameScrollPosition(WebFrame* frame, bool recursive) |
-{ |
- string result; |
- WebSize offset = frame->scrollOffset(); |
- if (offset.width > 0 || offset.height > 0) { |
- if (frame->parent()) |
- result = string("frame '") + frame->uniqueName().utf8().data() + "' "; |
- char data[100]; |
- snprintf(data, sizeof(data), "scrolled to %d,%d\n", offset.width, offset.height); |
- result += data; |
- } |
+string dumpFrameScrollPosition(WebFrame* frame, bool recursive) { |
+ string result; |
+ WebSize offset = frame->scrollOffset(); |
+ if (offset.width > 0 || offset.height > 0) { |
+ if (frame->parent()) |
+ result = string("frame '") + frame->uniqueName().utf8().data() + "' "; |
+ char data[100]; |
+ snprintf(data, sizeof(data), "scrolled to %d,%d\n", offset.width, |
+ offset.height); |
+ result += data; |
+ } |
- if (!recursive) |
- return result; |
- for (WebFrame* child = frame->firstChild(); child; child = child->nextSibling()) |
- result += dumpFrameScrollPosition(child, recursive); |
- return result; |
+ if (!recursive) return result; |
+ for (WebFrame* child = frame->firstChild(); child; |
+ child = child->nextSibling()) |
+ result += dumpFrameScrollPosition(child, recursive); |
+ return result; |
} |
-string dumpAllBackForwardLists(TestInterfaces* interfaces, WebTestDelegate* delegate) |
-{ |
- string result; |
- const vector<WebTestProxyBase*>& windowList = interfaces->windowList(); |
- for (unsigned i = 0; i < windowList.size(); ++i) |
- result.append(delegate->dumpHistoryForWindow(windowList.at(i))); |
- return result; |
+string dumpAllBackForwardLists(TestInterfaces* interfaces, |
+ WebTestDelegate* delegate) { |
+ string result; |
+ const vector<WebTestProxyBase*>& windowList = interfaces->windowList(); |
+ for (unsigned i = 0; i < windowList.size(); ++i) |
+ result.append(delegate->dumpHistoryForWindow(windowList.at(i))); |
+ return result; |
} |
- |
} |
WebTestProxyBase::WebTestProxyBase() |
- : m_testInterfaces(0) |
- , m_delegate(0) |
- , m_webWidget(0) |
- , m_spellcheck(new SpellCheckClient(this)) |
- , m_chooserCount(0) |
-{ |
- reset(); |
-} |
- |
-WebTestProxyBase::~WebTestProxyBase() |
-{ |
- m_testInterfaces->windowClosed(this); |
-} |
- |
-void WebTestProxyBase::setInterfaces(WebTestInterfaces* interfaces) |
-{ |
- m_testInterfaces = interfaces->testInterfaces(); |
- m_testInterfaces->windowOpened(this); |
-} |
- |
-void WebTestProxyBase::setDelegate(WebTestDelegate* delegate) |
-{ |
- m_delegate = delegate; |
- m_spellcheck->setDelegate(delegate); |
- if (m_speechRecognizer.get()) |
- m_speechRecognizer->setDelegate(delegate); |
-} |
- |
-void WebTestProxyBase::setWidget(WebWidget* widget) |
-{ |
- m_webWidget = widget; |
-} |
- |
-WebWidget* WebTestProxyBase::webWidget() |
-{ |
- return m_webWidget; |
-} |
- |
-WebView* WebTestProxyBase::webView() |
-{ |
- DCHECK(m_webWidget); |
- // TestRunner does not support popup widgets. So m_webWidget is always a WebView. |
- return static_cast<WebView*>(m_webWidget); |
-} |
- |
-void WebTestProxyBase::didForceResize() |
-{ |
- invalidateAll(); |
- discardBackingStore(); |
-} |
- |
-void WebTestProxyBase::reset() |
-{ |
- m_paintRect = WebRect(); |
- m_canvas.reset(); |
- m_isPainting = false; |
- m_animateScheduled = false; |
- m_resourceIdentifierMap.clear(); |
- m_logConsoleOutput = true; |
- if (m_midiClient.get()) |
- m_midiClient->resetMock(); |
-} |
- |
-WebSpellCheckClient* WebTestProxyBase::spellCheckClient() const |
-{ |
- return m_spellcheck.get(); |
-} |
- |
-WebColorChooser* WebTestProxyBase::createColorChooser(WebColorChooserClient* client, const blink::WebColor& color, const blink::WebVector<blink::WebColorSuggestion>& suggestions) |
-{ |
- // This instance is deleted by WebCore::ColorInputType |
- return new MockColorChooser(client, m_delegate, this); |
-} |
- |
-bool WebTestProxyBase::runFileChooser(const blink::WebFileChooserParams&, blink::WebFileChooserCompletion*) |
-{ |
- m_delegate->printMessage("Mock: Opening a file chooser.\n"); |
- // FIXME: Add ability to set file names to a file upload control. |
- return false; |
-} |
- |
-void WebTestProxyBase::showValidationMessage(const WebRect&, const WebString& message, const WebString& subMessage, WebTextDirection) |
-{ |
- m_delegate->printMessage(std::string("ValidationMessageClient: main-message=") + std::string(message.utf8()) + " sub-message=" + std::string(subMessage.utf8()) + "\n"); |
-} |
- |
-void WebTestProxyBase::hideValidationMessage() |
-{ |
-} |
- |
-void WebTestProxyBase::moveValidationMessage(const WebRect&) |
-{ |
-} |
- |
-string WebTestProxyBase::captureTree(bool debugRenderTree) |
-{ |
- bool shouldDumpCustomText = m_testInterfaces->testRunner()->shouldDumpAsCustomText(); |
- bool shouldDumpAsText = m_testInterfaces->testRunner()->shouldDumpAsText(); |
- bool shouldDumpAsMarkup = m_testInterfaces->testRunner()->shouldDumpAsMarkup(); |
- bool shouldDumpAsPrinted = m_testInterfaces->testRunner()->isPrinting(); |
- WebFrame* frame = webView()->mainFrame(); |
- string dataUtf8; |
- if (shouldDumpCustomText) { |
- // Append a newline for the test driver. |
- dataUtf8 = m_testInterfaces->testRunner()->customDumpText() + "\n"; |
- } else if (shouldDumpAsText) { |
- bool recursive = m_testInterfaces->testRunner()->shouldDumpChildFramesAsText(); |
- dataUtf8 = shouldDumpAsPrinted ? dumpFramesAsPrintedText(frame, recursive) : dumpFramesAsText(frame, recursive); |
- } else if (shouldDumpAsMarkup) { |
- // Append a newline for the test driver. |
- dataUtf8 = frame->contentAsMarkup().utf8() + "\n"; |
- } else { |
- bool recursive = m_testInterfaces->testRunner()->shouldDumpChildFrameScrollPositions(); |
- WebFrame::RenderAsTextControls renderTextBehavior = WebFrame::RenderAsTextNormal; |
- if (shouldDumpAsPrinted) |
- renderTextBehavior |= WebFrame::RenderAsTextPrinting; |
- if (debugRenderTree) |
- renderTextBehavior |= WebFrame::RenderAsTextDebug; |
- dataUtf8 = frame->renderTreeAsText(renderTextBehavior).utf8(); |
- dataUtf8 += dumpFrameScrollPosition(frame, recursive); |
- } |
+ : test_interfaces_(NULL), |
+ delegate_(NULL), |
+ web_widget_(NULL), |
+ spellcheck_(new SpellCheckClient(this)), |
+ chooser_count_(0) { |
+ Reset(); |
+} |
+ |
+WebTestProxyBase::~WebTestProxyBase() { test_interfaces_->windowClosed(this); } |
+ |
+void WebTestProxyBase::SetInterfaces(WebTestInterfaces* interfaces) { |
+ test_interfaces_ = interfaces->testInterfaces(); |
+ test_interfaces_->windowOpened(this); |
+} |
+ |
+void WebTestProxyBase::SetDelegate(WebTestDelegate* delegate) { |
+ delegate_ = delegate; |
+ spellcheck_->setDelegate(delegate); |
+ if (m_speechRecognizer.get()) m_speechRecognizer->setDelegate(delegate); |
+} |
+ |
+WebView* WebTestProxyBase::GetWebView() const { |
+ DCHECK(web_widget_); |
+ // TestRunner does not support popup widgets. So |web_widget|_ is always a |
+ // WebView. |
+ return static_cast<WebView*>(web_widget_); |
+} |
+ |
+void WebTestProxyBase::DidForceResize() { |
+ InvalidateAll(); |
+ DiscardBackingStore(); |
+} |
+ |
+void WebTestProxyBase::Reset() { |
+ paint_rect_ = WebRect(); |
+ canvas_.reset(); |
+ is_painting_ = false; |
+ animate_scheduled_ = false; |
+ resource_identifier_map_.clear(); |
+ log_console_output_ = true; |
+ if (m_midiClient.get()) m_midiClient->resetMock(); |
+} |
+ |
+WebSpellCheckClient* WebTestProxyBase::GetSpellCheckClient() const { |
+ return spellcheck_.get(); |
+} |
+ |
+WebColorChooser* WebTestProxyBase::CreateColorChooser( |
+ WebColorChooserClient* client, const blink::WebColor& color, |
+ const blink::WebVector<blink::WebColorSuggestion>& suggestions) { |
+ // This instance is deleted by WebCore::ColorInputType |
+ return new MockColorChooser(client, delegate_, this); |
+} |
+ |
+bool WebTestProxyBase::RunFileChooser(const blink::WebFileChooserParams&, |
+ blink::WebFileChooserCompletion*) { |
+ delegate_->printMessage("Mock: Opening a file chooser.\n"); |
+ // FIXME: Add ability to set file names to a file upload control. |
+ return false; |
+} |
+ |
+void WebTestProxyBase::ShowValidationMessage(const WebRect&, |
+ const WebString& message, |
+ const WebString& subMessage, |
+ WebTextDirection) { |
+ delegate_->printMessage( |
+ std::string("ValidationMessageClient: main-message=") + |
+ std::string(message.utf8()) + " sub-message=" + |
+ std::string(subMessage.utf8()) + "\n"); |
+} |
+ |
+void WebTestProxyBase::HideValidationMessage() {} |
+ |
+void WebTestProxyBase::MoveValidationMessage(const WebRect&) {} |
+ |
+string WebTestProxyBase::CaptureTree(bool debugRenderTree) { |
+ bool shouldDumpCustomText = |
+ test_interfaces_->testRunner()->shouldDumpAsCustomText(); |
+ bool shouldDumpAsText = test_interfaces_->testRunner()->shouldDumpAsText(); |
+ bool shouldDumpAsMarkup = |
+ test_interfaces_->testRunner()->shouldDumpAsMarkup(); |
+ bool shouldDumpAsPrinted = test_interfaces_->testRunner()->isPrinting(); |
+ WebFrame* frame = GetWebView()->mainFrame(); |
+ string dataUtf8; |
+ if (shouldDumpCustomText) { |
+ // Append a newline for the test driver. |
+ dataUtf8 = test_interfaces_->testRunner()->customDumpText() + "\n"; |
+ } else if (shouldDumpAsText) { |
+ bool recursive = |
+ test_interfaces_->testRunner()->shouldDumpChildFramesAsText(); |
+ dataUtf8 = shouldDumpAsPrinted ? dumpFramesAsPrintedText(frame, recursive) |
+ : dumpFramesAsText(frame, recursive); |
+ } else if (shouldDumpAsMarkup) { |
+ // Append a newline for the test driver. |
+ dataUtf8 = frame->contentAsMarkup().utf8() + "\n"; |
+ } else { |
+ bool recursive = |
+ test_interfaces_->testRunner()->shouldDumpChildFrameScrollPositions(); |
+ WebFrame::RenderAsTextControls renderTextBehavior = |
+ WebFrame::RenderAsTextNormal; |
+ if (shouldDumpAsPrinted) |
+ renderTextBehavior |= WebFrame::RenderAsTextPrinting; |
+ if (debugRenderTree) renderTextBehavior |= WebFrame::RenderAsTextDebug; |
+ dataUtf8 = frame->renderTreeAsText(renderTextBehavior).utf8(); |
+ dataUtf8 += dumpFrameScrollPosition(frame, recursive); |
+ } |
- if (m_testInterfaces->testRunner()->shouldDumpBackForwardList()) |
- dataUtf8 += dumpAllBackForwardLists(m_testInterfaces, m_delegate); |
+ if (test_interfaces_->testRunner()->shouldDumpBackForwardList()) |
+ dataUtf8 += dumpAllBackForwardLists(test_interfaces_, delegate_); |
- return dataUtf8; |
+ return dataUtf8; |
} |
-SkCanvas* WebTestProxyBase::capturePixels() |
-{ |
- TRACE_EVENT0("shell", "WebTestProxyBase::capturePixels"); |
- webWidget()->layout(); |
- if (m_testInterfaces->testRunner()->isPrinting()) |
- paintPagesWithBoundaries(); |
- else |
- paintInvalidatedRegion(); |
+SkCanvas* WebTestProxyBase::CapturePixels() { |
+ TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixels"); |
+ web_widget_->layout(); |
+ if (test_interfaces_->testRunner()->isPrinting()) |
+ PaintPagesWithBoundaries(); |
+ else |
+ PaintInvalidatedRegion(); |
- DrawSelectionRect(canvas()); |
+ DrawSelectionRect(GetCanvas()); |
- return canvas(); |
+ return GetCanvas(); |
} |
void WebTestProxyBase::DrawSelectionRect(SkCanvas* canvas) { |
// See if we need to draw the selection bounds rect. Selection bounds |
// rect is the rect enclosing the (possibly transformed) selection. |
// The rect should be drawn after everything is laid out and painted. |
- if (!m_testInterfaces->testRunner()->shouldDumpSelectionRect()) |
- return; |
+ if (!test_interfaces_->testRunner()->shouldDumpSelectionRect()) return; |
// If there is a selection rect - draw a red 1px border enclosing rect |
- WebRect wr = webView()->mainFrame()->selectionBoundsRect(); |
- if (wr.isEmpty()) |
- return; |
+ WebRect wr = GetWebView()->mainFrame()->selectionBoundsRect(); |
+ if (wr.isEmpty()) return; |
// Render a red rectangle bounding selection rect |
SkPaint paint; |
paint.setColor(0xFFFF0000); // Fully opaque red |
@@ -466,151 +430,146 @@ void WebTestProxyBase::DrawSelectionRect(SkCanvas* canvas) { |
} |
void WebTestProxyBase::didCompositeAndReadback(const SkBitmap& bitmap) { |
- TRACE_EVENT2("shell", |
- "WebTestProxyBase::didCompositeAndReadback", |
- "x", |
- bitmap.info().fWidth, |
- "y", |
- bitmap.info().fHeight); |
+ TRACE_EVENT2("shell", "WebTestProxyBase::didCompositeAndReadback", "x", |
+ bitmap.info().fWidth, "y", bitmap.info().fHeight); |
SkCanvas canvas(bitmap); |
DrawSelectionRect(&canvas); |
- DCHECK(!m_compositeAndReadbackCallbacks.empty()); |
- m_compositeAndReadbackCallbacks.front().Run(bitmap); |
- m_compositeAndReadbackCallbacks.pop_front(); |
+ DCHECK(!composite_and_readback_callbacks_.empty()); |
+ composite_and_readback_callbacks_.front().Run(bitmap); |
+ composite_and_readback_callbacks_.pop_front(); |
} |
void WebTestProxyBase::CapturePixelsForPrinting( |
- base::Callback<void(const SkBitmap&)> callback) { |
+ const base::Callback<void(const SkBitmap&)>& callback) { |
// TODO(enne): get rid of stateful canvas(). |
- webWidget()->layout(); |
- paintPagesWithBoundaries(); |
- DrawSelectionRect(canvas()); |
- SkBaseDevice* device = skia::GetTopDevice(*canvas()); |
+ web_widget_->layout(); |
+ PaintPagesWithBoundaries(); |
+ DrawSelectionRect(GetCanvas()); |
+ SkBaseDevice* device = skia::GetTopDevice(*GetCanvas()); |
const SkBitmap& bitmap = device->accessBitmap(false); |
callback.Run(bitmap); |
} |
void WebTestProxyBase::CapturePixelsAsync( |
- base::Callback<void(const SkBitmap&)> callback) { |
+ const base::Callback<void(const SkBitmap&)>& callback) { |
TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixelsAsync"); |
- DCHECK(webWidget()->isAcceleratedCompositingActive()); |
+ DCHECK(web_widget_->isAcceleratedCompositingActive()); |
DCHECK(!callback.is_null()); |
- if (m_testInterfaces->testRunner()->isPrinting()) { |
+ if (test_interfaces_->testRunner()->isPrinting()) { |
base::MessageLoopProxy::current()->PostTask( |
- FROM_HERE, |
- base::Bind(&WebTestProxyBase::CapturePixelsForPrinting, |
- base::Unretained(this), |
- callback)); |
+ FROM_HERE, base::Bind(&WebTestProxyBase::CapturePixelsForPrinting, |
+ base::Unretained(this), callback)); |
return; |
} |
- m_compositeAndReadbackCallbacks.push_back(callback); |
- webWidget()->compositeAndReadbackAsync(this); |
-} |
- |
-void WebTestProxyBase::setLogConsoleOutput(bool enabled) |
-{ |
- m_logConsoleOutput = enabled; |
-} |
- |
-void WebTestProxyBase::paintRect(const WebRect& rect) |
-{ |
- DCHECK(!m_isPainting); |
- DCHECK(canvas()); |
- m_isPainting = true; |
- float deviceScaleFactor = webView()->deviceScaleFactor(); |
- int scaledX = static_cast<int>(static_cast<float>(rect.x) * deviceScaleFactor); |
- int scaledY = static_cast<int>(static_cast<float>(rect.y) * deviceScaleFactor); |
- int scaledWidth = static_cast<int>(ceil(static_cast<float>(rect.width) * deviceScaleFactor)); |
- int scaledHeight = static_cast<int>(ceil(static_cast<float>(rect.height) * deviceScaleFactor)); |
- WebRect deviceRect(scaledX, scaledY, scaledWidth, scaledHeight); |
- webWidget()->paint(canvas(), deviceRect); |
- m_isPainting = false; |
-} |
- |
-void WebTestProxyBase::paintInvalidatedRegion() |
-{ |
- webWidget()->animate(0.0); |
- webWidget()->layout(); |
- WebSize widgetSize = webWidget()->size(); |
- WebRect clientRect(0, 0, widgetSize.width, widgetSize.height); |
- |
- // Paint the canvas if necessary. Allow painting to generate extra rects |
- // for the first two calls. This is necessary because some WebCore rendering |
- // objects update their layout only when painted. |
- // Store the total area painted in total_paint. Then tell the gdk window |
- // to update that area after we're done painting it. |
- for (int i = 0; i < 3; ++i) { |
- // rect = intersect(m_paintRect , clientRect) |
- WebRect damageRect = m_paintRect; |
- int left = max(damageRect.x, clientRect.x); |
- int top = max(damageRect.y, clientRect.y); |
- int right = min(damageRect.x + damageRect.width, clientRect.x + clientRect.width); |
- int bottom = min(damageRect.y + damageRect.height, clientRect.y + clientRect.height); |
- WebRect rect; |
- if (left < right && top < bottom) |
- rect = WebRect(left, top, right - left, bottom - top); |
- |
- m_paintRect = WebRect(); |
- if (rect.isEmpty()) |
- continue; |
- paintRect(rect); |
- } |
- DCHECK(m_paintRect.isEmpty()); |
+ composite_and_readback_callbacks_.push_back(callback); |
+ web_widget_->compositeAndReadbackAsync(this); |
+} |
+ |
+void WebTestProxyBase::SetLogConsoleOutput(bool enabled) { |
+ log_console_output_ = enabled; |
+} |
+ |
+void WebTestProxyBase::PaintRect(const WebRect& rect) { |
+ DCHECK(!is_painting_); |
+ DCHECK(GetCanvas()); |
+ is_painting_ = true; |
+ float deviceScaleFactor = GetWebView()->deviceScaleFactor(); |
+ int scaledX = |
+ static_cast<int>(static_cast<float>(rect.x) * deviceScaleFactor); |
+ int scaledY = |
+ static_cast<int>(static_cast<float>(rect.y) * deviceScaleFactor); |
+ int scaledWidth = static_cast<int>( |
+ ceil(static_cast<float>(rect.width) * deviceScaleFactor)); |
+ int scaledHeight = static_cast<int>( |
+ ceil(static_cast<float>(rect.height) * deviceScaleFactor)); |
+ WebRect deviceRect(scaledX, scaledY, scaledWidth, scaledHeight); |
+ web_widget_->paint(GetCanvas(), deviceRect); |
+ is_painting_ = false; |
+} |
+ |
+void WebTestProxyBase::PaintInvalidatedRegion() { |
+ web_widget_->animate(0.0); |
+ web_widget_->layout(); |
+ WebSize widgetSize = web_widget_->size(); |
+ WebRect clientRect(0, 0, widgetSize.width, widgetSize.height); |
+ |
+ // Paint the canvas if necessary. Allow painting to generate extra rects |
+ // for the first two calls. This is necessary because some WebCore rendering |
+ // objects update their layout only when painted. |
+ // Store the total area painted in total_paint. Then tell the gdk window |
+ // to update that area after we're done painting it. |
+ for (int i = 0; i < 3; ++i) { |
+ // rect = intersect(paint_rect_ , clientRect) |
+ WebRect damageRect = paint_rect_; |
+ int left = max(damageRect.x, clientRect.x); |
+ int top = max(damageRect.y, clientRect.y); |
+ int right = |
+ min(damageRect.x + damageRect.width, clientRect.x + clientRect.width); |
+ int bottom = |
+ min(damageRect.y + damageRect.height, clientRect.y + clientRect.height); |
+ WebRect rect; |
+ if (left < right && top < bottom) |
+ rect = WebRect(left, top, right - left, bottom - top); |
+ |
+ paint_rect_ = WebRect(); |
+ if (rect.isEmpty()) continue; |
+ PaintRect(rect); |
+ } |
+ DCHECK(paint_rect_.isEmpty()); |
} |
-void WebTestProxyBase::paintPagesWithBoundaries() |
-{ |
- DCHECK(!m_isPainting); |
- DCHECK(canvas()); |
- m_isPainting = true; |
- |
- WebSize pageSizeInPixels = webWidget()->size(); |
- WebFrame* webFrame = webView()->mainFrame(); |
+void WebTestProxyBase::PaintPagesWithBoundaries() { |
+ DCHECK(!is_painting_); |
+ DCHECK(GetCanvas()); |
+ is_painting_ = true; |
- int pageCount = webFrame->printBegin(pageSizeInPixels); |
- int totalHeight = pageCount * (pageSizeInPixels.height + 1) - 1; |
+ WebSize pageSizeInPixels = web_widget_->size(); |
+ WebFrame* webFrame = GetWebView()->mainFrame(); |
- SkCanvas* testCanvas = skia::TryCreateBitmapCanvas(pageSizeInPixels.width, totalHeight, false); |
- if (testCanvas) { |
- discardBackingStore(); |
- m_canvas.reset(testCanvas); |
- } else { |
- webFrame->printEnd(); |
- return; |
- } |
+ int pageCount = webFrame->printBegin(pageSizeInPixels); |
+ int totalHeight = pageCount * (pageSizeInPixels.height + 1) - 1; |
- webFrame->printPagesWithBoundaries(canvas(), pageSizeInPixels); |
+ SkCanvas* testCanvas = |
+ skia::TryCreateBitmapCanvas(pageSizeInPixels.width, totalHeight, false); |
+ if (testCanvas) { |
+ DiscardBackingStore(); |
+ canvas_.reset(testCanvas); |
+ } else { |
webFrame->printEnd(); |
+ return; |
+ } |
+ |
+ webFrame->printPagesWithBoundaries(GetCanvas(), pageSizeInPixels); |
+ webFrame->printEnd(); |
- m_isPainting = false; |
+ is_painting_ = false; |
} |
-SkCanvas* WebTestProxyBase::canvas() |
-{ |
- if (m_canvas.get()) |
- return m_canvas.get(); |
- WebSize widgetSize = webWidget()->size(); |
- float deviceScaleFactor = webView()->deviceScaleFactor(); |
- int scaledWidth = static_cast<int>(ceil(static_cast<float>(widgetSize.width) * deviceScaleFactor)); |
- int scaledHeight = static_cast<int>(ceil(static_cast<float>(widgetSize.height) * deviceScaleFactor)); |
- // We're allocating the canvas to be non-opaque (third parameter), so we |
- // don't end up with uninitialized memory if a layout test doesn't damage |
- // the entire view. |
- m_canvas.reset(skia::CreateBitmapCanvas(scaledWidth, scaledHeight, false)); |
- return m_canvas.get(); |
+SkCanvas* WebTestProxyBase::GetCanvas() { |
+ if (canvas_.get()) return canvas_.get(); |
+ WebSize widgetSize = web_widget_->size(); |
+ float deviceScaleFactor = GetWebView()->deviceScaleFactor(); |
+ int scaledWidth = static_cast<int>( |
+ ceil(static_cast<float>(widgetSize.width) * deviceScaleFactor)); |
+ int scaledHeight = static_cast<int>( |
+ ceil(static_cast<float>(widgetSize.height) * deviceScaleFactor)); |
+ // We're allocating the canvas to be non-opaque (third parameter), so we |
+ // don't end up with uninitialized memory if a layout test doesn't damage |
+ // the entire view. |
+ canvas_.reset(skia::CreateBitmapCanvas(scaledWidth, scaledHeight, false)); |
+ return canvas_.get(); |
} |
void WebTestProxyBase::DisplayForSoftwareMode(const base::Closure& callback) { |
- const blink::WebSize& size = webWidget()->size(); |
+ const blink::WebSize& size = web_widget_->size(); |
WebRect rect(0, 0, size.width, size.height); |
- m_paintRect = rect; |
- paintInvalidatedRegion(); |
+ paint_rect_ = rect; |
+ PaintInvalidatedRegion(); |
- if (!callback.is_null()) |
- callback.Run(); |
+ if (!callback.is_null()) callback.Run(); |
} |
void WebTestProxyBase::DidDisplayAsync(const base::Closure& callback, |
@@ -618,711 +577,698 @@ void WebTestProxyBase::DidDisplayAsync(const base::Closure& callback, |
// Verify we actually composited. |
CHECK_NE(0, bitmap.info().fWidth); |
CHECK_NE(0, bitmap.info().fHeight); |
- if (!callback.is_null()) |
- callback.Run(); |
+ if (!callback.is_null()) callback.Run(); |
} |
-void WebTestProxyBase::displayAsyncThen(base::Closure callback) { |
- TRACE_EVENT0("shell", "WebTestProxyBase::displayAsyncThen"); |
+void WebTestProxyBase::DisplayAsyncThen(const base::Closure& callback) { |
+ TRACE_EVENT0("shell", "WebTestProxyBase::DisplayAsyncThen"); |
// TODO(danakj): Remove when we have kForceCompositingMode everywhere. |
- if (!webWidget()->isAcceleratedCompositingActive()) { |
+ if (!web_widget_->isAcceleratedCompositingActive()) { |
TRACE_EVENT0("shell", |
- "WebTestProxyBase::displayAsyncThen " |
+ "WebTestProxyBase::DisplayAsyncThen " |
"isAcceleratedCompositingActive false"); |
base::MessageLoopProxy::current()->PostTask( |
- FROM_HERE, |
- base::Bind(&WebTestProxyBase::DisplayForSoftwareMode, |
- base::Unretained(this), |
- callback)); |
+ FROM_HERE, base::Bind(&WebTestProxyBase::DisplayForSoftwareMode, |
+ base::Unretained(this), callback)); |
return; |
} |
- CapturePixelsAsync(base::Bind( |
- &WebTestProxyBase::DidDisplayAsync, base::Unretained(this), callback)); |
+ CapturePixelsAsync(base::Bind(&WebTestProxyBase::DidDisplayAsync, |
+ base::Unretained(this), callback)); |
} |
-void WebTestProxyBase::discardBackingStore() |
-{ |
- m_canvas.reset(); |
-} |
+void WebTestProxyBase::DiscardBackingStore() { canvas_.reset(); } |
-WebMIDIClientMock* WebTestProxyBase::midiClientMock() |
-{ |
- if (!m_midiClient.get()) |
- m_midiClient.reset(new WebMIDIClientMock); |
- return m_midiClient.get(); |
+WebMIDIClientMock* WebTestProxyBase::GetMIDIClientMock() { |
+ if (!m_midiClient.get()) m_midiClient.reset(new WebMIDIClientMock); |
+ return m_midiClient.get(); |
} |
-MockWebSpeechRecognizer* WebTestProxyBase::speechRecognizerMock() |
-{ |
- if (!m_speechRecognizer.get()) { |
- m_speechRecognizer.reset(new MockWebSpeechRecognizer()); |
- m_speechRecognizer->setDelegate(m_delegate); |
- } |
- return m_speechRecognizer.get(); |
+MockWebSpeechRecognizer* WebTestProxyBase::GetSpeechRecognizerMock() { |
+ if (!m_speechRecognizer.get()) { |
+ m_speechRecognizer.reset(new MockWebSpeechRecognizer()); |
+ m_speechRecognizer->setDelegate(delegate_); |
+ } |
+ return m_speechRecognizer.get(); |
} |
-void WebTestProxyBase::didInvalidateRect(const WebRect& rect) |
-{ |
- // m_paintRect = m_paintRect U rect |
- if (rect.isEmpty()) |
- return; |
- if (m_paintRect.isEmpty()) { |
- m_paintRect = rect; |
- return; |
- } |
- int left = min(m_paintRect.x, rect.x); |
- int top = min(m_paintRect.y, rect.y); |
- int right = max(m_paintRect.x + m_paintRect.width, rect.x + rect.width); |
- int bottom = max(m_paintRect.y + m_paintRect.height, rect.y + rect.height); |
- m_paintRect = WebRect(left, top, right - left, bottom - top); |
+void WebTestProxyBase::DidInvalidateRect(const WebRect& rect) { |
+ // paint_rect_ = paint_rect_ U rect |
+ if (rect.isEmpty()) return; |
+ if (paint_rect_.isEmpty()) { |
+ paint_rect_ = rect; |
+ return; |
+ } |
+ int left = min(paint_rect_.x, rect.x); |
+ int top = min(paint_rect_.y, rect.y); |
+ int right = max(paint_rect_.x + paint_rect_.width, rect.x + rect.width); |
+ int bottom = max(paint_rect_.y + paint_rect_.height, rect.y + rect.height); |
+ paint_rect_ = WebRect(left, top, right - left, bottom - top); |
} |
-void WebTestProxyBase::didScrollRect(int, int, const WebRect& clipRect) |
-{ |
- didInvalidateRect(clipRect); |
+void WebTestProxyBase::DidScrollRect(int, int, const WebRect& clipRect) { |
+ DidInvalidateRect(clipRect); |
} |
-void WebTestProxyBase::invalidateAll() |
-{ |
- m_paintRect = WebRect(0, 0, INT_MAX, INT_MAX); |
+void WebTestProxyBase::InvalidateAll() { |
+ paint_rect_ = WebRect(0, 0, INT_MAX, INT_MAX); |
} |
-void WebTestProxyBase::scheduleComposite() |
-{ |
- invalidateAll(); |
-} |
+void WebTestProxyBase::ScheduleComposite() { InvalidateAll(); } |
-void WebTestProxyBase::scheduleAnimation() |
-{ |
- if (!m_testInterfaces->testRunner()->TestIsRunning()) |
- return; |
+void WebTestProxyBase::ScheduleAnimation() { |
+ if (!test_interfaces_->testRunner()->TestIsRunning()) return; |
- if (!m_animateScheduled) { |
- m_animateScheduled = true; |
- m_delegate->postDelayedTask(new HostMethodTask(this, &WebTestProxyBase::animateNow), 1); |
- } |
+ if (!animate_scheduled_) { |
+ animate_scheduled_ = true; |
+ delegate_->postDelayedTask( |
+ new HostMethodTask(this, &WebTestProxyBase::AnimateNow), 1); |
+ } |
} |
-void WebTestProxyBase::animateNow() |
-{ |
- if (m_animateScheduled) { |
- m_animateScheduled = false; |
- webWidget()->animate(0.0); |
- webWidget()->layout(); |
- } |
+void WebTestProxyBase::AnimateNow() { |
+ if (animate_scheduled_) { |
+ animate_scheduled_ = false; |
+ web_widget_->animate(0.0); |
+ web_widget_->layout(); |
+ } |
} |
-bool WebTestProxyBase::isCompositorFramePending() const |
-{ |
- return m_animateScheduled || !m_paintRect.isEmpty(); |
+bool WebTestProxyBase::IsCompositorFramePending() const { |
+ return animate_scheduled_ || !paint_rect_.isEmpty(); |
} |
-void WebTestProxyBase::show(WebNavigationPolicy) |
-{ |
- invalidateAll(); |
-} |
+void WebTestProxyBase::Show(WebNavigationPolicy) { InvalidateAll(); } |
-void WebTestProxyBase::setWindowRect(const WebRect& rect) |
-{ |
- invalidateAll(); |
- discardBackingStore(); |
+void WebTestProxyBase::SetWindowRect(const WebRect& rect) { |
+ InvalidateAll(); |
+ DiscardBackingStore(); |
} |
-void WebTestProxyBase::didAutoResize(const WebSize&) |
-{ |
- invalidateAll(); |
-} |
+void WebTestProxyBase::DidAutoResize(const WebSize&) { InvalidateAll(); } |
-void WebTestProxyBase::postAccessibilityEvent(const blink::WebAXObject& obj, blink::WebAXEvent event) |
-{ |
- // Only hook the accessibility events occured during the test run. |
- // This check prevents false positives in WebLeakDetector. |
- // The pending tasks in browser/renderer message queue may trigger accessibility events, |
- // and AccessibilityController will hold on to their target nodes if we don't ignore them here. |
- if (!m_testInterfaces->testRunner()->TestIsRunning()) |
- return; |
+void WebTestProxyBase::PostAccessibilityEvent(const blink::WebAXObject& obj, |
+ blink::WebAXEvent event) { |
+ // Only hook the accessibility events occured during the test run. |
+ // This check prevents false positives in WebLeakDetector. |
+ // The pending tasks in browser/renderer message queue may trigger |
+ // accessibility events, |
+ // and AccessibilityController will hold on to their target nodes if we don't |
+ // ignore them here. |
+ if (!test_interfaces_->testRunner()->TestIsRunning()) return; |
- if (event == blink::WebAXEventFocus) |
- m_testInterfaces->accessibilityController()->SetFocusedElement(obj); |
+ if (event == blink::WebAXEventFocus) |
+ test_interfaces_->accessibilityController()->SetFocusedElement(obj); |
- const char* eventName = 0; |
- switch (event) { |
+ const char* eventName = NULL; |
+ switch (event) { |
case blink::WebAXEventActiveDescendantChanged: |
- eventName = "ActiveDescendantChanged"; |
- break; |
+ eventName = "ActiveDescendantChanged"; |
+ break; |
case blink::WebAXEventAlert: |
- eventName = "Alert"; |
- break; |
+ eventName = "Alert"; |
+ break; |
case blink::WebAXEventAriaAttributeChanged: |
- eventName = "AriaAttributeChanged"; |
- break; |
+ eventName = "AriaAttributeChanged"; |
+ break; |
case blink::WebAXEventAutocorrectionOccured: |
- eventName = "AutocorrectionOccured"; |
- break; |
+ eventName = "AutocorrectionOccured"; |
+ break; |
case blink::WebAXEventBlur: |
- eventName = "Blur"; |
- break; |
+ eventName = "Blur"; |
+ break; |
case blink::WebAXEventCheckedStateChanged: |
- eventName = "CheckedStateChanged"; |
- break; |
+ eventName = "CheckedStateChanged"; |
+ break; |
case blink::WebAXEventChildrenChanged: |
- eventName = "ChildrenChanged"; |
- break; |
+ eventName = "ChildrenChanged"; |
+ break; |
case blink::WebAXEventFocus: |
- eventName = "Focus"; |
- break; |
+ eventName = "Focus"; |
+ break; |
case blink::WebAXEventHide: |
- eventName = "Hide"; |
- break; |
+ eventName = "Hide"; |
+ break; |
case blink::WebAXEventInvalidStatusChanged: |
- eventName = "InvalidStatusChanged"; |
- break; |
+ eventName = "InvalidStatusChanged"; |
+ break; |
case blink::WebAXEventLayoutComplete: |
- eventName = "LayoutComplete"; |
- break; |
+ eventName = "LayoutComplete"; |
+ break; |
case blink::WebAXEventLiveRegionChanged: |
- eventName = "LiveRegionChanged"; |
- break; |
+ eventName = "LiveRegionChanged"; |
+ break; |
case blink::WebAXEventLoadComplete: |
- eventName = "LoadComplete"; |
- break; |
+ eventName = "LoadComplete"; |
+ break; |
case blink::WebAXEventLocationChanged: |
- eventName = "LocationChanged"; |
- break; |
+ eventName = "LocationChanged"; |
+ break; |
case blink::WebAXEventMenuListItemSelected: |
- eventName = "MenuListItemSelected"; |
- break; |
+ eventName = "MenuListItemSelected"; |
+ break; |
case blink::WebAXEventMenuListValueChanged: |
- eventName = "MenuListValueChanged"; |
- break; |
+ eventName = "MenuListValueChanged"; |
+ break; |
case blink::WebAXEventRowCollapsed: |
- eventName = "RowCollapsed"; |
- break; |
+ eventName = "RowCollapsed"; |
+ break; |
case blink::WebAXEventRowCountChanged: |
- eventName = "RowCountChanged"; |
- break; |
+ eventName = "RowCountChanged"; |
+ break; |
case blink::WebAXEventRowExpanded: |
- eventName = "RowExpanded"; |
- break; |
+ eventName = "RowExpanded"; |
+ break; |
case blink::WebAXEventScrollPositionChanged: |
- eventName = "ScrollPositionChanged"; |
- break; |
+ eventName = "ScrollPositionChanged"; |
+ break; |
case blink::WebAXEventScrolledToAnchor: |
- eventName = "ScrolledToAnchor"; |
- break; |
+ eventName = "ScrolledToAnchor"; |
+ break; |
case blink::WebAXEventSelectedChildrenChanged: |
- eventName = "SelectedChildrenChanged"; |
- break; |
+ eventName = "SelectedChildrenChanged"; |
+ break; |
case blink::WebAXEventSelectedTextChanged: |
- eventName = "SelectedTextChanged"; |
- break; |
+ eventName = "SelectedTextChanged"; |
+ break; |
case blink::WebAXEventShow: |
- eventName = "Show"; |
- break; |
+ eventName = "Show"; |
+ break; |
case blink::WebAXEventTextChanged: |
- eventName = "TextChanged"; |
- break; |
+ eventName = "TextChanged"; |
+ break; |
case blink::WebAXEventTextInserted: |
- eventName = "TextInserted"; |
- break; |
+ eventName = "TextInserted"; |
+ break; |
case blink::WebAXEventTextRemoved: |
- eventName = "TextRemoved"; |
- break; |
+ eventName = "TextRemoved"; |
+ break; |
case blink::WebAXEventValueChanged: |
- eventName = "ValueChanged"; |
- break; |
+ eventName = "ValueChanged"; |
+ break; |
default: |
- eventName = "Unknown"; |
- break; |
- } |
- |
- m_testInterfaces->accessibilityController()->NotificationReceived(obj, eventName); |
- |
- if (m_testInterfaces->accessibilityController()->ShouldLogAccessibilityEvents()) { |
- string message("AccessibilityNotification - "); |
- message += eventName; |
- |
- blink::WebNode node = obj.node(); |
- if (!node.isNull() && node.isElementNode()) { |
- blink::WebElement element = node.to<blink::WebElement>(); |
- if (element.hasAttribute("id")) { |
- message += " - id:"; |
- message += element.getAttribute("id").utf8().data(); |
- } |
- } |
+ eventName = "Unknown"; |
+ break; |
+ } |
- m_delegate->printMessage(message + "\n"); |
+ test_interfaces_->accessibilityController()->NotificationReceived(obj, |
+ eventName); |
+ |
+ if (test_interfaces_->accessibilityController() |
+ ->ShouldLogAccessibilityEvents()) { |
+ string message("AccessibilityNotification - "); |
+ message += eventName; |
+ |
+ blink::WebNode node = obj.node(); |
+ if (!node.isNull() && node.isElementNode()) { |
+ blink::WebElement element = node.to<blink::WebElement>(); |
+ if (element.hasAttribute("id")) { |
+ message += " - id:"; |
+ message += element.getAttribute("id").utf8().data(); |
+ } |
} |
+ |
+ delegate_->printMessage(message + "\n"); |
+ } |
} |
-void WebTestProxyBase::startDragging(WebLocalFrame*, const WebDragData& data, WebDragOperationsMask mask, const WebImage&, const WebPoint&) |
-{ |
- // When running a test, we need to fake a drag drop operation otherwise |
- // Windows waits for real mouse events to know when the drag is over. |
- m_testInterfaces->eventSender()->DoDragDrop(data, mask); |
+void WebTestProxyBase::StartDragging(WebLocalFrame*, const WebDragData& data, |
+ WebDragOperationsMask mask, |
+ const WebImage&, const WebPoint&) { |
+ // When running a test, we need to fake a drag drop operation otherwise |
+ // Windows waits for real mouse events to know when the drag is over. |
+ test_interfaces_->eventSender()->DoDragDrop(data, mask); |
} |
// The output from these methods in layout test mode should match that |
// expected by the layout tests. See EditingDelegate.m in DumpRenderTree. |
-void WebTestProxyBase::didChangeSelection(bool isEmptySelection) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) |
- m_delegate->printMessage("EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n"); |
+void WebTestProxyBase::DidChangeSelection(bool isEmptySelection) { |
+ if (test_interfaces_->testRunner()->shouldDumpEditingCallbacks()) |
+ delegate_->printMessage( |
+ "EDITING DELEGATE: " |
+ "webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n"); |
} |
-void WebTestProxyBase::didChangeContents() |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) |
- m_delegate->printMessage("EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n"); |
+void WebTestProxyBase::DidChangeContents() { |
+ if (test_interfaces_->testRunner()->shouldDumpEditingCallbacks()) |
+ delegate_->printMessage( |
+ "EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n"); |
} |
-bool WebTestProxyBase::createView(WebLocalFrame*, const WebURLRequest& request, const WebWindowFeatures&, const WebString&, WebNavigationPolicy, bool) |
-{ |
- if (!m_testInterfaces->testRunner()->canOpenWindows()) |
- return false; |
- if (m_testInterfaces->testRunner()->shouldDumpCreateView()) |
- m_delegate->printMessage(string("createView(") + URLDescription(request.url()) + ")\n"); |
- return true; |
+bool WebTestProxyBase::CreateView(WebLocalFrame*, const WebURLRequest& request, |
+ const WebWindowFeatures&, const WebString&, |
+ WebNavigationPolicy, bool) { |
+ if (!test_interfaces_->testRunner()->canOpenWindows()) return false; |
+ if (test_interfaces_->testRunner()->shouldDumpCreateView()) |
+ delegate_->printMessage(string("createView(") + |
+ URLDescription(request.url()) + ")\n"); |
+ return true; |
} |
-WebPlugin* WebTestProxyBase::createPlugin(WebLocalFrame* frame, const WebPluginParams& params) |
-{ |
- if (TestPlugin::isSupportedMimeType(params.mimeType)) |
- return TestPlugin::create(frame, params, m_delegate); |
- return 0; |
+WebPlugin* WebTestProxyBase::CreatePlugin(WebLocalFrame* frame, |
+ const WebPluginParams& params) { |
+ if (TestPlugin::isSupportedMimeType(params.mimeType)) |
+ return TestPlugin::create(frame, params, delegate_); |
+ return 0; |
} |
-void WebTestProxyBase::setStatusText(const WebString& text) |
-{ |
- if (!m_testInterfaces->testRunner()->shouldDumpStatusCallbacks()) |
- return; |
- m_delegate->printMessage(string("UI DELEGATE STATUS CALLBACK: setStatusText:") + text.utf8().data() + "\n"); |
+void WebTestProxyBase::SetStatusText(const WebString& text) { |
+ if (!test_interfaces_->testRunner()->shouldDumpStatusCallbacks()) return; |
+ delegate_->printMessage( |
+ string("UI DELEGATE STATUS CALLBACK: setStatusText:") + |
+ text.utf8().data() + "\n"); |
} |
-void WebTestProxyBase::didStopLoading() |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpProgressFinishedCallback()) |
- m_delegate->printMessage("postProgressFinishedNotification\n"); |
+void WebTestProxyBase::DidStopLoading() { |
+ if (test_interfaces_->testRunner()->shouldDumpProgressFinishedCallback()) |
+ delegate_->printMessage("postProgressFinishedNotification\n"); |
} |
-void WebTestProxyBase::showContextMenu(WebLocalFrame*, const WebContextMenuData& contextMenuData) |
-{ |
- m_testInterfaces->eventSender()->SetContextMenuData(contextMenuData); |
+void WebTestProxyBase::ShowContextMenu( |
+ WebLocalFrame*, const WebContextMenuData& contextMenuData) { |
+ test_interfaces_->eventSender()->SetContextMenuData(contextMenuData); |
} |
-WebUserMediaClient* WebTestProxyBase::userMediaClient() |
-{ |
- if (!m_userMediaClient.get()) |
- m_userMediaClient.reset(new WebUserMediaClientMock(m_delegate)); |
- return m_userMediaClient.get(); |
+WebUserMediaClient* WebTestProxyBase::GetUserMediaClient() { |
+ if (!user_media_client_.get()) |
+ user_media_client_.reset(new WebUserMediaClientMock(delegate_)); |
+ return user_media_client_.get(); |
} |
// Simulate a print by going into print mode and then exit straight away. |
-void WebTestProxyBase::printPage(WebLocalFrame* frame) |
-{ |
- WebSize pageSizeInPixels = webWidget()->size(); |
- if (pageSizeInPixels.isEmpty()) |
- return; |
- WebPrintParams printParams(pageSizeInPixels); |
- frame->printBegin(printParams); |
- frame->printEnd(); |
+void WebTestProxyBase::PrintPage(WebLocalFrame* frame) { |
+ WebSize pageSizeInPixels = web_widget_->size(); |
+ if (pageSizeInPixels.isEmpty()) return; |
+ WebPrintParams printParams(pageSizeInPixels); |
+ frame->printBegin(printParams); |
+ frame->printEnd(); |
} |
-WebNotificationPresenter* WebTestProxyBase::notificationPresenter() |
-{ |
- return m_testInterfaces->testRunner()->notification_presenter(); |
+WebNotificationPresenter* WebTestProxyBase::GetNotificationPresenter() { |
+ return test_interfaces_->testRunner()->notification_presenter(); |
} |
-WebMIDIClient* WebTestProxyBase::webMIDIClient() |
-{ |
- return midiClientMock(); |
+WebMIDIClient* WebTestProxyBase::GetWebMIDIClient() { |
+ return GetMIDIClientMock(); |
} |
-WebSpeechRecognizer* WebTestProxyBase::speechRecognizer() |
-{ |
- return speechRecognizerMock(); |
+WebSpeechRecognizer* WebTestProxyBase::GetSpeechRecognizer() { |
+ return GetSpeechRecognizerMock(); |
} |
-bool WebTestProxyBase::requestPointerLock() |
-{ |
- return m_testInterfaces->testRunner()->RequestPointerLock(); |
+bool WebTestProxyBase::RequestPointerLock() { |
+ return test_interfaces_->testRunner()->RequestPointerLock(); |
} |
-void WebTestProxyBase::requestPointerUnlock() |
-{ |
- m_testInterfaces->testRunner()->RequestPointerUnlock(); |
+void WebTestProxyBase::RequestPointerUnlock() { |
+ test_interfaces_->testRunner()->RequestPointerUnlock(); |
} |
-bool WebTestProxyBase::isPointerLocked() |
-{ |
- return m_testInterfaces->testRunner()->isPointerLocked(); |
+bool WebTestProxyBase::IsPointerLocked() { |
+ return test_interfaces_->testRunner()->isPointerLocked(); |
} |
-void WebTestProxyBase::didFocus() |
-{ |
- m_delegate->setFocus(this, true); |
-} |
+void WebTestProxyBase::DidFocus() { delegate_->setFocus(this, true); } |
-void WebTestProxyBase::didBlur() |
-{ |
- m_delegate->setFocus(this, false); |
-} |
+void WebTestProxyBase::DidBlur() { delegate_->setFocus(this, false); } |
-void WebTestProxyBase::setToolTipText(const WebString& text, WebTextDirection) |
-{ |
- m_testInterfaces->testRunner()->setToolTipText(text); |
+void WebTestProxyBase::SetToolTipText(const WebString& text, WebTextDirection) { |
+ test_interfaces_->testRunner()->setToolTipText(text); |
} |
-void WebTestProxyBase::didOpenChooser() |
-{ |
- m_chooserCount++; |
-} |
+void WebTestProxyBase::DidOpenChooser() { chooser_count_++; } |
-void WebTestProxyBase::didCloseChooser() |
-{ |
- m_chooserCount--; |
-} |
+void WebTestProxyBase::DidCloseChooser() { chooser_count_--; } |
-bool WebTestProxyBase::isChooserShown() |
-{ |
- return 0 < m_chooserCount; |
-} |
+bool WebTestProxyBase::IsChooserShown() { return 0 < chooser_count_; } |
-void WebTestProxyBase::loadURLExternally(WebLocalFrame* frame, const WebURLRequest& request, WebNavigationPolicy policy, const WebString& suggested_name) |
-{ |
- if (m_testInterfaces->testRunner()->shouldWaitUntilExternalURLLoad()) { |
- if (policy == WebNavigationPolicyDownload) { |
- m_delegate->printMessage(string("Downloading URL with suggested filename \"") + suggested_name.utf8() + "\"\n"); |
- } else { |
- m_delegate->printMessage(string("Loading URL externally - \"") + URLDescription(request.url()) + "\"\n"); |
- } |
- m_delegate->testFinished(); |
+void WebTestProxyBase::LoadURLExternally(WebLocalFrame* frame, |
+ const WebURLRequest& request, |
+ WebNavigationPolicy policy, |
+ const WebString& suggested_name) { |
+ if (test_interfaces_->testRunner()->shouldWaitUntilExternalURLLoad()) { |
+ if (policy == WebNavigationPolicyDownload) { |
+ delegate_->printMessage( |
+ string("Downloading URL with suggested filename \"") + |
+ suggested_name.utf8() + "\"\n"); |
+ } else { |
+ delegate_->printMessage(string("Loading URL externally - \"") + |
+ URLDescription(request.url()) + "\"\n"); |
} |
+ delegate_->testFinished(); |
+ } |
} |
-void WebTestProxyBase::didStartProvisionalLoad(WebLocalFrame* frame) |
-{ |
- if (!m_testInterfaces->testRunner()->topLoadingFrame()) |
- m_testInterfaces->testRunner()->setTopLoadingFrame(frame, false); |
+void WebTestProxyBase::DidStartProvisionalLoad(WebLocalFrame* frame) { |
+ if (!test_interfaces_->testRunner()->topLoadingFrame()) |
+ test_interfaces_->testRunner()->setTopLoadingFrame(frame, false); |
- if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
- printFrameDescription(m_delegate, frame); |
- m_delegate->printMessage(" - didStartProvisionalLoadForFrame\n"); |
- } |
+ if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { |
+ printFrameDescription(delegate_, frame); |
+ delegate_->printMessage(" - didStartProvisionalLoadForFrame\n"); |
+ } |
- if (m_testInterfaces->testRunner()->shouldDumpUserGestureInFrameLoadCallbacks()) |
- printFrameUserGestureStatus(m_delegate, frame, " - in didStartProvisionalLoadForFrame\n"); |
+ if (test_interfaces_->testRunner() |
+ ->shouldDumpUserGestureInFrameLoadCallbacks()) |
+ printFrameUserGestureStatus(delegate_, frame, |
+ " - in didStartProvisionalLoadForFrame\n"); |
} |
-void WebTestProxyBase::didReceiveServerRedirectForProvisionalLoad(WebLocalFrame* frame) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
- printFrameDescription(m_delegate, frame); |
- m_delegate->printMessage(" - didReceiveServerRedirectForProvisionalLoadForFrame\n"); |
- } |
+void WebTestProxyBase::DidReceiveServerRedirectForProvisionalLoad( |
+ WebLocalFrame* frame) { |
+ if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { |
+ printFrameDescription(delegate_, frame); |
+ delegate_->printMessage( |
+ " - didReceiveServerRedirectForProvisionalLoadForFrame\n"); |
+ } |
} |
-bool WebTestProxyBase::didFailProvisionalLoad(WebLocalFrame* frame, const WebURLError&) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
- printFrameDescription(m_delegate, frame); |
- m_delegate->printMessage(" - didFailProvisionalLoadWithError\n"); |
- } |
- locationChangeDone(frame); |
- return !frame->provisionalDataSource(); |
+bool WebTestProxyBase::DidFailProvisionalLoad(WebLocalFrame* frame, |
+ const WebURLError&) { |
+ if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { |
+ printFrameDescription(delegate_, frame); |
+ delegate_->printMessage(" - didFailProvisionalLoadWithError\n"); |
+ } |
+ LocationChangeDone(frame); |
+ return !frame->provisionalDataSource(); |
} |
-void WebTestProxyBase::didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistoryItem&, blink::WebHistoryCommitType) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
- printFrameDescription(m_delegate, frame); |
- m_delegate->printMessage(" - didCommitLoadForFrame\n"); |
- } |
+void WebTestProxyBase::DidCommitProvisionalLoad(WebLocalFrame* frame, |
+ const WebHistoryItem&, |
+ blink::WebHistoryCommitType) { |
+ if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { |
+ printFrameDescription(delegate_, frame); |
+ delegate_->printMessage(" - didCommitLoadForFrame\n"); |
+ } |
} |
-void WebTestProxyBase::didReceiveTitle(WebLocalFrame* frame, const WebString& title, WebTextDirection direction) |
-{ |
- WebCString title8 = title.utf8(); |
+void WebTestProxyBase::DidReceiveTitle(WebLocalFrame* frame, |
+ const WebString& title, |
+ WebTextDirection direction) { |
+ WebCString title8 = title.utf8(); |
- if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
- printFrameDescription(m_delegate, frame); |
- m_delegate->printMessage(string(" - didReceiveTitle: ") + title8.data() + "\n"); |
- } |
+ if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { |
+ printFrameDescription(delegate_, frame); |
+ delegate_->printMessage(string(" - didReceiveTitle: ") + title8.data() + |
+ "\n"); |
+ } |
- if (m_testInterfaces->testRunner()->shouldDumpTitleChanges()) |
- m_delegate->printMessage(string("TITLE CHANGED: '") + title8.data() + "'\n"); |
+ if (test_interfaces_->testRunner()->shouldDumpTitleChanges()) |
+ delegate_->printMessage(string("TITLE CHANGED: '") + title8.data() + "'\n"); |
} |
-void WebTestProxyBase::didChangeIcon(WebLocalFrame* frame, WebIconURL::Type) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpIconChanges()) { |
- printFrameDescription(m_delegate, frame); |
- m_delegate->printMessage(string(" - didChangeIcons\n")); |
- } |
+void WebTestProxyBase::DidChangeIcon(WebLocalFrame* frame, WebIconURL::Type) { |
+ if (test_interfaces_->testRunner()->shouldDumpIconChanges()) { |
+ printFrameDescription(delegate_, frame); |
+ delegate_->printMessage(string(" - didChangeIcons\n")); |
+ } |
} |
-void WebTestProxyBase::didFinishDocumentLoad(WebLocalFrame* frame) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
- printFrameDescription(m_delegate, frame); |
- m_delegate->printMessage(" - didFinishDocumentLoadForFrame\n"); |
- } else { |
- unsigned pendingUnloadEvents = frame->unloadListenerCount(); |
- if (pendingUnloadEvents) { |
- printFrameDescription(m_delegate, frame); |
- char buffer[100]; |
- snprintf(buffer, sizeof(buffer), " - has %u onunload handler(s)\n", pendingUnloadEvents); |
- m_delegate->printMessage(buffer); |
- } |
+void WebTestProxyBase::DidFinishDocumentLoad(WebLocalFrame* frame) { |
+ if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { |
+ printFrameDescription(delegate_, frame); |
+ delegate_->printMessage(" - didFinishDocumentLoadForFrame\n"); |
+ } else { |
+ unsigned pendingUnloadEvents = frame->unloadListenerCount(); |
+ if (pendingUnloadEvents) { |
+ printFrameDescription(delegate_, frame); |
+ char buffer[100]; |
+ snprintf(buffer, sizeof(buffer), " - has %u onunload handler(s)\n", |
+ pendingUnloadEvents); |
+ delegate_->printMessage(buffer); |
} |
+ } |
} |
-void WebTestProxyBase::didHandleOnloadEvents(WebLocalFrame* frame) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
- printFrameDescription(m_delegate, frame); |
- m_delegate->printMessage(" - didHandleOnloadEventsForFrame\n"); |
- } |
+void WebTestProxyBase::DidHandleOnloadEvents(WebLocalFrame* frame) { |
+ if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { |
+ printFrameDescription(delegate_, frame); |
+ delegate_->printMessage(" - didHandleOnloadEventsForFrame\n"); |
+ } |
} |
-void WebTestProxyBase::didFailLoad(WebLocalFrame* frame, const WebURLError&) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
- printFrameDescription(m_delegate, frame); |
- m_delegate->printMessage(" - didFailLoadWithError\n"); |
- } |
- locationChangeDone(frame); |
+void WebTestProxyBase::DidFailLoad(WebLocalFrame* frame, const WebURLError&) { |
+ if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { |
+ printFrameDescription(delegate_, frame); |
+ delegate_->printMessage(" - didFailLoadWithError\n"); |
+ } |
+ LocationChangeDone(frame); |
} |
-void WebTestProxyBase::didFinishLoad(WebLocalFrame* frame) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
- printFrameDescription(m_delegate, frame); |
- m_delegate->printMessage(" - didFinishLoadForFrame\n"); |
- } |
- locationChangeDone(frame); |
+void WebTestProxyBase::DidFinishLoad(WebLocalFrame* frame) { |
+ if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { |
+ printFrameDescription(delegate_, frame); |
+ delegate_->printMessage(" - didFinishLoadForFrame\n"); |
+ } |
+ LocationChangeDone(frame); |
} |
-void WebTestProxyBase::didDetectXSS(WebLocalFrame*, const WebURL&, bool) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) |
- m_delegate->printMessage("didDetectXSS\n"); |
+void WebTestProxyBase::DidDetectXSS(WebLocalFrame*, const WebURL&, bool) { |
+ if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) |
+ delegate_->printMessage("didDetectXSS\n"); |
} |
-void WebTestProxyBase::didDispatchPingLoader(WebLocalFrame*, const WebURL& url) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpPingLoaderCallbacks()) |
- m_delegate->printMessage(string("PingLoader dispatched to '") + URLDescription(url).c_str() + "'.\n"); |
+void WebTestProxyBase::DidDispatchPingLoader(WebLocalFrame*, |
+ const WebURL& url) { |
+ if (test_interfaces_->testRunner()->shouldDumpPingLoaderCallbacks()) |
+ delegate_->printMessage(string("PingLoader dispatched to '") + |
+ URLDescription(url).c_str() + "'.\n"); |
} |
-void WebTestProxyBase::willRequestResource(WebLocalFrame* frame, const blink::WebCachedURLRequest& request) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpResourceRequestCallbacks()) { |
- printFrameDescription(m_delegate, frame); |
- m_delegate->printMessage(string(" - ") + request.initiatorName().utf8().data()); |
- m_delegate->printMessage(string(" requested '") + URLDescription(request.urlRequest().url()).c_str() + "'\n"); |
- } |
+void WebTestProxyBase::WillRequestResource( |
+ WebLocalFrame* frame, const blink::WebCachedURLRequest& request) { |
+ if (test_interfaces_->testRunner()->shouldDumpResourceRequestCallbacks()) { |
+ printFrameDescription(delegate_, frame); |
+ delegate_->printMessage(string(" - ") + |
+ request.initiatorName().utf8().data()); |
+ delegate_->printMessage(string(" requested '") + |
+ URLDescription(request.urlRequest().url()).c_str() + |
+ "'\n"); |
+ } |
} |
-void WebTestProxyBase::willSendRequest(WebLocalFrame*, unsigned identifier, blink::WebURLRequest& request, const blink::WebURLResponse& redirectResponse) |
-{ |
- // Need to use GURL for host() and SchemeIs() |
- GURL url = request.url(); |
- string requestURL = url.possibly_invalid_spec(); |
+void WebTestProxyBase::WillSendRequest( |
+ WebLocalFrame*, unsigned identifier, blink::WebURLRequest& request, |
+ const blink::WebURLResponse& redirectResponse) { |
+ // Need to use GURL for host() and SchemeIs() |
+ GURL url = request.url(); |
+ string requestURL = url.possibly_invalid_spec(); |
- GURL mainDocumentURL = request.firstPartyForCookies(); |
+ GURL mainDocumentURL = request.firstPartyForCookies(); |
- if (redirectResponse.isNull() && (m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks() || m_testInterfaces->testRunner()->shouldDumpResourcePriorities())) { |
- DCHECK(m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end()); |
- m_resourceIdentifierMap[identifier] = descriptionSuitableForTestResult(requestURL); |
- } |
+ if (redirectResponse.isNull() && |
+ (test_interfaces_->testRunner()->shouldDumpResourceLoadCallbacks() || |
+ test_interfaces_->testRunner()->shouldDumpResourcePriorities())) { |
+ DCHECK(resource_identifier_map_.find(identifier) == |
+ resource_identifier_map_.end()); |
+ resource_identifier_map_[identifier] = |
+ descriptionSuitableForTestResult(requestURL); |
+ } |
- if (m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) { |
- if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end()) |
- m_delegate->printMessage("<unknown>"); |
- else |
- m_delegate->printMessage(m_resourceIdentifierMap[identifier]); |
- m_delegate->printMessage(" - willSendRequest <NSURLRequest URL "); |
- m_delegate->printMessage(descriptionSuitableForTestResult(requestURL).c_str()); |
- m_delegate->printMessage(", main document URL "); |
- m_delegate->printMessage(URLDescription(mainDocumentURL).c_str()); |
- m_delegate->printMessage(", http method "); |
- m_delegate->printMessage(request.httpMethod().utf8().data()); |
- m_delegate->printMessage("> redirectResponse "); |
- printResponseDescription(m_delegate, redirectResponse); |
- m_delegate->printMessage("\n"); |
- } |
+ if (test_interfaces_->testRunner()->shouldDumpResourceLoadCallbacks()) { |
+ if (resource_identifier_map_.find(identifier) == |
+ resource_identifier_map_.end()) |
+ delegate_->printMessage("<unknown>"); |
+ else |
+ delegate_->printMessage(resource_identifier_map_[identifier]); |
+ delegate_->printMessage(" - willSendRequest <NSURLRequest URL "); |
+ delegate_->printMessage( |
+ descriptionSuitableForTestResult(requestURL).c_str()); |
+ delegate_->printMessage(", main document URL "); |
+ delegate_->printMessage(URLDescription(mainDocumentURL).c_str()); |
+ delegate_->printMessage(", http method "); |
+ delegate_->printMessage(request.httpMethod().utf8().data()); |
+ delegate_->printMessage("> redirectResponse "); |
+ printResponseDescription(delegate_, redirectResponse); |
+ delegate_->printMessage("\n"); |
+ } |
- if (m_testInterfaces->testRunner()->shouldDumpResourcePriorities()) { |
- m_delegate->printMessage(descriptionSuitableForTestResult(requestURL).c_str()); |
- m_delegate->printMessage(" has priority "); |
- m_delegate->printMessage(PriorityDescription(request.priority())); |
- m_delegate->printMessage("\n"); |
- } |
+ if (test_interfaces_->testRunner()->shouldDumpResourcePriorities()) { |
+ delegate_->printMessage( |
+ descriptionSuitableForTestResult(requestURL).c_str()); |
+ delegate_->printMessage(" has priority "); |
+ delegate_->printMessage(PriorityDescription(request.priority())); |
+ delegate_->printMessage("\n"); |
+ } |
- if (m_testInterfaces->testRunner()->httpHeadersToClear()) { |
- const set<string> *clearHeaders = m_testInterfaces->testRunner()->httpHeadersToClear(); |
- for (set<string>::const_iterator header = clearHeaders->begin(); header != clearHeaders->end(); ++header) |
- request.clearHTTPHeaderField(WebString::fromUTF8(*header)); |
- } |
+ if (test_interfaces_->testRunner()->httpHeadersToClear()) { |
+ const set<string>* clearHeaders = |
+ test_interfaces_->testRunner()->httpHeadersToClear(); |
+ for (set<string>::const_iterator header = clearHeaders->begin(); |
+ header != clearHeaders->end(); ++header) |
+ request.clearHTTPHeaderField(WebString::fromUTF8(*header)); |
+ } |
- string host = url.host(); |
- if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https"))) { |
- if (!isLocalhost(host) && !hostIsUsedBySomeTestsToGenerateError(host) |
- && ((!mainDocumentURL.SchemeIs("http") && !mainDocumentURL.SchemeIs("https")) || isLocalhost(mainDocumentURL.host())) |
- && !m_delegate->allowExternalPages()) { |
- m_delegate->printMessage(string("Blocked access to external URL ") + requestURL + "\n"); |
- blockRequest(request); |
- return; |
- } |
+ string host = url.host(); |
+ if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https"))) { |
+ if (!isLocalhost(host) && !hostIsUsedBySomeTestsToGenerateError(host) && |
+ ((!mainDocumentURL.SchemeIs("http") && |
+ !mainDocumentURL.SchemeIs("https")) || |
+ isLocalhost(mainDocumentURL.host())) && |
+ !delegate_->allowExternalPages()) { |
+ delegate_->printMessage(string("Blocked access to external URL ") + |
+ requestURL + "\n"); |
+ blockRequest(request); |
+ return; |
} |
+ } |
- // Set the new substituted URL. |
- request.setURL(m_delegate->rewriteLayoutTestsURL(request.url().spec())); |
+ // Set the new substituted URL. |
+ request.setURL(delegate_->rewriteLayoutTestsURL(request.url().spec())); |
} |
-void WebTestProxyBase::didReceiveResponse(WebLocalFrame*, unsigned identifier, const blink::WebURLResponse& response) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) { |
- if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end()) |
- m_delegate->printMessage("<unknown>"); |
- else |
- m_delegate->printMessage(m_resourceIdentifierMap[identifier]); |
- m_delegate->printMessage(" - didReceiveResponse "); |
- printResponseDescription(m_delegate, response); |
- m_delegate->printMessage("\n"); |
- } |
- if (m_testInterfaces->testRunner()->shouldDumpResourceResponseMIMETypes()) { |
- GURL url = response.url(); |
- WebString mimeType = response.mimeType(); |
- m_delegate->printMessage(url.ExtractFileName()); |
- m_delegate->printMessage(" has MIME type "); |
- // Simulate NSURLResponse's mapping of empty/unknown MIME types to application/octet-stream |
- m_delegate->printMessage(mimeType.isEmpty() ? "application/octet-stream" : mimeType.utf8().data()); |
- m_delegate->printMessage("\n"); |
- } |
+void WebTestProxyBase::DidReceiveResponse( |
+ WebLocalFrame*, unsigned identifier, |
+ const blink::WebURLResponse& response) { |
+ if (test_interfaces_->testRunner()->shouldDumpResourceLoadCallbacks()) { |
+ if (resource_identifier_map_.find(identifier) == |
+ resource_identifier_map_.end()) |
+ delegate_->printMessage("<unknown>"); |
+ else |
+ delegate_->printMessage(resource_identifier_map_[identifier]); |
+ delegate_->printMessage(" - didReceiveResponse "); |
+ printResponseDescription(delegate_, response); |
+ delegate_->printMessage("\n"); |
+ } |
+ if (test_interfaces_->testRunner()->shouldDumpResourceResponseMIMETypes()) { |
+ GURL url = response.url(); |
+ WebString mimeType = response.mimeType(); |
+ delegate_->printMessage(url.ExtractFileName()); |
+ delegate_->printMessage(" has MIME type "); |
+ // Simulate NSURLResponse's mapping of empty/unknown MIME types to |
+ // application/octet-stream |
+ delegate_->printMessage(mimeType.isEmpty() ? "application/octet-stream" |
+ : mimeType.utf8().data()); |
+ delegate_->printMessage("\n"); |
+ } |
} |
-void WebTestProxyBase::didChangeResourcePriority(WebLocalFrame*, unsigned identifier, const blink::WebURLRequest::Priority& priority, int intra_priority_value) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpResourcePriorities()) { |
- if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end()) |
- m_delegate->printMessage("<unknown>"); |
- else |
- m_delegate->printMessage(m_resourceIdentifierMap[identifier]); |
- m_delegate->printMessage(" changed priority to "); |
- m_delegate->printMessage(PriorityDescription(priority)); |
- char buffer[64]; |
- snprintf(buffer, sizeof(buffer), ", intra_priority %d", intra_priority_value); |
- m_delegate->printMessage(buffer); |
- m_delegate->printMessage("\n"); |
- } |
+void WebTestProxyBase::DidChangeResourcePriority( |
+ WebLocalFrame*, unsigned identifier, |
+ const blink::WebURLRequest::Priority& priority, int intra_priority_value) { |
+ if (test_interfaces_->testRunner()->shouldDumpResourcePriorities()) { |
+ if (resource_identifier_map_.find(identifier) == |
+ resource_identifier_map_.end()) |
+ delegate_->printMessage("<unknown>"); |
+ else |
+ delegate_->printMessage(resource_identifier_map_[identifier]); |
+ delegate_->printMessage(" changed priority to "); |
+ delegate_->printMessage(PriorityDescription(priority)); |
+ char buffer[64]; |
+ snprintf(buffer, sizeof(buffer), ", intra_priority %d", |
+ intra_priority_value); |
+ delegate_->printMessage(buffer); |
+ delegate_->printMessage("\n"); |
+ } |
} |
-void WebTestProxyBase::didFinishResourceLoad(WebLocalFrame*, unsigned identifier) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) { |
- if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end()) |
- m_delegate->printMessage("<unknown>"); |
- else |
- m_delegate->printMessage(m_resourceIdentifierMap[identifier]); |
- m_delegate->printMessage(" - didFinishLoading\n"); |
- } |
- m_resourceIdentifierMap.erase(identifier); |
+void WebTestProxyBase::DidFinishResourceLoad(WebLocalFrame*, |
+ unsigned identifier) { |
+ if (test_interfaces_->testRunner()->shouldDumpResourceLoadCallbacks()) { |
+ if (resource_identifier_map_.find(identifier) == |
+ resource_identifier_map_.end()) |
+ delegate_->printMessage("<unknown>"); |
+ else |
+ delegate_->printMessage(resource_identifier_map_[identifier]); |
+ delegate_->printMessage(" - didFinishLoading\n"); |
+ } |
+ resource_identifier_map_.erase(identifier); |
} |
-void WebTestProxyBase::didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine) |
-{ |
- // This matches win DumpRenderTree's UIDelegate.cpp. |
- if (!m_logConsoleOutput) |
- return; |
- string level; |
- switch (message.level) { |
+void WebTestProxyBase::DidAddMessageToConsole(const WebConsoleMessage& message, |
+ const WebString& sourceName, |
+ unsigned sourceLine) { |
+ // This matches win DumpRenderTree's UIDelegate.cpp. |
+ if (!log_console_output_) return; |
+ string level; |
+ switch (message.level) { |
case WebConsoleMessage::LevelDebug: |
- level = "DEBUG"; |
- break; |
+ level = "DEBUG"; |
+ break; |
case WebConsoleMessage::LevelLog: |
- level = "MESSAGE"; |
- break; |
+ level = "MESSAGE"; |
+ break; |
case WebConsoleMessage::LevelInfo: |
- level = "INFO"; |
- break; |
+ level = "INFO"; |
+ break; |
case WebConsoleMessage::LevelWarning: |
- level = "WARNING"; |
- break; |
+ level = "WARNING"; |
+ break; |
case WebConsoleMessage::LevelError: |
- level = "ERROR"; |
- break; |
- } |
- m_delegate->printMessage(string("CONSOLE ") + level + ": "); |
- if (sourceLine) { |
- char buffer[40]; |
- snprintf(buffer, sizeof(buffer), "line %d: ", sourceLine); |
- m_delegate->printMessage(buffer); |
- } |
- if (!message.text.isEmpty()) { |
- string newMessage; |
- newMessage = message.text.utf8(); |
- size_t fileProtocol = newMessage.find("file://"); |
- if (fileProtocol != string::npos) { |
- newMessage = newMessage.substr(0, fileProtocol) |
- + urlSuitableForTestResult(newMessage.substr(fileProtocol)); |
- } |
- m_delegate->printMessage(newMessage); |
- } |
- m_delegate->printMessage(string("\n")); |
-} |
- |
-void WebTestProxyBase::locationChangeDone(WebFrame* frame) |
-{ |
- if (frame != m_testInterfaces->testRunner()->topLoadingFrame()) |
- return; |
- m_testInterfaces->testRunner()->setTopLoadingFrame(frame, true); |
-} |
- |
-WebNavigationPolicy WebTestProxyBase::decidePolicyForNavigation(WebLocalFrame*, WebDataSource::ExtraData*, const WebURLRequest& request, WebNavigationType type, WebNavigationPolicy defaultPolicy, bool isRedirect) |
-{ |
- WebNavigationPolicy result; |
- if (!m_testInterfaces->testRunner()->policyDelegateEnabled()) |
- return defaultPolicy; |
- |
- m_delegate->printMessage(string("Policy delegate: attempt to load ") + URLDescription(request.url()) + " with navigation type '" + webNavigationTypeToString(type) + "'\n"); |
- if (m_testInterfaces->testRunner()->policyDelegateIsPermissive()) |
- result = blink::WebNavigationPolicyCurrentTab; |
- else |
- result = blink::WebNavigationPolicyIgnore; |
- |
- if (m_testInterfaces->testRunner()->policyDelegateShouldNotifyDone()) |
- m_testInterfaces->testRunner()->policyDelegateDone(); |
- return result; |
-} |
- |
-bool WebTestProxyBase::willCheckAndDispatchMessageEvent(WebLocalFrame*, WebFrame*, WebSecurityOrigin, WebDOMMessageEvent) |
-{ |
- if (m_testInterfaces->testRunner()->shouldInterceptPostMessage()) { |
- m_delegate->printMessage("intercepted postMessage\n"); |
- return true; |
+ level = "ERROR"; |
+ break; |
+ } |
+ delegate_->printMessage(string("CONSOLE ") + level + ": "); |
+ if (sourceLine) { |
+ char buffer[40]; |
+ snprintf(buffer, sizeof(buffer), "line %d: ", sourceLine); |
+ delegate_->printMessage(buffer); |
+ } |
+ if (!message.text.isEmpty()) { |
+ string newMessage; |
+ newMessage = message.text.utf8(); |
+ size_t fileProtocol = newMessage.find("file://"); |
+ if (fileProtocol != string::npos) { |
+ newMessage = newMessage.substr(0, fileProtocol) + |
+ urlSuitableForTestResult(newMessage.substr(fileProtocol)); |
} |
+ delegate_->printMessage(newMessage); |
+ } |
+ delegate_->printMessage(string("\n")); |
+} |
+ |
+void WebTestProxyBase::LocationChangeDone(WebFrame* frame) { |
+ if (frame != test_interfaces_->testRunner()->topLoadingFrame()) return; |
+ test_interfaces_->testRunner()->setTopLoadingFrame(frame, true); |
+} |
+ |
+WebNavigationPolicy WebTestProxyBase::DecidePolicyForNavigation( |
+ WebLocalFrame*, WebDataSource::ExtraData*, const WebURLRequest& request, |
+ WebNavigationType type, WebNavigationPolicy defaultPolicy, |
+ bool isRedirect) { |
+ WebNavigationPolicy result; |
+ if (!test_interfaces_->testRunner()->policyDelegateEnabled()) |
+ return defaultPolicy; |
+ |
+ delegate_->printMessage(string("Policy delegate: attempt to load ") + |
+ URLDescription(request.url()) + |
+ " with navigation type '" + |
+ webNavigationTypeToString(type) + "'\n"); |
+ if (test_interfaces_->testRunner()->policyDelegateIsPermissive()) |
+ result = blink::WebNavigationPolicyCurrentTab; |
+ else |
+ result = blink::WebNavigationPolicyIgnore; |
+ |
+ if (test_interfaces_->testRunner()->policyDelegateShouldNotifyDone()) |
+ test_interfaces_->testRunner()->policyDelegateDone(); |
+ return result; |
+} |
+ |
+bool WebTestProxyBase::WillCheckAndDispatchMessageEvent(WebLocalFrame*, |
+ WebFrame*, |
+ WebSecurityOrigin, |
+ WebDOMMessageEvent) { |
+ if (test_interfaces_->testRunner()->shouldInterceptPostMessage()) { |
+ delegate_->printMessage("intercepted postMessage\n"); |
+ return true; |
+ } |
- return false; |
+ return false; |
} |
-void WebTestProxyBase::postSpellCheckEvent(const WebString& eventName) |
-{ |
- if (m_testInterfaces->testRunner()->shouldDumpSpellCheckCallbacks()) { |
- m_delegate->printMessage(string("SpellCheckEvent: ") + eventName.utf8().data() + "\n"); |
- } |
+void WebTestProxyBase::PostSpellCheckEvent(const WebString& eventName) { |
+ if (test_interfaces_->testRunner()->shouldDumpSpellCheckCallbacks()) { |
+ delegate_->printMessage(string("SpellCheckEvent: ") + |
+ eventName.utf8().data() + "\n"); |
+ } |
} |
-void WebTestProxyBase::resetInputMethod() |
-{ |
- // If a composition text exists, then we need to let the browser process |
- // to cancel the input method's ongoing composition session. |
- if (m_webWidget) |
- m_webWidget->confirmComposition(); |
+void WebTestProxyBase::ResetInputMethod() { |
+ // If a composition text exists, then we need to let the browser process |
+ // to cancel the input method's ongoing composition session. |
+ if (web_widget_) web_widget_->confirmComposition(); |
} |
} // namespace content |