diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-08 19:08:45 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-08 19:08:45 +0000 |
commit | 07d08a3efc70736c49ac8db48f9bf1df8e37b8fa (patch) | |
tree | 07d8c5693756ba3982823dda040a56e3b01ca1e0 | |
parent | c9e4322d0b2088b55ee242c6adf889143fc49aac (diff) | |
download | chromium_src-07d08a3efc70736c49ac8db48f9bf1df8e37b8fa.zip chromium_src-07d08a3efc70736c49ac8db48f9bf1df8e37b8fa.tar.gz chromium_src-07d08a3efc70736c49ac8db48f9bf1df8e37b8fa.tar.bz2 |
Remove most of layout test controller.
waitUntilDone/notifyDone are still there for a couple
test_shell_tests.
Review URL: http://codereview.chromium.org/6413033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74140 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller.cc | 1150 | ||||
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller.h | 246 | ||||
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller_unittest.cc | 45 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.gypi | 1 |
4 files changed, 1 insertions, 1441 deletions
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc index 6a55e1a..a5da7b2 100644 --- a/webkit/tools/test_shell/layout_test_controller.cc +++ b/webkit/tools/test_shell/layout_test_controller.cc @@ -65,13 +65,8 @@ bool LayoutTestController::accepts_editing_ = true; bool LayoutTestController::wait_until_done_ = false; bool LayoutTestController::can_open_windows_ = false; bool LayoutTestController::close_remaining_windows_ = true; -bool LayoutTestController::test_repaint_ = false; -bool LayoutTestController::sweep_horizontally_ = false; -bool LayoutTestController::should_add_file_to_pasteboard_ = false; bool LayoutTestController::stop_provisional_frame_loads_ = false; LayoutTestController::WorkQueue LayoutTestController::work_queue_; -CppVariant LayoutTestController::globalFlag_; -CppVariant LayoutTestController::webHistoryItemCount_; LayoutTestController::LayoutTestController(TestShell* shell) : ALLOW_THIS_IN_INITIALIZER_LIST(timeout_factory_(this)) { @@ -85,113 +80,11 @@ LayoutTestController::LayoutTestController(TestShell* shell) : // they will use when called by JavaScript. The actual binding of those // names to their methods will be done by calling BindToJavaScript() (defined // by CppBoundClass, the parent to LayoutTestController). - BindMethod("setAcceptsEditing", &LayoutTestController::setAcceptsEditing); BindMethod("waitUntilDone", &LayoutTestController::waitUntilDone); BindMethod("notifyDone", &LayoutTestController::notifyDone); - BindMethod("queueReload", &LayoutTestController::queueReload); - BindMethod("queueLoadingScript", &LayoutTestController::queueLoadingScript); - BindMethod("queueNonLoadingScript", &LayoutTestController::queueNonLoadingScript); - BindMethod("queueLoad", &LayoutTestController::queueLoad); - BindMethod("queueBackNavigation", &LayoutTestController::queueBackNavigation); - BindMethod("queueForwardNavigation", &LayoutTestController::queueForwardNavigation); - BindMethod("windowCount", &LayoutTestController::windowCount); - BindMethod("setCanOpenWindows", &LayoutTestController::setCanOpenWindows); - BindMethod("setCloseRemainingWindowsWhenComplete", &LayoutTestController::setCloseRemainingWindowsWhenComplete); - BindMethod("objCIdentityIsEqual", &LayoutTestController::objCIdentityIsEqual); - BindMethod("setAlwaysAcceptCookies", &LayoutTestController::setAlwaysAcceptCookies); - BindMethod("showWebInspector", &LayoutTestController::showWebInspector); - BindMethod("closeWebInspector", &LayoutTestController::closeWebInspector); - BindMethod("setWindowIsKey", &LayoutTestController::setWindowIsKey); - BindMethod("setTabKeyCyclesThroughElements", &LayoutTestController::setTabKeyCyclesThroughElements); - BindMethod("setUserStyleSheetLocation", &LayoutTestController::setUserStyleSheetLocation); - BindMethod("setUserStyleSheetEnabled", &LayoutTestController::setUserStyleSheetEnabled); - BindMethod("setAuthorAndUserStylesEnabled", &LayoutTestController::setAuthorAndUserStylesEnabled); - BindMethod("pathToLocalResource", &LayoutTestController::pathToLocalResource); - BindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteboardOnDrag); - BindMethod("execCommand", &LayoutTestController::execCommand); - BindMethod("isCommandEnabled", &LayoutTestController::isCommandEnabled); - BindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingEnabled); - BindMethod("setStopProvisionalFrameLoads", &LayoutTestController::setStopProvisionalFrameLoads); - BindMethod("setSmartInsertDeleteEnabled", &LayoutTestController::setSmartInsertDeleteEnabled); - BindMethod("setSelectTrailingWhitespaceEnabled", &LayoutTestController::setSelectTrailingWhitespaceEnabled); - BindMethod("pauseAnimationAtTimeOnElementWithId", &LayoutTestController::pauseAnimationAtTimeOnElementWithId); - BindMethod("pauseTransitionAtTimeOnElementWithId", &LayoutTestController::pauseTransitionAtTimeOnElementWithId); - BindMethod("suspendAnimations", &LayoutTestController::suspendAnimations); - BindMethod("resumeAnimations", &LayoutTestController::resumeAnimations); - BindMethod("elementDoesAutoCompleteForElementWithId", &LayoutTestController::elementDoesAutoCompleteForElementWithId); - BindMethod("numberOfActiveAnimations", &LayoutTestController::numberOfActiveAnimations); - BindMethod("disableImageLoading", &LayoutTestController::disableImageLoading); - BindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEnabled); - BindMethod("setCustomPolicyDelegate", &LayoutTestController::setCustomPolicyDelegate); - BindMethod("setScrollbarPolicy", &LayoutTestController::setScrollbarPolicy); - BindMethod("waitForPolicyDelegate", &LayoutTestController::waitForPolicyDelegate); - BindMethod("setWillSendRequestClearHeader", &LayoutTestController::setWillSendRequestClearHeader); - BindMethod("setWillSendRequestReturnsNullOnRedirect", &LayoutTestController::setWillSendRequestReturnsNullOnRedirect); - BindMethod("setWillSendRequestReturnsNull", &LayoutTestController::setWillSendRequestReturnsNull); - BindMethod("addOriginAccessWhitelistEntry", - &LayoutTestController::addOriginAccessWhitelistEntry); - BindMethod("removeOriginAccessWhitelistEntry", - &LayoutTestController::removeOriginAccessWhitelistEntry); - BindMethod("clearAllDatabases", &LayoutTestController::clearAllDatabases); - BindMethod("setDatabaseQuota", &LayoutTestController::setDatabaseQuota); - BindMethod("setPOSIXLocale", &LayoutTestController::setPOSIXLocale); - BindMethod("counterValueForElementById", &LayoutTestController::counterValueForElementById); - BindMethod("addUserScript", &LayoutTestController::addUserScript); - BindMethod("addUserStyleSheet", &LayoutTestController::addUserStyleSheet); - BindMethod("pageNumberForElementById", &LayoutTestController::pageNumberForElementById); - BindMethod("numberOfPages", &LayoutTestController::numberOfPages); - BindMethod("grantDesktopNotificationPermission", &LayoutTestController::grantDesktopNotificationPermission); - BindMethod("setDomainRelaxationForbiddenForURLScheme", &LayoutTestController::setDomainRelaxationForbiddenForURLScheme); - BindMethod("sampleSVGAnimationForElementAtTime", &LayoutTestController::sampleSVGAnimationForElementAtTime); - BindMethod("hasSpellingMarker", &LayoutTestController::hasSpellingMarker); - - // The following are stubs. - BindMethod("setMainFrameIsFirstResponder", &LayoutTestController::setMainFrameIsFirstResponder); - BindMethod("display", &LayoutTestController::display); - BindMethod("testRepaint", &LayoutTestController::testRepaint); - BindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHorizontally); - BindMethod("clearBackForwardList", &LayoutTestController::clearBackForwardList); - BindMethod("keepWebHistory", &LayoutTestController::keepWebHistory); - BindMethod("layerTreeAsText", &LayoutTestController::layerTreeAsText); - BindMethod("storeWebScriptObject", &LayoutTestController::storeWebScriptObject); - BindMethod("accessStoredWebScriptObject", &LayoutTestController::accessStoredWebScriptObject); - BindMethod("objCClassNameOf", &LayoutTestController::objCClassNameOf); - BindMethod("addDisallowedURL", &LayoutTestController::addDisallowedURL); - BindMethod("callShouldCloseOnWebView", &LayoutTestController::callShouldCloseOnWebView); - BindMethod("setCallCloseOnWebViews", &LayoutTestController::setCallCloseOnWebViews); - BindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrowsingEnabled); - BindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDashboardCompatibilityMode); - - BindMethod("setJavaScriptCanAccessClipboard", &LayoutTestController::setJavaScriptCanAccessClipboard); - BindMethod("setXSSAuditorEnabled", &LayoutTestController::setXSSAuditorEnabled); - BindMethod("evaluateScriptInIsolatedWorld", &LayoutTestController::evaluateScriptInIsolatedWorld); - BindMethod("overridePreference", &LayoutTestController::overridePreference); - BindMethod("setAllowUniversalAccessFromFileURLs", &LayoutTestController::setAllowUniversalAccessFromFileURLs); - BindMethod("setAllowFileAccessFromFileURLs", &LayoutTestController::setAllowFileAccessFromFileURLs); - BindMethod("setJavaScriptProfilingEnabled", &LayoutTestController::setJavaScriptProfilingEnabled); - 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); - - BindMethod("markerTextForListItem", &LayoutTestController::markerTextForListItem); - - BindMethod("setMockDeviceOrientation", &LayoutTestController::setMockDeviceOrientation); - BindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult); // The fallback method is called when an unknown method is invoked. BindFallbackMethod(&LayoutTestController::fallbackMethod); - - // Shared properties. - // globalFlag is used by a number of layout tests in - // LayoutTests\http\tests\security\dataURL. - BindProperty("globalFlag", &globalFlag_); - // webHistoryItemCount is used by tests in LayoutTests\http\tests\history - BindProperty("webHistoryItemCount", &webHistoryItemCount_); } LayoutTestController::~LayoutTestController() { @@ -247,13 +140,6 @@ void LayoutTestController::WorkQueue::AddWork(WorkItem* work) { queue_.push(work); } -void LayoutTestController::setAcceptsEditing( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) - accepts_editing_ = args[0].value.boolValue; - result->SetNull(); -} - void LayoutTestController::waitUntilDone( const CppArgumentList& args, CppVariant* result) { bool is_debugger_present = false; @@ -299,121 +185,6 @@ void LayoutTestController::completeNotifyDone(bool is_timeout) { wait_until_done_ = false; } -class WorkItemBackForward : public LayoutTestController::WorkItem { - public: - WorkItemBackForward(int distance) : distance_(distance) {} - bool Run(TestShell* shell) { - shell->GoBackOrForward(distance_); - return true; // TODO(darin): Did it really start a navigation? - } - private: - int distance_; -}; - -void LayoutTestController::queueBackNavigation( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isNumber()) - work_queue_.AddWork(new WorkItemBackForward(-args[0].ToInt32())); - result->SetNull(); -} - -void LayoutTestController::queueForwardNavigation( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isNumber()) - work_queue_.AddWork(new WorkItemBackForward(args[0].ToInt32())); - result->SetNull(); -} - -class WorkItemReload : public LayoutTestController::WorkItem { - public: - bool Run(TestShell* shell) { - shell->Reload(); - return true; - } -}; - -void LayoutTestController::queueReload( - const CppArgumentList& args, CppVariant* result) { - work_queue_.AddWork(new WorkItemReload); - result->SetNull(); -} - -class WorkItemLoadingScript : public LayoutTestController::WorkItem { - public: - WorkItemLoadingScript(const string& script) : script_(script) {} - bool Run(TestShell* shell) { - shell->webView()->mainFrame()->executeScript( - WebScriptSource(WebString::fromUTF8(script_))); - return true; // TODO(darin): Did it really start a navigation? - } - private: - string script_; -}; - -class WorkItemNonLoadingScript : public LayoutTestController::WorkItem { - public: - WorkItemNonLoadingScript(const string& script) : script_(script) {} - bool Run(TestShell* shell) { - shell->webView()->mainFrame()->executeScript( - WebScriptSource(WebString::fromUTF8(script_))); - return false; - } - private: - string script_; -}; - -void LayoutTestController::queueLoadingScript( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isString()) - work_queue_.AddWork(new WorkItemLoadingScript(args[0].ToString())); - result->SetNull(); -} - -void LayoutTestController::queueNonLoadingScript( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isString()) - work_queue_.AddWork(new WorkItemNonLoadingScript(args[0].ToString())); - result->SetNull(); -} - -class WorkItemLoad : public LayoutTestController::WorkItem { - public: - WorkItemLoad(const GURL& url, const string& target) - : url_(url), target_(target) {} - bool Run(TestShell* shell) { - shell->LoadURLForFrame(url_, UTF8ToWide(target_).c_str()); - return true; // TODO(darin): Did it really start a navigation? - } - private: - GURL url_; - string target_; -}; - -void LayoutTestController::queueLoad( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isString()) { - GURL current_url = shell_->webView()->mainFrame()->url(); - GURL full_url = current_url.Resolve(args[0].ToString()); - - string target = ""; - if (args.size() > 1 && args[1].isString()) - target = args[1].ToString(); - - work_queue_.AddWork(new WorkItemLoad(full_url, target)); - } - result->SetNull(); -} - -void LayoutTestController::objCIdentityIsEqual( - const CppArgumentList& args, CppVariant* result) { - if (args.size() < 2) { - // This is the best we can do to return an error. - result->SetNull(); - return; - } - result->Set(args[0].isEqual(args[1])); -} - void LayoutTestController::Reset() { if (shell_) { shell_->webView()->setZoomLevel(false, 0); @@ -439,12 +210,7 @@ void LayoutTestController::Reset() { accepts_editing_ = true; wait_until_done_ = false; can_open_windows_ = false; - test_repaint_ = false; - sweep_horizontally_ = false; - should_add_file_to_pasteboard_ = false; stop_provisional_frame_loads_ = false; - globalFlag_.Set(false); - webHistoryItemCount_.Set(0); SimpleResourceLoaderBridge::SetAcceptAllCookies(false); WebSecurityPolicy::resetOriginAccessWhitelists(); @@ -477,8 +243,6 @@ void LayoutTestController::Reset() { } void LayoutTestController::LocationChangeDone() { - webHistoryItemCount_.Set(shell_->navigation_controller()->GetEntryCount()); - // no more new work after the first complete load. work_queue_.set_frozen(true); @@ -495,648 +259,6 @@ void LayoutTestController::PolicyDelegateDone() { wait_until_done_ = false; } -void LayoutTestController::setCanOpenWindows( - const CppArgumentList& args, CppVariant* result) { - can_open_windows_ = true; - result->SetNull(); -} - -void LayoutTestController::setTabKeyCyclesThroughElements( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - shell_->webView()->setTabKeyCyclesThroughElements(args[0].ToBoolean()); - } - result->SetNull(); -} - -void LayoutTestController::windowCount( - const CppArgumentList& args, CppVariant* result) { - int num_windows = static_cast<int>(TestShell::windowList()->size()); - result->Set(num_windows); -} - -void LayoutTestController::setCloseRemainingWindowsWhenComplete( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - close_remaining_windows_ = args[0].value.boolValue; - } - result->SetNull(); -} - -void LayoutTestController::setAlwaysAcceptCookies( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0) { - SimpleResourceLoaderBridge::SetAcceptAllCookies(CppVariantToBool(args[0])); - } - result->SetNull(); -} - -void LayoutTestController::showWebInspector( - const CppArgumentList& args, CppVariant* result) { - shell_->ShowDevTools(); - result->SetNull(); -} - -void LayoutTestController::closeWebInspector( - const CppArgumentList& args, CppVariant* result) { - shell_->CloseDevTools(); - result->SetNull(); -} - -void LayoutTestController::setWindowIsKey( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - shell_->SetFocus(shell_->webViewHost(), args[0].value.boolValue); - } - result->SetNull(); -} - -void LayoutTestController::setUserStyleSheetEnabled( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - shell_->delegate()->SetUserStyleSheetEnabled(args[0].value.boolValue); - } - - result->SetNull(); -} - -void LayoutTestController::setUserStyleSheetLocation( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - - if (args.size() > 0 && args[0].isString()) { - GURL location(TestShell::RewriteLocalUrl(args[0].ToString())); - - FilePath local_path; - if (!net::FileURLToFilePath(location, &local_path)) - return; - - std::string contents; - if (!file_util::ReadFileToString(local_path, &contents)) - return; - - std::string contents_base64; - if (!base::Base64Encode(contents, &contents_base64)) - return; - - const char kDataUrlPrefix[] = "data:text/css;charset=utf-8;base64,"; - location = GURL(kDataUrlPrefix + contents_base64); - - shell_->delegate()->SetUserStyleSheetLocation(location); - } -} - -void LayoutTestController::setAuthorAndUserStylesEnabled( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - shell_->delegate()->SetAuthorAndUserStylesEnabled(args[0].value.boolValue); - } - - result->SetNull(); -} - -void LayoutTestController::execCommand( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isString()) { - std::string command = args[0].ToString(); - std::string value(""); - - // Ignore the second parameter (which is userInterface) - // since this command emulates a manual action. - if (args.size() >= 3 && args[2].isString()) - value = args[2].ToString(); - - // Note: webkit's version does not return the boolean, so neither do we. - shell_->webView()->focusedFrame()->executeCommand( - WebString::fromUTF8(command), WebString::fromUTF8(value)); - } - result->SetNull(); -} - -void LayoutTestController::isCommandEnabled( - const CppArgumentList& args, CppVariant* result) { - if (args.size() <= 0 || !args[0].isString()) { - result->SetNull(); - return; - } - - std::string command = args[0].ToString(); - bool rv = shell_->webView()->focusedFrame()->isCommandEnabled( - WebString::fromUTF8(command)); - result->Set(rv); -} - -void LayoutTestController::setPopupBlockingEnabled( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - bool block_popups = args[0].ToBoolean(); - WebPreferences* prefs = shell_->GetWebPreferences(); - prefs->javascript_can_open_windows_automatically = !block_popups; - prefs->Apply(shell_->webView()); - } - result->SetNull(); -} - -void LayoutTestController::setUseDashboardCompatibilityMode( - const CppArgumentList& args, CppVariant* result) { - // We have no need to support Dashboard Compatibility Mode (mac-only) - result->SetNull(); -} - - -void LayoutTestController::setScrollbarPolicy( - const CppArgumentList& args, CppVariant* result) { - // FIXME: implement. - // Currently only has a non-null implementation on QT. - result->SetNull(); -} - -void LayoutTestController::setCustomPolicyDelegate( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - bool enable = args[0].value.boolValue; - bool permissive = false; - if (args.size() > 1 && args[1].isBool()) - permissive = args[1].value.boolValue; - shell_->delegate()->SetCustomPolicyDelegate(enable, permissive); - } - - result->SetNull(); -} - -void LayoutTestController::waitForPolicyDelegate( - const CppArgumentList& args, CppVariant* result) { - shell_->delegate()->WaitForPolicyDelegate(); - wait_until_done_ = true; - result->SetNull(); -} - -void LayoutTestController::setWillSendRequestClearHeader( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isString()) { - std::string header = args[0].ToString(); - if (!header.empty()) - shell_->delegate()->set_clear_header(header); - } - result->SetNull(); -} - -void LayoutTestController::setWillSendRequestReturnsNullOnRedirect( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) - shell_->delegate()->set_block_redirects(args[0].value.boolValue); - - result->SetNull(); -} - -void LayoutTestController::setWillSendRequestReturnsNull( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) - shell_->delegate()->set_request_return_null(args[0].value.boolValue); - - result->SetNull(); -} - -void LayoutTestController::pathToLocalResource( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - if (args.size() <= 0 || !args[0].isString()) - return; - - std::string url = args[0].ToString(); - if (StartsWithASCII(url, "/tmp/", true)) { - // We want a temp file. - FilePath path; - PathService::Get(base::DIR_TEMP, &path); - path = path.AppendASCII(url.substr(5)); - result->Set(WideToUTF8(path.ToWStringHack())); - return; - } - - // Some layout tests use file://// which we resolve as a UNC path. Normalize - // them to just file:///. - while (StartsWithASCII(url, "file:////", false)) { - url = url.substr(0, 8) + url.substr(9); - } - GURL location(TestShell::RewriteLocalUrl(url)); - result->Set(location.spec()); -} - -void LayoutTestController::addFileToPasteboardOnDrag( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - should_add_file_to_pasteboard_ = true; -} - -void LayoutTestController::setStopProvisionalFrameLoads( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - stop_provisional_frame_loads_ = true; -} - -void LayoutTestController::setSmartInsertDeleteEnabled( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - shell_->delegate()->SetSmartInsertDeleteEnabled(args[0].value.boolValue); - } - - result->SetNull(); -} - -void LayoutTestController::setSelectTrailingWhitespaceEnabled( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - shell_->delegate()->SetSelectTrailingWhitespaceEnabled( - args[0].value.boolValue); - } - - result->SetNull(); -} - -void LayoutTestController::pauseAnimationAtTimeOnElementWithId( - const CppArgumentList& args, - CppVariant* result) { - if (args.size() > 2 && args[0].isString() && args[1].isNumber() && - args[2].isString()) { - std::string animation_name = args[0].ToString(); - double time = args[1].ToDouble(); - std::string element_id = args[2].ToString(); - - result->Set( - webkit_glue::PauseAnimationAtTimeOnElementWithId( - shell_->webView(), animation_name, time, element_id)); - } else { - result->Set(false); - } -} - -void LayoutTestController::pauseTransitionAtTimeOnElementWithId( - const CppArgumentList& args, - CppVariant* result) { - if (args.size() > 2 && args[0].isString() && args[1].isNumber() && - args[2].isString()) { - std::string property_name = args[0].ToString(); - double time = args[1].ToDouble(); - std::string element_id = args[2].ToString(); - - result->Set(webkit_glue::PauseTransitionAtTimeOnElementWithId( - shell_->webView(), property_name, time, element_id)); - } else { - result->Set(false); - } -} - -void LayoutTestController::suspendAnimations( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - - WebKit::WebFrame* web_frame = shell_->webView()->mainFrame(); - if (!web_frame) - return; - - WebKit::WebAnimationController* controller = web_frame->animationController(); - if (!controller) - return; - controller->suspendAnimations(); -} - -void LayoutTestController::resumeAnimations( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - - WebKit::WebFrame* web_frame = shell_->webView()->mainFrame(); - if (!web_frame) - return; - - WebKit::WebAnimationController* controller = web_frame->animationController(); - if (!controller) - return; - controller->resumeAnimations(); -} - -void LayoutTestController::elementDoesAutoCompleteForElementWithId( - const CppArgumentList& args, - CppVariant* result) { - if (args.size() != 1 || !args[0].isString()) { - result->Set(false); - return; - } - std::string element_id = args[0].ToString(); - result->Set(webkit_glue::ElementDoesAutoCompleteForElementWithId( - shell_->webView(), element_id)); -} - -void LayoutTestController::numberOfActiveAnimations(const CppArgumentList& args, - CppVariant* result) { - result->Set(webkit_glue::NumberOfActiveAnimations(shell_->webView())); -} - -void LayoutTestController::disableImageLoading(const CppArgumentList& args, - CppVariant* result) { - WebPreferences* prefs = shell_->GetWebPreferences(); - prefs->loads_images_automatically = false; - prefs->Apply(shell_->webView()); - result->SetNull(); -} - -void LayoutTestController::setIconDatabaseEnabled(const CppArgumentList& args, - CppVariant* result) { - // We don't use the WebKit icon database. - result->SetNull(); -} - -void LayoutTestController::callShouldCloseOnWebView( - const CppArgumentList& args, CppVariant* result) { - bool rv = shell_->webView()->dispatchBeforeUnloadEvent(); - result->Set(rv); -} - -void LayoutTestController::grantDesktopNotificationPermission( - const CppArgumentList& args, CppVariant* result) { - if (args.size() != 1 || !args[0].isString()) { - result->Set(false); - return; - } - std::string origin = args[0].ToString(); - shell_->notification_presenter()->grantPermission(origin); - result->Set(true); -} - -void LayoutTestController::setDomainRelaxationForbiddenForURLScheme( - const CppArgumentList& args, CppVariant* result) { - if (args.size() != 2 || !args[0].isBool() || !args[1].isString()) - return; - - shell_->webView()->setDomainRelaxationForbidden( - CppVariantToBool(args[0]), WebString::fromUTF8(args[1].ToString())); -} - -void LayoutTestController::sampleSVGAnimationForElementAtTime( - const CppArgumentList& args, CppVariant* result) { - if (args.size() != 3) { - result->SetNull(); - return; - } - bool success = shell_->webView()->mainFrame()->pauseSVGAnimation( - WebString::fromUTF8(args[0].ToString()), - args[1].ToDouble(), - WebString::fromUTF8(args[2].ToString())); - result->Set(success); -} - -// -// Unimplemented stubs -// - -void LayoutTestController::setMainFrameIsFirstResponder( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void LayoutTestController::display( - const CppArgumentList& args, CppVariant* result) { - WebViewHost* view_host = shell_->webViewHost(); - const WebSize& size = view_host->webview()->size(); - gfx::Rect rect(size.width, size.height); - view_host->UpdatePaintRect(rect); - view_host->Paint(); - view_host->DisplayRepaintMask(); - result->SetNull(); -} - -void LayoutTestController::testRepaint( - const CppArgumentList& args, CppVariant* result) { - test_repaint_ = true; - result->SetNull(); -} - -void LayoutTestController::repaintSweepHorizontally( - const CppArgumentList& args, CppVariant* result) { - sweep_horizontally_ = true; - result->SetNull(); -} - -void LayoutTestController::clearBackForwardList( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void LayoutTestController::keepWebHistory( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void LayoutTestController::layerTreeAsText( - const CppArgumentList& args, CppVariant* result) { - WebString rv = shell_->webView()->mainFrame()->layerTreeAsText(); - result->Set(rv.utf8()); -} - -void LayoutTestController::storeWebScriptObject( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void LayoutTestController::accessStoredWebScriptObject( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void LayoutTestController::objCClassNameOf( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} -void LayoutTestController::addDisallowedURL( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} -void LayoutTestController::setCallCloseOnWebViews( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} -void LayoutTestController::setPrivateBrowsingEnabled( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void LayoutTestController::setJavaScriptCanAccessClipboard( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - WebPreferences* prefs = shell_->GetWebPreferences(); - prefs->javascript_can_access_clipboard = args[0].value.boolValue; - prefs->Apply(shell_->webView()); - } - result->SetNull(); -} - -void LayoutTestController::setXSSAuditorEnabled( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - WebPreferences* prefs = shell_->GetWebPreferences(); - prefs->xss_auditor_enabled = args[0].value.boolValue; - prefs->Apply(shell_->webView()); - } - result->SetNull(); -} - -void LayoutTestController::evaluateScriptInIsolatedWorld( - const CppArgumentList& args, CppVariant* result) { - if (args.size() >= 2 && args[0].isNumber() && args[1].isString()) { - WebScriptSource source(WebString::fromUTF8(args[1].ToString())); - // This relies on the iframe focusing itself when it loads. This is a bit - // sketchy, but it seems to be what other tests do. - shell_->webView()->focusedFrame()->executeScriptInIsolatedWorld( - args[0].ToInt32(), &source, 1, 1); - } - result->SetNull(); -} - -void LayoutTestController::setAllowUniversalAccessFromFileURLs( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - WebPreferences* prefs = shell_->GetWebPreferences(); - prefs->allow_universal_access_from_file_urls = args[0].value.boolValue; - prefs->Apply(shell_->webView()); - } - result->SetNull(); -} - -void LayoutTestController::setAllowFileAccessFromFileURLs( - const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0 && args[0].isBool()) { - WebPreferences* prefs = shell_->GetWebPreferences(); - prefs->allow_file_access_from_file_urls = args[0].value.boolValue; - prefs->Apply(shell_->webView()); - } - result->SetNull(); -} - -void LayoutTestController::addMockSpeechInputResult(const CppArgumentList& args, - CppVariant* result) { - if (args.size() > 0 && args[0].isString() && args[1].isNumber() && - args[2].isString()) { - shell_->speech_input_controller_mock()->addMockRecognitionResult( - WebString::fromUTF8(args[0].ToString()), args[1].ToDouble(), - WebString::fromUTF8(args[2].ToString())); - } - result->SetNull(); -} - -// Need these conversions because the format of the value for booleans -// may vary - for example, on mac "1" and "0" are used for boolean. -bool LayoutTestController::CppVariantToBool(const CppVariant& value) { - if (value.isBool()) - return value.ToBoolean(); - else if (value.isNumber()) - return 0 != value.ToInt32(); - else if (value.isString()) { - std::string valueString = value.ToString(); - if (valueString == "true" || valueString == "1") - return true; - if (valueString == "false" || valueString == "0") - return false; - } - LogErrorToConsole("Invalid value. Expected boolean value."); - return false; -} - -int32 LayoutTestController::CppVariantToInt32(const CppVariant& value) { - if (value.isNumber()) - return value.ToInt32(); - else if (value.isString()) { - int number; - if (base::StringToInt(value.ToString(), &number)) - return number; - } - LogErrorToConsole("Invalid value for preference. Expected integer value."); - return 0; -} - -string16 LayoutTestController::CppVariantToString16( - const CppVariant& value) { - if (value.isString()) - return UTF8ToUTF16(value.ToString()); - LogErrorToConsole("Invalid value for preference. Expected string value."); - return string16(); -} - -void LayoutTestController::overridePreference( - const CppArgumentList& args, CppVariant* result) { - if (args.size() == 2 && args[0].isString()) { - std::string key = args[0].ToString(); - CppVariant value = args[1]; - WebPreferences* preferences = shell_->GetWebPreferences(); - if (key == "WebKitStandardFont") - preferences->standard_font_family = CppVariantToString16(value); - else if (key == "WebKitFixedFont") - preferences->fixed_font_family = CppVariantToString16(value); - else if (key == "WebKitSerifFont") - preferences->serif_font_family = CppVariantToString16(value); - else if (key == "WebKitSansSerifFont") - preferences->sans_serif_font_family = CppVariantToString16(value); - else if (key == "WebKitCursiveFont") - preferences->cursive_font_family = CppVariantToString16(value); - else if (key == "WebKitFantasyFont") - preferences->fantasy_font_family = CppVariantToString16(value); - else if (key == "WebKitDefaultFontSize") - preferences->default_font_size = CppVariantToInt32(value); - else if (key == "WebKitDefaultFixedFontSize") - preferences->default_fixed_font_size = CppVariantToInt32(value); - else if (key == "WebKitMinimumFontSize") - preferences->minimum_font_size = CppVariantToInt32(value); - else if (key == "WebKitMinimumLogicalFontSize") - preferences->minimum_logical_font_size = CppVariantToInt32(value); - else if (key == "WebKitDefaultTextEncodingName") - preferences->default_encoding = value.ToString(); - else if (key == "WebKitJavaScriptEnabled") - preferences->javascript_enabled = CppVariantToBool(value); - else if (key == "WebKitWebSecurityEnabled") - preferences->web_security_enabled = CppVariantToBool(value); - else if (key == "WebKitJavaScriptCanOpenWindowsAutomatically") - preferences->javascript_can_open_windows_automatically = - CppVariantToBool(value); - else if (key == "WebKitDisplayImagesKey") - preferences->loads_images_automatically = CppVariantToBool(value); - else if (key == "WebKitPluginsEnabled") - preferences->plugins_enabled = CppVariantToBool(value); - else if (key == "WebKitDOMPasteAllowedPreferenceKey") - preferences->dom_paste_enabled = CppVariantToBool(value); - else if (key == "WebKitDeveloperExtrasEnabledPreferenceKey") - preferences->developer_extras_enabled = CppVariantToBool(value); - else if (key == "WebKitShrinksStandaloneImagesToFit") - preferences->shrinks_standalone_images_to_fit = CppVariantToBool(value); - else if (key == "WebKitTextAreasAreResizable") - preferences->text_areas_are_resizable = CppVariantToBool(value); - else if (key == "WebKitJavaEnabled") - preferences->java_enabled = CppVariantToBool(value); - else if (key == "WebKitUsesPageCachePreferenceKey") - preferences->uses_page_cache = CppVariantToBool(value); - else if (key == "WebKitJavaScriptCanAccessClipboard") - preferences->javascript_can_access_clipboard = CppVariantToBool(value); - else if (key == "WebKitXSSAuditorEnabled") - preferences->xss_auditor_enabled = CppVariantToBool(value); - else if (key == "WebKitLocalStorageEnabledPreferenceKey") - preferences->local_storage_enabled = CppVariantToBool(value); - else if (key == "WebKitOfflineWebApplicationCacheEnabled") - preferences->application_cache_enabled = CppVariantToBool(value); - else if (key == "WebKitTabToLinksPreferenceKey") - preferences->tabs_to_links = CppVariantToBool(value); - else if (key == "WebKitWebGLEnabled") - preferences->experimental_webgl_enabled = CppVariantToBool(value); - else if (key == "WebKitEnableCaretBrowsing") - preferences->caret_browsing_enabled = CppVariantToBool(value); - else if (key == "WebKitHyperlinkAuditingEnabled") - preferences->hyperlink_auditing_enabled = CppVariantToBool(value); - else { - std::string message("Invalid name for preference: "); - message.append(key); - LogErrorToConsole(message); - } - preferences->Apply(shell_->webView()); - } - result->SetNull(); -} - void LayoutTestController::fallbackMethod( const CppArgumentList& args, CppVariant* result) { std::wstring message(L"JavaScript ERROR: unknown method called on LayoutTestController"); @@ -1148,281 +270,9 @@ void LayoutTestController::fallbackMethod( result->SetNull(); } -void LayoutTestController::addOriginAccessWhitelistEntry( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - - if (args.size() != 4 || !args[0].isString() || !args[1].isString() || - !args[2].isString() || !args[3].isBool()) - return; - - WebURL url(GURL(args[0].ToString())); - if (!url.isValid()) - return; - - WebSecurityPolicy::addOriginAccessWhitelistEntry(url, - WebString::fromUTF8(args[1].ToString()), - WebString::fromUTF8(args[2].ToString()), - args[3].ToBoolean()); -} - -void LayoutTestController::removeOriginAccessWhitelistEntry( - const CppArgumentList& args, CppVariant* result) -{ - result->SetNull(); - - if (args.size() != 4 || !args[0].isString() || !args[1].isString() || - !args[2].isString() || !args[3].isBool()) - return; - - WebURL url(GURL(args[0].ToString())); - if (!url.isValid()) - return; - - WebSecurityPolicy::removeOriginAccessWhitelistEntry(url, - WebString::fromUTF8(args[1].ToString()), - WebString::fromUTF8(args[2].ToString()), - args[3].ToBoolean()); -} - -void LayoutTestController::clearAllDatabases( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - SimpleDatabaseSystem::GetInstance()->ClearAllDatabases(); -} - -void LayoutTestController::setDatabaseQuota( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - if ((args.size() >= 1) && args[0].isNumber()) - SimpleDatabaseSystem::GetInstance()->SetDatabaseQuota(args[0].ToInt32()); -} - -void LayoutTestController::setPOSIXLocale(const CppArgumentList& args, - CppVariant* result) { - result->SetNull(); - if (args.size() == 1 && args[0].isString()) { - std::string new_locale = args[0].ToString(); - setlocale(LC_ALL, new_locale.c_str()); - } -} - -void LayoutTestController::counterValueForElementById( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - if (args.size() < 1 || !args[0].isString()) - return; - string16 counterValue; - if (!webkit_glue::CounterValueForElementById(shell_->webView()->mainFrame(), - args[0].ToString(), - &counterValue)) - return; - result->Set(UTF16ToUTF8(counterValue)); -} - -static bool ParsePageSizeParameters(const CppArgumentList& args, - int arg_offset, - float* page_width_in_pixels, - float* page_height_in_pixels) { - // WebKit is using the window width/height of DumpRenderTree as the - // default value of the page size. - // TODO(hamaji): Once chromium DumpRenderTree is implemented, - // share these values with other ports. - *page_width_in_pixels = 800; - *page_height_in_pixels = 600; - switch (args.size() - arg_offset) { - case 2: - if (!args[arg_offset].isNumber() || !args[1 + arg_offset].isNumber()) - return false; - *page_width_in_pixels = static_cast<float>(args[arg_offset].ToInt32()); - *page_height_in_pixels = static_cast<float>(args[1 + arg_offset].ToInt32()); - // fall through. - case 0: - break; - default: - return false; - } - return true; -} - -void LayoutTestController::pageNumberForElementById( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - float page_width_in_pixels = 0; - float page_height_in_pixels = 0; - if (!ParsePageSizeParameters(args, 1, - &page_width_in_pixels, &page_height_in_pixels)) - return; - if (!args[0].isString()) - return; - - int page_number = webkit_glue::PageNumberForElementById( - shell_->webView()->mainFrame(), - args[0].ToString(), - page_width_in_pixels, - page_height_in_pixels); - result->Set(page_number); -} - -void LayoutTestController::numberOfPages( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - float page_width_in_pixels = 0; - float page_height_in_pixels = 0; - if (!ParsePageSizeParameters(args, 0, - &page_width_in_pixels, &page_height_in_pixels)) - return; - - int page_number = webkit_glue::NumberOfPages(shell_->webView()->mainFrame(), - page_width_in_pixels, - page_height_in_pixels); - result->Set(page_number); -} - void LayoutTestController::LogErrorToConsole(const std::string& text) { shell_->delegate()->didAddMessageToConsole( WebConsoleMessage(WebConsoleMessage::LevelError, WebString::fromUTF8(text)), WebString(), 0); } - -void LayoutTestController::setJavaScriptProfilingEnabled( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - // Dummy method. JS profiling is always enabled in InspectorController. - return; -} - -void LayoutTestController::setTimelineProfilingEnabled( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); - if (args.size() < 1 || !args[0].isBool()) - return; - shell_->dev_tools_agent()->setTimelineProfilingEnabled(args[0].ToBoolean()); -} - -void LayoutTestController::evaluateInWebInspector(const CppArgumentList& args, - CppVariant* result) { - result->SetNull(); - if (args.size() < 2 || !args[0].isNumber() || !args[1].isString()) - return; - shell_->dev_tools_agent()->evaluateInWebInspector(args[0].ToInt32(), - args[1].ToString()); -} - -void LayoutTestController::forceRedSelectionColors(const CppArgumentList& args, - CppVariant* result) { - result->SetNull(); - shell_->webView()->setSelectionColors(0xffee0000, 0xff00ee00, 0xff000000, - 0xffc0c0c0); -} - -void LayoutTestController::addUserScript(const CppArgumentList& args, - CppVariant* result) { - result->SetNull(); - if (args.size() < 3 || !args[0].isString() || !args[1].isBool() || - !args[2].isBool()) - return; - WebKit::WebView::addUserScript( - WebString::fromUTF8(args[0].ToString()), - WebKit::WebVector<WebString>(), - args[1].ToBoolean() ? - WebKit::WebView::UserScriptInjectAtDocumentStart : - WebKit::WebView::UserScriptInjectAtDocumentEnd, - args[2].ToBoolean() ? - WebKit::WebView::UserContentInjectInAllFrames : - WebKit::WebView::UserContentInjectInTopFrameOnly); -} - -void LayoutTestController::addUserStyleSheet(const CppArgumentList& args, - CppVariant* result) { - result->SetNull(); - if (args.size() < 2 || !args[0].isString() || !args[1].isBool()) - return; - WebKit::WebView::addUserStyleSheet( - WebString::fromUTF8(args[0].ToString()), - WebKit::WebVector<WebString>(), - args[1].ToBoolean() ? - WebKit::WebView::UserContentInjectInAllFrames : - WebKit::WebView::UserContentInjectInTopFrameOnly, - WebKit::WebView::UserStyleInjectInExistingDocuments); -} - -void LayoutTestController::setEditingBehavior(const CppArgumentList& args, - CppVariant* result) { - result->SetNull(); - WebString key = WebString::fromUTF8(args[0].ToString()); - WebKit::WebSettings::EditingBehavior behavior; - if (key == "mac") { - behavior = WebKit::WebSettings::EditingBehaviorMac; - } else if (key == "win") { - behavior = WebKit::WebSettings::EditingBehaviorWin; - } else if (key == "unix") { - behavior = WebKit::WebSettings::EditingBehaviorUnix; - } else { - LogErrorToConsole("Passed invalid editing behavior. " - "Should be 'mac', 'win', or 'unix'."); - return; - } - shell_->webView()->settings()->setEditingBehavior(behavior); -} - -void LayoutTestController::setGeolocationPermission(const CppArgumentList& args, - CppVariant* result) { - if (args.size() < 1 || !args[0].isBool()) - return; - shell_->geolocation_client_mock()->setPermission( - args[0].ToBoolean()); -} - -void LayoutTestController::setMockGeolocationPosition( - const CppArgumentList& args, CppVariant* result) { - if (args.size() < 3 || - !args[0].isNumber() || !args[1].isNumber() || !args[2].isNumber()) - return; - shell_->geolocation_client_mock()->setPosition( - args[0].ToDouble(), args[1].ToDouble(), args[2].ToDouble()); -} - -void LayoutTestController::setMockGeolocationError(const CppArgumentList& args, - CppVariant* result) { - if (args.size() < 2 || !args[0].isNumber() || !args[1].isString()) - return; - shell_->geolocation_client_mock()->setError( - args[0].ToInt32(), WebString::fromUTF8(args[1].ToString())); -} - -void LayoutTestController::markerTextForListItem(const CppArgumentList& args, - CppVariant* result) { - WebElement element; - if (!WebBindings::getElement(args[0].value.objectValue, &element)) - result->SetNull(); - else - result->Set( - element.document().frame()->markerTextForListItem(element).utf8()); -} - -void LayoutTestController::setMockDeviceOrientation(const CppArgumentList& args, - CppVariant* result) { - if (args.size() < 6 || - !args[0].isBool() || !args[1].isNumber() || - !args[2].isBool() || !args[3].isNumber() || - !args[4].isBool() || !args[5].isNumber()) - return; - WebKit::WebDeviceOrientation orientation(args[0].ToBoolean(), - args[1].ToDouble(), - args[2].ToBoolean(), - args[3].ToDouble(), - args[4].ToBoolean(), - args[5].ToDouble()); - - shell_->device_orientation_client_mock()->setOrientation(orientation); -} - -void LayoutTestController::hasSpellingMarker(const CppArgumentList& arguments, - CppVariant* result) { - if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isNumber()) - return; - result->Set(shell_->webView()->mainFrame()->selectionStartHasSpellingMarkerFor( - arguments[0].ToInt32(), arguments[1].ToInt32())); -} diff --git a/webkit/tools/test_shell/layout_test_controller.h b/webkit/tools/test_shell/layout_test_controller.h index a83bc94..136b6a1 100644 --- a/webkit/tools/test_shell/layout_test_controller.h +++ b/webkit/tools/test_shell/layout_test_controller.h @@ -29,166 +29,10 @@ class LayoutTestController : public CppBoundClass { LayoutTestController(TestShell* shell); ~LayoutTestController(); - // When called with a boolean argument, this sets a flag that controls - // whether content-editable elements accept editing focus when an editing - // attempt is made. It ignores any additional arguments. - void setAcceptsEditing(const CppArgumentList& args, CppVariant* result); - - // Functions for dealing with windows. By default we block all new windows. - void windowCount(const CppArgumentList& args, CppVariant* result); - void setCanOpenWindows(const CppArgumentList& args, CppVariant* result); - void setCloseRemainingWindowsWhenComplete(const CppArgumentList& args, CppVariant* result); - // By default, tests end when page load is complete. These methods are used // to delay the completion of the test until notifyDone is called. void waitUntilDone(const CppArgumentList& args, CppVariant* result); void notifyDone(const CppArgumentList& args, CppVariant* result); - void notifyDoneTimedOut(); - - // Methods for adding actions to the work queue. Used in conjunction with - // waitUntilDone/notifyDone above. - void queueBackNavigation(const CppArgumentList& args, CppVariant* result); - void queueForwardNavigation(const CppArgumentList& args, CppVariant* result); - void queueReload(const CppArgumentList& args, CppVariant* result); - void queueLoadingScript(const CppArgumentList& args, CppVariant* result); - void queueNonLoadingScript(const CppArgumentList& args, CppVariant* result); - void queueLoad(const CppArgumentList& args, CppVariant* result); - - // Although this is named "objC" to match the Mac version, it actually tests - // the identity of its two arguments in C++. - void objCIdentityIsEqual(const CppArgumentList& args, CppVariant* result); - - // Changes the cookie policy from the default to allow all cookies. - void setAlwaysAcceptCookies(const CppArgumentList& args, CppVariant* result); - - // Shows DevTools window. - void showWebInspector(const CppArgumentList& args, CppVariant* result); - - // Close DevTools window. - void closeWebInspector(const CppArgumentList& args, CppVariant* result); - - // Gives focus to the window. - void setWindowIsKey(const CppArgumentList& args, CppVariant* result); - - // Method that controls whether pressing Tab key cycles through page elements - // or inserts a '\t' char in text area - void setTabKeyCyclesThroughElements(const CppArgumentList& args, CppVariant* result); - - // Passes through to WebPreferences which allows the user to have a custom - // style sheet. - void setUserStyleSheetEnabled(const CppArgumentList& args, CppVariant* result); - void setUserStyleSheetLocation(const CppArgumentList& args, CppVariant* result); - - // Passes this preference through to WebPreferences. - void setAuthorAndUserStylesEnabled(const CppArgumentList& args, CppVariant* result); - - // Puts Webkit in "dashboard compatibility mode", which is used in obscure - // Mac-only circumstances. It's not really necessary, and will most likely - // never be used by Chrome, but some layout tests depend on its presence. - void setUseDashboardCompatibilityMode(const CppArgumentList& args, CppVariant* result); - - void setScrollbarPolicy(const CppArgumentList& args, CppVariant* result); - - // Causes navigation actions just printout the intended navigation instead - // of taking you to the page. This is used for cases like mailto, where you - // don't actually want to open the mail program. - void setCustomPolicyDelegate(const CppArgumentList& args, CppVariant* result); - - // Delays completion of the test until the policy delegate runs. - void waitForPolicyDelegate(const CppArgumentList& args, CppVariant* result); - - // Causes WillSendRequest to clear certain headers. - void setWillSendRequestClearHeader(const CppArgumentList& args, - CppVariant* result); - - // Causes WillSendRequest to block redirects. - void setWillSendRequestReturnsNullOnRedirect(const CppArgumentList& args, - CppVariant* result); - - // Causes WillSendRequest to return an empty request. - void setWillSendRequestReturnsNull(const CppArgumentList& args, - CppVariant* result); - - // Converts a URL starting with file:///tmp/ to the local mapping. - void pathToLocalResource(const CppArgumentList& args, CppVariant* result); - - // Sets a bool such that when a drag is started, we fill the drag clipboard - // with a fake file object. - void addFileToPasteboardOnDrag(const CppArgumentList& args, CppVariant* result); - - // Executes an internal command (superset of document.execCommand() commands). - void execCommand(const CppArgumentList& args, CppVariant* result); - - // Checks if an internal command is currently available. - void isCommandEnabled(const CppArgumentList& args, CppVariant* result); - - // Set the WebPreference that controls webkit's popup blocking. - void setPopupBlockingEnabled(const CppArgumentList& args, CppVariant* result); - - // If true, causes provisional frame loads to be stopped for the remainder of - // the test. - void setStopProvisionalFrameLoads(const CppArgumentList& args, - CppVariant* result); - - // Enable or disable smart insert/delete. This is enabled by default. - void setSmartInsertDeleteEnabled(const CppArgumentList& args, - CppVariant* result); - - // Enable or disable trailing whitespace selection on double click. - void setSelectTrailingWhitespaceEnabled(const CppArgumentList& args, - CppVariant* result); - - void pauseAnimationAtTimeOnElementWithId(const CppArgumentList& args, - CppVariant* result); - void pauseTransitionAtTimeOnElementWithId(const CppArgumentList& args, - CppVariant* result); - void suspendAnimations(const CppArgumentList& args, CppVariant* result); - void resumeAnimations(const CppArgumentList& args, CppVariant* result); - void elementDoesAutoCompleteForElementWithId(const CppArgumentList& args, - CppVariant* result); - void numberOfActiveAnimations(const CppArgumentList& args, - CppVariant* result); - - void disableImageLoading(const CppArgumentList& args, - CppVariant* result); - - void setIconDatabaseEnabled(const CppArgumentList& args, - CppVariant* result); - - // Grants permission for desktop notifications to an origin - void grantDesktopNotificationPermission(const CppArgumentList& args, - CppVariant* result); - - void setDomainRelaxationForbiddenForURLScheme( - const CppArgumentList& args, CppVariant* result); - void sampleSVGAnimationForElementAtTime(const CppArgumentList& args, - CppVariant* result); - void setEditingBehavior(const CppArgumentList&, CppVariant*); - - // The following are only stubs. TODO(pamg): Implement any of these that - // are needed to pass the layout tests. - void setMainFrameIsFirstResponder(const CppArgumentList& args, CppVariant* result); - void display(const CppArgumentList& args, CppVariant* result); - void testRepaint(const CppArgumentList& args, CppVariant* result); - void repaintSweepHorizontally(const CppArgumentList& args, CppVariant* result); - void clearBackForwardList(const CppArgumentList& args, CppVariant* result); - void keepWebHistory(const CppArgumentList& args, CppVariant* result); - void layerTreeAsText(const CppArgumentList& args, CppVariant* result); - void storeWebScriptObject(const CppArgumentList& args, CppVariant* result); - void accessStoredWebScriptObject(const CppArgumentList& args, CppVariant* result); - void objCClassNameOf(const CppArgumentList& args, CppVariant* result); - void addDisallowedURL(const CppArgumentList& args, CppVariant* result); - void callShouldCloseOnWebView(const CppArgumentList& args, CppVariant* result); - void setCallCloseOnWebViews(const CppArgumentList& args, CppVariant* result); - void setPrivateBrowsingEnabled(const CppArgumentList& args, CppVariant* result); - - void setJavaScriptCanAccessClipboard(const CppArgumentList& args, CppVariant* result); - void setXSSAuditorEnabled(const CppArgumentList& args, CppVariant* result); - void evaluateScriptInIsolatedWorld(const CppArgumentList& args, CppVariant* result); - void overridePreference(const CppArgumentList& args, CppVariant* result); - void setAllowUniversalAccessFromFileURLs(const CppArgumentList& args, CppVariant* result); - void setAllowFileAccessFromFileURLs(const CppArgumentList& args, CppVariant* result); - void addMockSpeechInputResult(const CppArgumentList& args, CppVariant* result); // The fallback method is called when a nonexistent method is called on // the layout test controller object. @@ -197,79 +41,14 @@ class LayoutTestController : public CppBoundClass { // that case (as the Mac does). void fallbackMethod(const CppArgumentList& args, CppVariant* result); - // Allows layout tests to manage origins' whitelisting. - void addOriginAccessWhitelistEntry( - const CppArgumentList& args, CppVariant* result); - void removeOriginAccessWhitelistEntry( - const CppArgumentList& args, CppVariant* result); - - // Clears all databases. - void clearAllDatabases(const CppArgumentList& args, CppVariant* result); - // Sets the default quota for all origins - void setDatabaseQuota(const CppArgumentList& args, CppVariant* result); - - // Calls setlocale(LC_ALL, ...) for a specified locale. - // Resets between tests. - void setPOSIXLocale(const CppArgumentList& args, CppVariant* result); - - // Gets the value of the counter in the element specified by its ID. - void counterValueForElementById( - const CppArgumentList& args, CppVariant* result); - - // Gets the number of page where the specified element will be put. - void pageNumberForElementById( - const CppArgumentList& args, CppVariant* result); - - // Gets the number of pages to be printed. - void numberOfPages(const CppArgumentList& args, CppVariant* result); - - // Allows layout tests to control JavaScript profiling. - void setJavaScriptProfilingEnabled(const CppArgumentList& args, - CppVariant* result); - - // Allows layout tests to start Timeline profiling. - void setTimelineProfilingEnabled(const CppArgumentList& args, - CppVariant* result); - - // Allows layout tests to exec scripts at WebInspector side. - void evaluateInWebInspector(const CppArgumentList& args, CppVariant* result); - - // Forces the selection colors for testing under Linux. - void forceRedSelectionColors(const CppArgumentList& args, - CppVariant* result); - - // Adds a user script or user style sheet to be injected into new documents. - void addUserScript(const CppArgumentList& args, CppVariant* result); - void addUserStyleSheet(const CppArgumentList& args, CppVariant* result); - - // Geolocation related functions. - void setGeolocationPermission(const CppArgumentList& args, - CppVariant* result); - void setMockGeolocationPosition(const CppArgumentList& args, - CppVariant* result); - void setMockGeolocationError(const CppArgumentList& args, - CppVariant* result); - - void markerTextForListItem(const CppArgumentList& args, - CppVariant* result); - - void setMockDeviceOrientation(const CppArgumentList& args, - CppVariant* result); - - void hasSpellingMarker(const CppArgumentList& args, CppVariant* result); - public: // The following methods are not exposed to JavaScript. void SetWorkQueueFrozen(bool frozen) { work_queue_.set_frozen(frozen); } bool AcceptsEditing() { return accepts_editing_; } bool CanOpenWindows() { return can_open_windows_; } - bool ShouldAddFileToPasteboard() { return should_add_file_to_pasteboard_; } bool StopProvisionalFrameLoads() { return stop_provisional_frame_loads_; } - bool test_repaint() const { return test_repaint_; } - bool sweep_horizontally() const { return sweep_horizontally_; } - // Called by the webview delegate when the toplevel frame load is done. void LocationChangeDone(); @@ -321,10 +100,7 @@ class LayoutTestController : public CppBoundClass { bool frozen_; }; - // Support for overridePreference. - bool CppVariantToBool(const CppVariant&); - int32 CppVariantToInt32(const CppVariant&); - string16 CppVariantToString16(const CppVariant&); + void notifyDoneTimedOut(); void LogErrorToConsole(const std::string& text); @@ -352,16 +128,6 @@ class LayoutTestController : public CppBoundClass { // setCloseRemainingWindowsWhenComplete(). static bool close_remaining_windows_; - // If true, pixel dump will be produced as a series of 1px-tall, view-wide - // individual paints over the height of the view. - static bool test_repaint_; - // If true and test_repaint_ is true as well, pixel dump will be produced as - // a series of 1px-wide, view-tall paints across the width of the view. - static bool sweep_horizontally_; - - // If true and a drag starts, adds a file to the drag&drop clipboard. - static bool should_add_file_to_pasteboard_; - // If true, stops provisional frame loads during the // DidStartProvisionalLoadForFrame callback. static bool stop_provisional_frame_loads_; @@ -369,17 +135,7 @@ class LayoutTestController : public CppBoundClass { // If true, don't dump output until notifyDone is called. static bool wait_until_done_; - // To prevent infinite loops, only the first page of a test can add to a - // work queue (since we may well come back to that same page). - static bool work_queue_frozen_; - - static WorkQueue work_queue_; - - static CppVariant globalFlag_; - - // Bound variable counting the number of top URLs visited. - static CppVariant webHistoryItemCount_; }; #endif // WEBKIT_TOOLS_TEST_SHELL_LAYOUT_TEST_CONTROLLER_H_ diff --git a/webkit/tools/test_shell/layout_test_controller_unittest.cc b/webkit/tools/test_shell/layout_test_controller_unittest.cc deleted file mode 100644 index bb4c4c1..0000000 --- a/webkit/tools/test_shell/layout_test_controller_unittest.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <map> - -#include "webkit/tools/test_shell/layout_test_controller.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { -// A subclass of LayoutTestController, with additional accessors. -class TestLayoutTestController : public LayoutTestController { - public: - TestLayoutTestController() : LayoutTestController(NULL) { - } - - size_t MethodCount() { - return methods_.size(); - } - - void Reset() { - LayoutTestController::Reset(); - } -}; - -class LayoutTestControllerTest : public testing::Test { -}; -} // namespace - -TEST(LayoutTestControllerTest, MethodMapIsInitialized) { - const char* test_methods[] = { - "waitUntilDone", - "notifyDone", - "queueLoad", - "windowCount", - NULL - }; - TestLayoutTestController controller; - for (const char** method = test_methods; *method; ++method) { - EXPECT_TRUE(controller.IsMethodRegistered(*method)); - } - - // One more case, to test our test. - EXPECT_FALSE(controller.IsMethodRegistered("nonexistent_method")); -} diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi index 80b75da..6a2d336 100644 --- a/webkit/tools/test_shell/test_shell.gypi +++ b/webkit/tools/test_shell/test_shell.gypi @@ -422,7 +422,6 @@ 'event_listener_unittest.cc', 'image_decoder_unittest.cc', 'image_decoder_unittest.h', - 'layout_test_controller_unittest.cc', 'listener_leak_test.cc', 'media_leak_test.cc', 'mock_spellcheck_unittest.cc', |