diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp')
-rw-r--r-- | WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp index 4413ff2..b4e3764 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp @@ -39,6 +39,7 @@ #include "public/WebConsoleMessage.h" #include "public/WebDocument.h" #include "public/WebFrame.h" +#include "public/WebGeolocationServiceMock.h" #include "public/WebInputElement.h" #include "public/WebKit.h" #include "public/WebNotificationPresenter.h" @@ -159,6 +160,11 @@ LayoutTestController::LayoutTestController(TestShell* shell) bindMethod("setTimelineProfilingEnabled", &LayoutTestController::setTimelineProfilingEnabled); bindMethod("evaluateInWebInspector", &LayoutTestController::evaluateInWebInspector); bindMethod("forceRedSelectionColors", &LayoutTestController::forceRedSelectionColors); + bindMethod("setEditingBehavior", &LayoutTestController::setEditingBehavior); + + bindMethod("setGeolocationPermission", &LayoutTestController::setGeolocationPermission); + bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition); + bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError); // The fallback method is called when an unknown method is invoked. bindFallbackMethod(&LayoutTestController::fallbackMethod); @@ -477,6 +483,7 @@ void LayoutTestController::reset() m_stopProvisionalFrameLoads = false; m_globalFlag.set(false); m_webHistoryItemCount.set(0); + m_userStyleSheetLocation = WebURL(); webkit_support::SetAcceptAllCookies(false); WebSecurityPolicy::resetOriginAccessWhitelists(); @@ -852,7 +859,7 @@ void LayoutTestController::grantDesktopNotificationPermission(const CppArgumentL result->set(false); return; } - m_shell->notificationPresenter()->grantPermission(WebString::fromUTF8(arguments[0].toString())); + m_shell->notificationPresenter()->grantPermission(cppVariantToWebString(arguments[0])); result->set(true); } @@ -955,7 +962,7 @@ void LayoutTestController::setXSSAuditorEnabled(const CppArgumentList& arguments void LayoutTestController::evaluateScriptInIsolatedWorld(const CppArgumentList& arguments, CppVariant* result) { if (arguments.size() >= 2 && arguments[0].isNumber() && arguments[1].isString()) { - WebScriptSource source(WebString::fromUTF8(arguments[1].toString())); + WebScriptSource source(cppVariantToWebString(arguments[1])); // This relies on the iframe focusing itself when it loads. This is a bit // sketchy, but it seems to be what other tests do. m_shell->webView()->focusedFrame()->executeScriptInIsolatedWorld(arguments[0].toInt32(), &source, 1, 1); @@ -1110,8 +1117,8 @@ void LayoutTestController::addOriginAccessWhitelistEntry(const CppArgumentList& WebSecurityPolicy::addOriginAccessWhitelistEntry( url, - WebString::fromUTF8(arguments[1].toString()), - WebString::fromUTF8(arguments[2].toString()), + cppVariantToWebString(arguments[1]), + cppVariantToWebString(arguments[2]), arguments[3].toBoolean()); } @@ -1129,8 +1136,8 @@ void LayoutTestController::removeOriginAccessWhitelistEntry(const CppArgumentLis WebSecurityPolicy::removeOriginAccessWhitelistEntry( url, - WebString::fromUTF8(arguments[1].toString()), - WebString::fromUTF8(arguments[2].toString()), + cppVariantToWebString(arguments[1]), + cppVariantToWebString(arguments[2]), arguments[3].toBoolean()); } @@ -1261,7 +1268,7 @@ void LayoutTestController::addUserScript(const CppArgumentList& arguments, CppVa result->setNull(); if (arguments.size() < 2 || !arguments[0].isString() || !arguments[1].isBool()) return; - m_shell->webView()->addUserScript(WebString::fromUTF8(arguments[0].toString()), arguments[1].toBoolean()); + m_shell->webView()->addUserScript(cppVariantToWebString(arguments[0]), arguments[1].toBoolean()); } void LayoutTestController::addUserStyleSheet(const CppArgumentList& arguments, CppVariant* result) @@ -1269,5 +1276,41 @@ void LayoutTestController::addUserStyleSheet(const CppArgumentList& arguments, C result->setNull(); if (arguments.size() < 1 || !arguments[0].isString()) return; - m_shell->webView()->addUserStyleSheet(WebString::fromUTF8(arguments[0].toString())); + m_shell->webView()->addUserStyleSheet(cppVariantToWebString(arguments[0])); +} + +void LayoutTestController::setEditingBehavior(const CppArgumentList& arguments, CppVariant* results) +{ + WebSettings* settings = m_shell->webView()->settings(); + string key = arguments[0].toString(); + if (key == "mac") + settings->setEditingBehavior(WebSettings::EditingBehaviorMac); + else if (key == "win") + settings->setEditingBehavior(WebSettings::EditingBehaviorWin); + else + logErrorToConsole("Passed invalid editing behavior. Should be 'mac' or 'win'."); +} + +void LayoutTestController::setGeolocationPermission(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + if (arguments.size() < 1 || !arguments[0].isBool()) + return; + WebGeolocationServiceMock::setMockGeolocationPermission(arguments[0].toBoolean()); +} + +void LayoutTestController::setMockGeolocationPosition(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + if (arguments.size() < 3 || !arguments[0].isNumber() || !arguments[1].isNumber() || !arguments[2].isNumber()) + return; + WebGeolocationServiceMock::setMockGeolocationPosition(arguments[0].toDouble(), arguments[1].toDouble(), arguments[2].toDouble()); +} + +void LayoutTestController::setMockGeolocationError(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + if (arguments.size() < 2 || !arguments[0].isInt32() || !arguments[1].isString()) + return; + WebGeolocationServiceMock::setMockGeolocationError(arguments[0].toInt32(), cppVariantToWebString(arguments[1])); } |