diff options
author | Steve Block <steveblock@google.com> | 2010-09-29 17:32:26 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-09-29 17:35:08 +0100 |
commit | 68513a70bcd92384395513322f1b801e7bf9c729 (patch) | |
tree | 161b50f75a5921d61731bb25e730005994fcec85 /WebKitTools/DumpRenderTree | |
parent | fd5c6425ce58eb75211be7718d5dee960842a37e (diff) | |
download | external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.zip external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.tar.gz external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.tar.bz2 |
Merge WebKit at r67908: Initial merge by Git
Change-Id: I43a553e7b3299b28cb6ee8aa035ed70fe342b972
Diffstat (limited to 'WebKitTools/DumpRenderTree')
23 files changed, 747 insertions, 313 deletions
diff --git a/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp b/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp index 22bbbaa..13c642a 100644 --- a/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp +++ b/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp @@ -424,6 +424,18 @@ static JSValueRef textMarkerRangeLengthCallback(JSContextRef context, JSObjectRe return JSValueMakeNumber(context, (int)toAXElement(thisObject)->textMarkerRangeLength(range)); } +static JSValueRef textMarkerForPointCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + int x = 0; + int y = 0; + if (argumentCount == 2) { + x = JSValueToNumber(context, arguments[0], exception); + y = JSValueToNumber(context, arguments[1], exception); + } + + return AccessibilityTextMarker::makeJSAccessibilityTextMarker(context, toAXElement(thisObject)->textMarkerForPoint(x, y)); +} + static JSValueRef textMarkerRangeForMarkersCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { AccessibilityTextMarker* startMarker = 0; @@ -662,6 +674,11 @@ static JSValueRef getIsCollapsedCallback(JSContextRef context, JSObjectRef thisO return JSValueMakeBoolean(context, toAXElement(thisObject)->isCollapsed()); } +static JSValueRef isIgnoredCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*) +{ + return JSValueMakeBoolean(context, toAXElement(thisObject)->isIgnored()); +} + static JSValueRef getHasPopupCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*) { return JSValueMakeBoolean(context, toAXElement(thisObject)->hasPopup()); @@ -752,6 +769,11 @@ AccessibilityUIElement AccessibilityUIElement::accessibilityElementForTextMarker return 0; } +AccessibilityTextMarker AccessibilityUIElement::textMarkerForPoint(int x, int y) +{ + return 0; +} + #endif // Destruction @@ -814,6 +836,7 @@ JSClassRef AccessibilityUIElement::getJSClass() { "orientation", getOrientationCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "ariaIsGrabbed", getARIAIsGrabbedCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "ariaDropEffects", getARIADropEffectsCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "isIgnored", isIgnoredCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { 0, 0, 0, 0 } }; @@ -872,6 +895,7 @@ JSClassRef AccessibilityUIElement::getJSClass() { "endTextMarkerForTextMarkerRange", endTextMarkerForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "accessibilityElementForTextMarker", accessibilityElementForTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "textMarkerRangeLength", textMarkerRangeLengthCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "textMarkerForPoint", textMarkerForPointCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; diff --git a/WebKitTools/DumpRenderTree/AccessibilityUIElement.h b/WebKitTools/DumpRenderTree/AccessibilityUIElement.h index 2606795..5170f20 100644 --- a/WebKitTools/DumpRenderTree/AccessibilityUIElement.h +++ b/WebKitTools/DumpRenderTree/AccessibilityUIElement.h @@ -138,6 +138,7 @@ public: bool isVisible() const; bool isOffScreen() const; bool isCollapsed() const; + bool isIgnored() const; bool hasPopup() const; int hierarchicalLevel() const; double clickPointX(); @@ -189,6 +190,7 @@ public: AccessibilityTextMarkerRange textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker); AccessibilityTextMarker startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*); AccessibilityTextMarker endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*); + AccessibilityTextMarker textMarkerForPoint(int x, int y); AccessibilityUIElement accessibilityElementForTextMarker(AccessibilityTextMarker*); int textMarkerRangeLength(AccessibilityTextMarkerRange*); diff --git a/WebKitTools/DumpRenderTree/DumpRenderTree.gypi b/WebKitTools/DumpRenderTree/DumpRenderTree.gypi index b39fd2a..58ccaae 100644 --- a/WebKitTools/DumpRenderTree/DumpRenderTree.gypi +++ b/WebKitTools/DumpRenderTree/DumpRenderTree.gypi @@ -39,6 +39,8 @@ 'chromium/TestShellWin.cpp', 'chromium/TextInputController.cpp', 'chromium/TextInputController.h', + 'chromium/WebPreferences.cpp', + 'chromium/WebPreferences.h', 'chromium/WebViewHost.cpp', 'chromium/WebViewHost.h', ], diff --git a/WebKitTools/DumpRenderTree/chromium/EventSender.cpp b/WebKitTools/DumpRenderTree/chromium/EventSender.cpp index c2ba380..5f51553 100644 --- a/WebKitTools/DumpRenderTree/chromium/EventSender.cpp +++ b/WebKitTools/DumpRenderTree/chromium/EventSender.cpp @@ -250,34 +250,34 @@ EventSender::EventSender(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 EventSender). - bindMethod("mouseDown", &EventSender::mouseDown); - bindMethod("mouseUp", &EventSender::mouseUp); + bindMethod("addTouchPoint", &EventSender::addTouchPoint); + bindMethod("beginDragWithFiles", &EventSender::beginDragWithFiles); + bindMethod("cancelTouchPoint", &EventSender::cancelTouchPoint); + bindMethod("clearKillRing", &EventSender::clearKillRing); + bindMethod("clearTouchPoints", &EventSender::clearTouchPoints); bindMethod("contextClick", &EventSender::contextClick); - bindMethod("mouseMoveTo", &EventSender::mouseMoveTo); - bindMethod("leapForward", &EventSender::leapForward); - bindMethod("keyDown", &EventSender::keyDown); + bindMethod("continuousMouseScrollBy", &EventSender::continuousMouseScrollBy); bindMethod("dispatchMessage", &EventSender::dispatchMessage); bindMethod("enableDOMUIEventLogging", &EventSender::enableDOMUIEventLogging); bindMethod("fireKeyboardEventsToElement", &EventSender::fireKeyboardEventsToElement); - bindMethod("clearKillRing", &EventSender::clearKillRing); - bindMethod("textZoomIn", &EventSender::textZoomIn); - bindMethod("textZoomOut", &EventSender::textZoomOut); - bindMethod("zoomPageIn", &EventSender::zoomPageIn); - bindMethod("zoomPageOut", &EventSender::zoomPageOut); + bindMethod("keyDown", &EventSender::keyDown); + bindMethod("leapForward", &EventSender::leapForward); + bindMethod("mouseDown", &EventSender::mouseDown); + bindMethod("mouseMoveTo", &EventSender::mouseMoveTo); bindMethod("mouseScrollBy", &EventSender::mouseScrollBy); - bindMethod("continuousMouseScrollBy", &EventSender::continuousMouseScrollBy); - bindMethod("scheduleAsynchronousClick", &EventSender::scheduleAsynchronousClick); - bindMethod("beginDragWithFiles", &EventSender::beginDragWithFiles); - bindMethod("addTouchPoint", &EventSender::addTouchPoint); - bindMethod("cancelTouchPoint", &EventSender::cancelTouchPoint); - bindMethod("clearTouchPoints", &EventSender::clearTouchPoints); + bindMethod("mouseUp", &EventSender::mouseUp); bindMethod("releaseTouchPoint", &EventSender::releaseTouchPoint); - bindMethod("updateTouchPoint", &EventSender::updateTouchPoint); + bindMethod("scheduleAsynchronousClick", &EventSender::scheduleAsynchronousClick); bindMethod("setTouchModifier", &EventSender::setTouchModifier); + bindMethod("textZoomIn", &EventSender::textZoomIn); + bindMethod("textZoomOut", &EventSender::textZoomOut); bindMethod("touchCancel", &EventSender::touchCancel); bindMethod("touchEnd", &EventSender::touchEnd); bindMethod("touchMove", &EventSender::touchMove); bindMethod("touchStart", &EventSender::touchStart); + bindMethod("updateTouchPoint", &EventSender::updateTouchPoint); + bindMethod("zoomPageIn", &EventSender::zoomPageIn); + bindMethod("zoomPageOut", &EventSender::zoomPageOut); // When set to true (the default value), we batch mouse move and mouse up // events so we can simulate drag & drop. diff --git a/WebKitTools/DumpRenderTree/chromium/ImageDiff.cpp b/WebKitTools/DumpRenderTree/chromium/ImageDiff.cpp index d1adc3d..f2875dd 100644 --- a/WebKitTools/DumpRenderTree/chromium/ImageDiff.cpp +++ b/WebKitTools/DumpRenderTree/chromium/ImageDiff.cpp @@ -36,7 +36,7 @@ #include "config.h" -#include "gfx/codec/png_codec.h" +#include "webkit/support/webkit_support_gfx.h" #include <algorithm> #include <stdio.h> #include <string.h> @@ -49,7 +49,6 @@ #define PATH_MAX MAX_PATH #endif -using namespace gfx; using namespace std; // Causes the app to remain open, waiting for pairs of filenames on stdin. @@ -93,8 +92,7 @@ public: if (fread(source.get(), 1, byteLength, stdin) != byteLength) return false; - if (!PNGCodec::Decode(source.get(), byteLength, PNGCodec::FORMAT_RGBA, - &m_data, &m_width, &m_height)) { + if (!webkit_support::DecodePNG(source.get(), byteLength, &m_data, &m_width, &m_height)) { clear(); return false; } @@ -118,8 +116,7 @@ public: fclose(f); - if (!PNGCodec::Decode(&compressed[0], compressed.size(), - PNGCodec::FORMAT_RGBA, &m_data, &m_width, &m_height)) { + if (!webkit_support::DecodePNG(&compressed[0], compressed.size(), &m_data, &m_width, &m_height)) { clear(); return false; } @@ -353,8 +350,8 @@ int diffImages(const char* file1, const char* file2, const char* outFile) return statusSame; vector<unsigned char> pngData; - PNGCodec::Encode(diffImage.data(), PNGCodec::FORMAT_RGBA, diffImage.width(), - diffImage.height(), diffImage.width() * 4, false, &pngData); + webkit_support::EncodeRGBAPNG(diffImage.data(), diffImage.width(), diffImage.height(), + diffImage.width() * 4, &pngData); if (!writeFile(outFile, &pngData.front(), pngData.size())) return statusError; return statusDifferent; diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp index 6f962bf..2c6c600 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp @@ -38,6 +38,7 @@ #include "public/WebAnimationController.h" #include "public/WebBindings.h" #include "public/WebConsoleMessage.h" +#include "public/WebData.h" #include "public/WebDeviceOrientation.h" #include "public/WebDeviceOrientationClientMock.h" #include "public/WebDocument.h" @@ -77,113 +78,112 @@ 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("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteboardOnDrag); + bindMethod("addOriginAccessWhitelistEntry", &LayoutTestController::addOriginAccessWhitelistEntry); + bindMethod("addUserScript", &LayoutTestController::addUserScript); + bindMethod("addUserStyleSheet", &LayoutTestController::addUserStyleSheet); + bindMethod("clearAllDatabases", &LayoutTestController::clearAllDatabases); + bindMethod("closeWebInspector", &LayoutTestController::closeWebInspector); + bindMethod("counterValueForElementById", &LayoutTestController::counterValueForElementById); + bindMethod("disableImageLoading", &LayoutTestController::disableImageLoading); + bindMethod("display", &LayoutTestController::display); bindMethod("dumpAsText", &LayoutTestController::dumpAsText); - bindMethod("dumpChildFrameScrollPositions", &LayoutTestController::dumpChildFrameScrollPositions); + bindMethod("dumpBackForwardList", &LayoutTestController::dumpBackForwardList); bindMethod("dumpChildFramesAsText", &LayoutTestController::dumpChildFramesAsText); + bindMethod("dumpChildFrameScrollPositions", &LayoutTestController::dumpChildFrameScrollPositions); bindMethod("dumpDatabaseCallbacks", &LayoutTestController::dumpDatabaseCallbacks); bindMethod("dumpEditingCallbacks", &LayoutTestController::dumpEditingCallbacks); - bindMethod("dumpBackForwardList", &LayoutTestController::dumpBackForwardList); bindMethod("dumpFrameLoadCallbacks", &LayoutTestController::dumpFrameLoadCallbacks); bindMethod("dumpResourceLoadCallbacks", &LayoutTestController::dumpResourceLoadCallbacks); + bindMethod("dumpResourceResponseMIMETypes", &LayoutTestController::dumpResourceResponseMIMETypes); + bindMethod("dumpSelectionRect", &LayoutTestController::dumpSelectionRect); bindMethod("dumpStatusCallbacks", &LayoutTestController::dumpWindowStatusChanges); bindMethod("dumpTitleChanges", &LayoutTestController::dumpTitleChanges); - bindMethod("setAcceptsEditing", &LayoutTestController::setAcceptsEditing); - bindMethod("waitUntilDone", &LayoutTestController::waitUntilDone); + bindMethod("elementDoesAutoCompleteForElementWithId", &LayoutTestController::elementDoesAutoCompleteForElementWithId); + bindMethod("evaluateInWebInspector", &LayoutTestController::evaluateInWebInspector); + bindMethod("evaluateScriptInIsolatedWorld", &LayoutTestController::evaluateScriptInIsolatedWorld); + bindMethod("execCommand", &LayoutTestController::execCommand); + bindMethod("forceRedSelectionColors", &LayoutTestController::forceRedSelectionColors); + bindMethod("grantDesktopNotificationPermission", &LayoutTestController::grantDesktopNotificationPermission); + bindMethod("isCommandEnabled", &LayoutTestController::isCommandEnabled); + bindMethod("markerTextForListItem", &LayoutTestController::markerTextForListItem); 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("numberOfActiveAnimations", &LayoutTestController::numberOfActiveAnimations); + bindMethod("numberOfPages", &LayoutTestController::numberOfPages); 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("overridePreference", &LayoutTestController::overridePreference); + bindMethod("pageNumberForElementById", &LayoutTestController::pageNumberForElementById); 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("elementDoesAutoCompleteForElementWithId", &LayoutTestController::elementDoesAutoCompleteForElementWithId); - bindMethod("numberOfActiveAnimations", &LayoutTestController::numberOfActiveAnimations); - bindMethod("suspendAnimations", &LayoutTestController::suspendAnimations); + bindMethod("queueBackNavigation", &LayoutTestController::queueBackNavigation); + bindMethod("queueForwardNavigation", &LayoutTestController::queueForwardNavigation); + bindMethod("queueLoadingScript", &LayoutTestController::queueLoadingScript); + bindMethod("queueLoad", &LayoutTestController::queueLoad); + bindMethod("queueLoadHTMLString", &LayoutTestController::queueLoadHTMLString); + bindMethod("queueNonLoadingScript", &LayoutTestController::queueNonLoadingScript); + bindMethod("queueReload", &LayoutTestController::queueReload); + bindMethod("removeOriginAccessWhitelistEntry", &LayoutTestController::removeOriginAccessWhitelistEntry); + bindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHorizontally); bindMethod("resumeAnimations", &LayoutTestController::resumeAnimations); - bindMethod("disableImageLoading", &LayoutTestController::disableImageLoading); - bindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEnabled); + bindMethod("setAcceptsEditing", &LayoutTestController::setAcceptsEditing); + bindMethod("setAllowFileAccessFromFileURLs", &LayoutTestController::setAllowFileAccessFromFileURLs); + bindMethod("setAllowUniversalAccessFromFileURLs", &LayoutTestController::setAllowUniversalAccessFromFileURLs); + bindMethod("setAlwaysAcceptCookies", &LayoutTestController::setAlwaysAcceptCookies); + bindMethod("setAuthorAndUserStylesEnabled", &LayoutTestController::setAuthorAndUserStylesEnabled); + bindMethod("setCanOpenWindows", &LayoutTestController::setCanOpenWindows); + bindMethod("setCloseRemainingWindowsWhenComplete", &LayoutTestController::setCloseRemainingWindowsWhenComplete); bindMethod("setCustomPolicyDelegate", &LayoutTestController::setCustomPolicyDelegate); + bindMethod("setDatabaseQuota", &LayoutTestController::setDatabaseQuota); + bindMethod("setDeferMainResourceDataLoad", &LayoutTestController::setDeferMainResourceDataLoad); + bindMethod("setDomainRelaxationForbiddenForURLScheme", &LayoutTestController::setDomainRelaxationForbiddenForURLScheme); + bindMethod("setEditingBehavior", &LayoutTestController::setEditingBehavior); + bindMethod("setGeolocationPermission", &LayoutTestController::setGeolocationPermission); + bindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEnabled); + bindMethod("setJavaScriptCanAccessClipboard", &LayoutTestController::setJavaScriptCanAccessClipboard); + bindMethod("setMockDeviceOrientation", &LayoutTestController::setMockDeviceOrientation); + bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError); + bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition); + bindMethod("setMockSpeechInputResult", &LayoutTestController::setMockSpeechInputResult); + bindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingEnabled); + bindMethod("setPOSIXLocale", &LayoutTestController::setPOSIXLocale); bindMethod("setScrollbarPolicy", &LayoutTestController::setScrollbarPolicy); - bindMethod("waitForPolicyDelegate", &LayoutTestController::waitForPolicyDelegate); + bindMethod("setSelectTrailingWhitespaceEnabled", &LayoutTestController::setSelectTrailingWhitespaceEnabled); + bindMethod("setSmartInsertDeleteEnabled", &LayoutTestController::setSmartInsertDeleteEnabled); + bindMethod("setStopProvisionalFrameLoads", &LayoutTestController::setStopProvisionalFrameLoads); + bindMethod("setTabKeyCyclesThroughElements", &LayoutTestController::setTabKeyCyclesThroughElements); + bindMethod("setTimelineProfilingEnabled", &LayoutTestController::setTimelineProfilingEnabled); + bindMethod("setUserStyleSheetEnabled", &LayoutTestController::setUserStyleSheetEnabled); + bindMethod("setUserStyleSheetLocation", &LayoutTestController::setUserStyleSheetLocation); 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("dumpSelectionRect", &LayoutTestController::dumpSelectionRect); - bindMethod("grantDesktopNotificationPermission", &LayoutTestController::grantDesktopNotificationPermission); + bindMethod("setWillSendRequestReturnsNullOnRedirect", &LayoutTestController::setWillSendRequestReturnsNullOnRedirect); + bindMethod("setWindowIsKey", &LayoutTestController::setWindowIsKey); + bindMethod("setXSSAuditorEnabled", &LayoutTestController::setXSSAuditorEnabled); + bindMethod("showWebInspector", &LayoutTestController::showWebInspector); bindMethod("simulateDesktopNotificationClick", &LayoutTestController::simulateDesktopNotificationClick); + bindMethod("suspendAnimations", &LayoutTestController::suspendAnimations); + bindMethod("testRepaint", &LayoutTestController::testRepaint); + bindMethod("waitForPolicyDelegate", &LayoutTestController::waitForPolicyDelegate); + bindMethod("waitUntilDone", &LayoutTestController::waitUntilDone); + bindMethod("windowCount", &LayoutTestController::windowCount); // The following are stubs. - bindMethod("dumpAsWebArchive", &LayoutTestController::dumpAsWebArchive); - bindMethod("setMainFrameIsFirstResponder", &LayoutTestController::setMainFrameIsFirstResponder); - bindMethod("dumpSelectionRect", &LayoutTestController::dumpSelectionRect); - bindMethod("display", &LayoutTestController::display); - bindMethod("testRepaint", &LayoutTestController::testRepaint); - bindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHorizontally); - bindMethod("clearBackForwardList", &LayoutTestController::clearBackForwardList); - bindMethod("keepWebHistory", &LayoutTestController::keepWebHistory); - bindMethod("storeWebScriptObject", &LayoutTestController::storeWebScriptObject); + bindMethod("abortModal", &LayoutTestController::abortModal); bindMethod("accessStoredWebScriptObject", &LayoutTestController::accessStoredWebScriptObject); - bindMethod("objCClassNameOf", &LayoutTestController::objCClassNameOf); bindMethod("addDisallowedURL", &LayoutTestController::addDisallowedURL); bindMethod("callShouldCloseOnWebView", &LayoutTestController::callShouldCloseOnWebView); + bindMethod("clearAllApplicationCaches", &LayoutTestController::clearAllApplicationCaches); + bindMethod("clearBackForwardList", &LayoutTestController::clearBackForwardList); + bindMethod("dumpAsWebArchive", &LayoutTestController::dumpAsWebArchive); + bindMethod("keepWebHistory", &LayoutTestController::keepWebHistory); + bindMethod("objCClassNameOf", &LayoutTestController::objCClassNameOf); + bindMethod("setApplicationCacheOriginQuota", &LayoutTestController::setApplicationCacheOriginQuota); bindMethod("setCallCloseOnWebViews", &LayoutTestController::setCallCloseOnWebViews); + bindMethod("setMainFrameIsFirstResponder", &LayoutTestController::setMainFrameIsFirstResponder); bindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrowsingEnabled); bindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDashboardCompatibilityMode); - bindMethod("clearAllApplicationCaches", &LayoutTestController::clearAllApplicationCaches); - bindMethod("setApplicationCacheOriginQuota", &LayoutTestController::setApplicationCacheOriginQuota); - - 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("setTimelineProfilingEnabled", &LayoutTestController::setTimelineProfilingEnabled); - bindMethod("evaluateInWebInspector", &LayoutTestController::evaluateInWebInspector); - bindMethod("forceRedSelectionColors", &LayoutTestController::forceRedSelectionColors); - bindMethod("setEditingBehavior", &LayoutTestController::setEditingBehavior); - - bindMethod("setMockDeviceOrientation", &LayoutTestController::setMockDeviceOrientation); - - bindMethod("setGeolocationPermission", &LayoutTestController::setGeolocationPermission); - bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition); - bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError); - bindMethod("abortModal", &LayoutTestController::abortModal); - bindMethod("setMockSpeechInputResult", &LayoutTestController::setMockSpeechInputResult); - - bindMethod("markerTextForListItem", &LayoutTestController::markerTextForListItem); + bindMethod("storeWebScriptObject", &LayoutTestController::storeWebScriptObject); // The fallback method is called when an unknown method is invoked. bindFallbackMethod(&LayoutTestController::fallbackMethod); @@ -291,6 +291,12 @@ void LayoutTestController::dumpResourceLoadCallbacks(const CppArgumentList&, Cpp result->setNull(); } +void LayoutTestController::dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant* result) +{ + m_dumpResourceResponseMIMETypes = true; + result->setNull(); +} + void LayoutTestController::dumpChildFrameScrollPositions(const CppArgumentList&, CppVariant* result) { m_dumpChildFrameScrollPositions = true; @@ -460,6 +466,34 @@ void LayoutTestController::queueLoad(const CppArgumentList& arguments, CppVarian result->setNull(); } +class WorkItemLoadHTMLString : public LayoutTestController::WorkItem { +public: + WorkItemLoadHTMLString(const std::string& html, const WebURL& baseURL) + : m_html(html) + , m_baseURL(baseURL) {} + bool run(TestShell* shell) + { + shell->webView()->mainFrame()->loadHTMLString( + WebKit::WebData(m_html.data(), m_html.length()), m_baseURL); + return true; + } +private: + std::string m_html; + WebURL m_baseURL; +}; + +void LayoutTestController::queueLoadHTMLString(const CppArgumentList& arguments, CppVariant* result) +{ + if (arguments.size() > 0 && arguments[0].isString()) { + string html = arguments[0].toString(); + WebURL baseURL; + if (arguments.size() > 1 && arguments[1].isString()) + baseURL = WebURL(GURL(arguments[1].toString())); + m_workQueue.addWork(new WorkItemLoadHTMLString(html, baseURL)); + } + result->setNull(); +} + void LayoutTestController::objCIdentityIsEqual(const CppArgumentList& arguments, CppVariant* result) { if (arguments.size() < 2) { @@ -486,6 +520,7 @@ void LayoutTestController::reset() m_dumpEditingCallbacks = false; m_dumpFrameLoadCallbacks = false; m_dumpResourceLoadCallbacks = false; + m_dumpResourceResponseMIMETypes = false; m_dumpBackForwardList = false; m_dumpChildFrameScrollPositions = false; m_dumpChildFramesAsText = false; @@ -500,6 +535,7 @@ void LayoutTestController::reset() m_sweepHorizontally = false; m_shouldAddFileToPasteboard = false; m_stopProvisionalFrameLoads = false; + m_deferMainResourceDataLoad = true; m_globalFlag.set(false); m_webHistoryItemCount.set(0); m_userStyleSheetLocation = WebURL(); @@ -591,24 +627,30 @@ void LayoutTestController::setWindowIsKey(const CppArgumentList& arguments, CppV void LayoutTestController::setUserStyleSheetEnabled(const CppArgumentList& arguments, CppVariant* result) { - if (arguments.size() > 0 && arguments[0].isBool()) - m_shell->webView()->settings()->setUserStyleSheetLocation(arguments[0].value.boolValue ? m_userStyleSheetLocation : WebURL()); + if (arguments.size() > 0 && arguments[0].isBool()) { + m_shell->preferences()->userStyleSheetLocation = arguments[0].value.boolValue ? m_userStyleSheetLocation : WebURL(); + m_shell->applyPreferences(); + } result->setNull(); } void LayoutTestController::setUserStyleSheetLocation(const CppArgumentList& arguments, CppVariant* result) { if (arguments.size() > 0 && arguments[0].isString()) { - m_userStyleSheetLocation = webkit_support::RewriteLayoutTestsURL(arguments[0].toString()); - m_shell->webView()->settings()->setUserStyleSheetLocation(m_userStyleSheetLocation); + m_userStyleSheetLocation = webkit_support::LocalFileToDataURL( + webkit_support::RewriteLayoutTestsURL(arguments[0].toString())); + m_shell->preferences()->userStyleSheetLocation = m_userStyleSheetLocation; + m_shell->applyPreferences(); } result->setNull(); } void LayoutTestController::setAuthorAndUserStylesEnabled(const CppArgumentList& arguments, CppVariant* result) { - if (arguments.size() > 0 && arguments[0].isBool()) - m_shell->webView()->settings()->setAuthorAndUserStylesEnabled(arguments[0].value.boolValue); + if (arguments.size() > 0 && arguments[0].isBool()) { + m_shell->preferences()->authorAndUserStylesEnabled = arguments[0].value.boolValue; + m_shell->applyPreferences(); + } result->setNull(); } @@ -645,7 +687,8 @@ void LayoutTestController::setPopupBlockingEnabled(const CppArgumentList& argume { if (arguments.size() > 0 && arguments[0].isBool()) { bool blockPopups = arguments[0].toBoolean(); - m_shell->webView()->settings()->setJavaScriptCanOpenWindowsAutomatically(!blockPopups); + m_shell->preferences()->javaScriptCanOpenWindowsAutomatically = !blockPopups; + m_shell->applyPreferences(); } result->setNull(); } @@ -918,7 +961,8 @@ void LayoutTestController::resumeAnimations(const CppArgumentList&, CppVariant* void LayoutTestController::disableImageLoading(const CppArgumentList&, CppVariant* result) { - m_shell->webView()->settings()->setLoadsImagesAutomatically(false); + m_shell->preferences()->loadsImagesAutomatically = false; + m_shell->applyPreferences(); result->setNull(); } @@ -955,6 +999,19 @@ void LayoutTestController::simulateDesktopNotificationClick(const CppArgumentLis result->set(false); } +void LayoutTestController::setDomainRelaxationForbiddenForURLScheme(const CppArgumentList& arguments, CppVariant* result) +{ + if (arguments.size() != 2 || !arguments[0].isBool() || !arguments[1].isString()) + return; + m_shell->webView()->setDomainRelaxationForbidden(cppVariantToBool(arguments[0]), cppVariantToWebString(arguments[1])); +} + +void LayoutTestController::setDeferMainResourceDataLoad(const CppArgumentList& arguments, CppVariant* result) +{ + if (arguments.size() == 1) + m_deferMainResourceDataLoad = cppVariantToBool(arguments[0]); +} + // // Unimplemented stubs // @@ -1027,6 +1084,7 @@ void LayoutTestController::addDisallowedURL(const CppArgumentList& arguments, Cp { result->setNull(); } + void LayoutTestController::setCallCloseOnWebViews(const CppArgumentList& arguments, CppVariant* result) { result->setNull(); @@ -1039,15 +1097,19 @@ void LayoutTestController::setPrivateBrowsingEnabled(const CppArgumentList& argu void LayoutTestController::setJavaScriptCanAccessClipboard(const CppArgumentList& arguments, CppVariant* result) { - if (arguments.size() > 0 && arguments[0].isBool()) - m_shell->webView()->settings()->setJavaScriptCanAccessClipboard(arguments[0].value.boolValue); + if (arguments.size() > 0 && arguments[0].isBool()) { + m_shell->preferences()->javaScriptCanAccessClipboard = arguments[0].value.boolValue; + m_shell->applyPreferences(); + } result->setNull(); } void LayoutTestController::setXSSAuditorEnabled(const CppArgumentList& arguments, CppVariant* result) { - if (arguments.size() > 0 && arguments[0].isBool()) - m_shell->webView()->settings()->setXSSAuditorEnabled(arguments[0].value.boolValue); + if (arguments.size() > 0 && arguments[0].isBool()) { + m_shell->preferences()->XSSAuditorEnabled = arguments[0].value.boolValue; + m_shell->applyPreferences(); + } result->setNull(); } @@ -1064,15 +1126,19 @@ void LayoutTestController::evaluateScriptInIsolatedWorld(const CppArgumentList& void LayoutTestController::setAllowUniversalAccessFromFileURLs(const CppArgumentList& arguments, CppVariant* result) { - if (arguments.size() > 0 && arguments[0].isBool()) - m_shell->webView()->settings()->setAllowUniversalAccessFromFileURLs(arguments[0].value.boolValue); + if (arguments.size() > 0 && arguments[0].isBool()) { + m_shell->preferences()->allowUniversalAccessFromFileURLs = arguments[0].value.boolValue; + m_shell->applyPreferences(); + } result->setNull(); } void LayoutTestController::setAllowFileAccessFromFileURLs(const CppArgumentList& arguments, CppVariant* result) { - if (arguments.size() > 0 && arguments[0].isBool()) - m_shell->webView()->settings()->setAllowFileAccessFromFileURLs(arguments[0].value.boolValue); + if (arguments.size() > 0 && arguments[0].isBool()) { + m_shell->preferences()->allowFileAccessFromFileURLs = arguments[0].value.boolValue; + m_shell->applyPreferences(); + } result->setNull(); } @@ -1128,68 +1194,69 @@ void LayoutTestController::overridePreference(const CppArgumentList& arguments, string key = arguments[0].toString(); CppVariant value = arguments[1]; - WebSettings* settings = m_shell->webView()->settings(); + WebPreferences* prefs = m_shell->preferences(); if (key == "WebKitStandardFont") - settings->setStandardFontFamily(cppVariantToWebString(value)); + prefs->standardFontFamily = cppVariantToWebString(value); else if (key == "WebKitFixedFont") - settings->setFixedFontFamily(cppVariantToWebString(value)); + prefs->fixedFontFamily = cppVariantToWebString(value); else if (key == "WebKitSerifFont") - settings->setSerifFontFamily(cppVariantToWebString(value)); + prefs->serifFontFamily = cppVariantToWebString(value); else if (key == "WebKitSansSerifFont") - settings->setSansSerifFontFamily(cppVariantToWebString(value)); + prefs->sansSerifFontFamily = cppVariantToWebString(value); else if (key == "WebKitCursiveFont") - settings->setCursiveFontFamily(cppVariantToWebString(value)); + prefs->cursiveFontFamily = cppVariantToWebString(value); else if (key == "WebKitFantasyFont") - settings->setFantasyFontFamily(cppVariantToWebString(value)); + prefs->fantasyFontFamily = cppVariantToWebString(value); else if (key == "WebKitDefaultFontSize") - settings->setDefaultFontSize(cppVariantToInt32(value)); + prefs->defaultFontSize = cppVariantToInt32(value); else if (key == "WebKitDefaultFixedFontSize") - settings->setDefaultFixedFontSize(cppVariantToInt32(value)); + prefs->defaultFixedFontSize = cppVariantToInt32(value); else if (key == "WebKitMinimumFontSize") - settings->setMinimumFontSize(cppVariantToInt32(value)); + prefs->minimumFontSize = cppVariantToInt32(value); else if (key == "WebKitMinimumLogicalFontSize") - settings->setMinimumLogicalFontSize(cppVariantToInt32(value)); + prefs->minimumLogicalFontSize = cppVariantToInt32(value); else if (key == "WebKitDefaultTextEncodingName") - settings->setDefaultTextEncodingName(cppVariantToWebString(value)); + prefs->defaultTextEncodingName = cppVariantToWebString(value); else if (key == "WebKitJavaScriptEnabled") - settings->setJavaScriptEnabled(cppVariantToBool(value)); + prefs->javaScriptEnabled = cppVariantToBool(value); else if (key == "WebKitWebSecurityEnabled") - settings->setWebSecurityEnabled(cppVariantToBool(value)); + prefs->webSecurityEnabled = cppVariantToBool(value); else if (key == "WebKitJavaScriptCanOpenWindowsAutomatically") - settings->setJavaScriptCanOpenWindowsAutomatically(cppVariantToBool(value)); + prefs->javaScriptCanOpenWindowsAutomatically = cppVariantToBool(value); else if (key == "WebKitDisplayImagesKey") - settings->setLoadsImagesAutomatically(cppVariantToBool(value)); + prefs->loadsImagesAutomatically = cppVariantToBool(value); else if (key == "WebKitPluginsEnabled") - settings->setPluginsEnabled(cppVariantToBool(value)); + prefs->pluginsEnabled = cppVariantToBool(value); else if (key == "WebKitDOMPasteAllowedPreferenceKey") - settings->setDOMPasteAllowed(cppVariantToBool(value)); + prefs->DOMPasteAllowed = cppVariantToBool(value); else if (key == "WebKitDeveloperExtrasEnabledPreferenceKey") - settings->setDeveloperExtrasEnabled(cppVariantToBool(value)); + prefs->developerExtrasEnabled = cppVariantToBool(value); else if (key == "WebKitShrinksStandaloneImagesToFit") - settings->setShrinksStandaloneImagesToFit(cppVariantToBool(value)); + prefs->shrinksStandaloneImagesToFit = cppVariantToBool(value); else if (key == "WebKitTextAreasAreResizable") - settings->setTextAreasAreResizable(cppVariantToBool(value)); + prefs->textAreasAreResizable = cppVariantToBool(value); else if (key == "WebKitJavaEnabled") - settings->setJavaEnabled(cppVariantToBool(value)); + prefs->javaEnabled = cppVariantToBool(value); else if (key == "WebKitUsesPageCachePreferenceKey") - settings->setUsesPageCache(cppVariantToBool(value)); + prefs->usesPageCache = cppVariantToBool(value); else if (key == "WebKitJavaScriptCanAccessClipboard") - settings->setJavaScriptCanAccessClipboard(cppVariantToBool(value)); + prefs->javaScriptCanAccessClipboard = cppVariantToBool(value); else if (key == "WebKitXSSAuditorEnabled") - settings->setXSSAuditorEnabled(cppVariantToBool(value)); + prefs->XSSAuditorEnabled = cppVariantToBool(value); else if (key == "WebKitLocalStorageEnabledPreferenceKey") - settings->setLocalStorageEnabled(cppVariantToBool(value)); + prefs->localStorageEnabled = cppVariantToBool(value); else if (key == "WebKitOfflineWebApplicationCacheEnabled") - settings->setOfflineWebApplicationCacheEnabled(cppVariantToBool(value)); + prefs->offlineWebApplicationCacheEnabled = cppVariantToBool(value); else if (key == "WebKitTabToLinksPreferenceKey") - m_shell->webView()->setTabsToLinks(cppVariantToBool(value)); + prefs->tabsToLinks = cppVariantToBool(value); else if (key == "WebKitWebGLEnabled") - settings->setExperimentalWebGLEnabled(cppVariantToBool(value)); + prefs->experimentalWebGLEnabled = cppVariantToBool(value); else { string message("Invalid name for preference: "); message.append(key); logErrorToConsole(message); } + m_shell->applyPreferences(); } void LayoutTestController::fallbackMethod(const CppArgumentList&, CppVariant* result) @@ -1381,13 +1448,14 @@ void LayoutTestController::addUserStyleSheet(const CppArgumentList& arguments, C 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 + if (key == "mac") { + m_shell->preferences()->editingBehavior = WebSettings::EditingBehaviorMac; + m_shell->applyPreferences(); + } else if (key == "win") { + m_shell->preferences()->editingBehavior = WebSettings::EditingBehaviorWin; + m_shell->applyPreferences(); + } else logErrorToConsole("Passed invalid editing behavior. Should be 'mac' or 'win'."); } @@ -1397,7 +1465,7 @@ void LayoutTestController::setMockDeviceOrientation(const CppArgumentList& argum if (arguments.size() < 6 || !arguments[0].isBool() || !arguments[1].isNumber() || !arguments[2].isBool() || !arguments[3].isNumber() || !arguments[4].isBool() || !arguments[5].isNumber()) return; - WebKit::WebDeviceOrientation orientation(arguments[0].toBoolean(), arguments[1].toDouble(), arguments[2].toBoolean(), arguments[3].toDouble(), arguments[4].toBoolean(), arguments[5].toDouble()); + WebDeviceOrientation orientation(arguments[0].toBoolean(), arguments[1].toDouble(), arguments[2].toBoolean(), arguments[3].toDouble(), arguments[4].toBoolean(), arguments[5].toDouble()); ASSERT(m_deviceOrientationClientMock); m_deviceOrientationClientMock->setOrientation(orientation); @@ -1457,9 +1525,9 @@ void LayoutTestController::markerTextForListItem(const CppArgumentList& args, Cp result->set(element.document().frame()->markerTextForListItem(element).utf8()); } -WebKit::WebDeviceOrientationClient* LayoutTestController::deviceOrientationClient() +WebDeviceOrientationClient* LayoutTestController::deviceOrientationClient() { if (!m_deviceOrientationClientMock.get()) - m_deviceOrientationClientMock.set(new WebKit::WebDeviceOrientationClientMock()); + m_deviceOrientationClientMock.set(WebDeviceOrientationClientMock::create()); return m_deviceOrientationClientMock.get(); } diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h index 7bb22ca..ec2503f 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h @@ -100,6 +100,16 @@ public: // dump all frames as plain text if the dumpAsText flag is set. // It takes no arguments, and ignores any that may be present. void dumpChildFramesAsText(const CppArgumentList&, CppVariant*); + + // This function sets a flag that tells the test_shell to dump a descriptive + // line for each resource load callback. It takes no arguments, and ignores + // any that may be present. + void dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant*); + + // This function sets a flag that tells the test_shell to dump the MIME type + // for each resource that was loaded. It takes no arguments, and ignores any + // that may be present. + void dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant*); // This function sets a flag that tells the test_shell to dump all calls // to window.status(). @@ -129,6 +139,7 @@ public: void queueLoadingScript(const CppArgumentList&, CppVariant*); void queueNonLoadingScript(const CppArgumentList&, CppVariant*); void queueLoad(const CppArgumentList&, CppVariant*); + void queueLoadHTMLString(const CppArgumentList&, CppVariant*); // Although this is named "objC" to match the Mac version, it actually tests // the identity of its two arguments in C++. @@ -212,11 +223,8 @@ public: void numberOfActiveAnimations(const CppArgumentList&, CppVariant*); void suspendAnimations(const CppArgumentList&, CppVariant*); void resumeAnimations(const CppArgumentList&, CppVariant*); - void disableImageLoading(const CppArgumentList&, CppVariant*); - void setIconDatabaseEnabled(const CppArgumentList&, CppVariant*); - void dumpSelectionRect(const CppArgumentList&, CppVariant*); // Grants permission for desktop notifications to an origin @@ -224,13 +232,14 @@ public: // Simulates a click on a desktop notification. void simulateDesktopNotificationClick(const CppArgumentList&, CppVariant*); + void setDomainRelaxationForbiddenForURLScheme(const CppArgumentList&, CppVariant*); + void setDeferMainResourceDataLoad(const CppArgumentList&, CppVariant*); 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 dumpAsWebArchive(const CppArgumentList&, CppVariant*); void dumpTitleChanges(const CppArgumentList&, CppVariant*); - void dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant*); void setMainFrameIsFirstResponder(const CppArgumentList&, CppVariant*); void display(const CppArgumentList&, CppVariant*); void testRepaint(const CppArgumentList&, CppVariant*); @@ -328,6 +337,8 @@ public: bool shouldDumpFrameLoadCallbacks() { return m_dumpFrameLoadCallbacks; } void setShouldDumpFrameLoadCallbacks(bool value) { m_dumpFrameLoadCallbacks = value; } bool shouldDumpResourceLoadCallbacks() {return m_dumpResourceLoadCallbacks; } + void setShouldDumpResourceResponseMIMETypes(bool value) { m_dumpResourceResponseMIMETypes = value; } + bool shouldDumpResourceResponseMIMETypes() {return m_dumpResourceResponseMIMETypes; } bool shouldDumpStatusCallbacks() { return m_dumpWindowStatusChanges; } bool shouldDumpSelectionRect() { return m_dumpSelectionRect; } bool shouldDumpBackForwardList() { return m_dumpBackForwardList; } @@ -339,6 +350,7 @@ public: bool canOpenWindows() { return m_canOpenWindows; } bool shouldAddFileToPasteboard() { return m_shouldAddFileToPasteboard; } bool stopProvisionalFrameLoads() { return m_stopProvisionalFrameLoads; } + bool deferMainResourceDataLoad() { return m_deferMainResourceDataLoad; } bool testRepaint() const { return m_testRepaint; } bool sweepHorizontally() const { return m_sweepHorizontally; } @@ -447,6 +459,10 @@ private: // If true, the test_shell will output a descriptive line for each resource // load callback. bool m_dumpResourceLoadCallbacks; + + // If true, the test_shell will output the MIME type for each resource that + // was loaded. + bool m_dumpResourceResponseMIMETypes; // If true, the test_shell will produce a dump of the back forward list as // well. @@ -501,6 +517,9 @@ private: // If true, don't dump output until notifyDone is called. bool m_waitUntilDone; + // If false, all new requests will not defer the main resource data load. + bool m_deferMainResourceDataLoad; + WorkQueue m_workQueue; CppVariant m_globalFlag; diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp index 4557803..15d6dee 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp @@ -35,8 +35,6 @@ #include "DRTDevToolsClient.h" #include "LayoutTestController.h" #include "WebViewHost.h" -#include "base/string16.h" -#include "gfx/codec/png_codec.h" // FIXME: Remove dependecy. WebCore/platform/image-encoder is better? #include "public/WebDataSource.h" #include "public/WebDocument.h" #include "public/WebElement.h" @@ -55,6 +53,7 @@ #include "skia/ext/bitmap_platform_device.h" #include "skia/ext/platform_canvas.h" #include "webkit/support/webkit_support.h" +#include "webkit/support/webkit_support_gfx.h" #include <algorithm> #include <cctype> #include <vector> @@ -155,84 +154,8 @@ void TestShell::closeDevTools() void TestShell::resetWebSettings(WebView& webView) { - // Match the settings used by Mac DumpRenderTree, with the exception of - // fonts. - WebSettings* settings = webView.settings(); -#if OS(MAC_OS_X) - WebString serif = WebString::fromUTF8("Times"); - settings->setCursiveFontFamily(WebString::fromUTF8("Apple Chancery")); - settings->setFantasyFontFamily(WebString::fromUTF8("Papyrus")); -#else - // NOTE: case matters here, this must be 'times new roman', else - // some layout tests fail. - WebString serif = WebString::fromUTF8("times new roman"); - - // These two fonts are picked from the intersection of - // Win XP font list and Vista font list : - // http://www.microsoft.com/typography/fonts/winxp.htm - // http://blogs.msdn.com/michkap/archive/2006/04/04/567881.aspx - // Some of them are installed only with CJK and complex script - // support enabled on Windows XP and are out of consideration here. - // (although we enabled both on our buildbots.) - // They (especially Impact for fantasy) are not typical cursive - // and fantasy fonts, but it should not matter for layout tests - // as long as they're available. - settings->setCursiveFontFamily(WebString::fromUTF8("Comic Sans MS")); - settings->setFantasyFontFamily(WebString::fromUTF8("Impact")); -#endif - settings->setSerifFontFamily(serif); - settings->setStandardFontFamily(serif); - settings->setFixedFontFamily(WebString::fromUTF8("Courier")); - settings->setSansSerifFontFamily(WebString::fromUTF8("Helvetica")); - - settings->setDefaultTextEncodingName(WebString::fromUTF8("ISO-8859-1")); - settings->setDefaultFontSize(16); - settings->setDefaultFixedFontSize(13); - settings->setMinimumFontSize(1); - settings->setMinimumLogicalFontSize(9); - settings->setJavaScriptCanOpenWindowsAutomatically(true); - settings->setJavaScriptCanAccessClipboard(true); - settings->setDOMPasteAllowed(true); - settings->setDeveloperExtrasEnabled(false); - settings->setNeedsSiteSpecificQuirks(true); - settings->setShrinksStandaloneImagesToFit(false); - settings->setUsesEncodingDetector(false); - settings->setTextAreasAreResizable(false); - settings->setJavaEnabled(false); - settings->setAllowScriptsToCloseWindows(false); - settings->setXSSAuditorEnabled(false); - settings->setDownloadableBinaryFontsEnabled(true); - settings->setLocalStorageEnabled(true); - settings->setOfflineWebApplicationCacheEnabled(true); - settings->setAllowFileAccessFromFileURLs(true); - settings->setUserStyleSheetLocation(WebURL()); - - // LayoutTests were written with Safari Mac in mind which does not allow - // tabbing to links by default. - webView.setTabsToLinks(false); - - // Allow those layout tests running as local files, i.e. under - // LayoutTests/http/tests/local, to access http server. - settings->setAllowUniversalAccessFromFileURLs(true); - - settings->setJavaScriptEnabled(true); - settings->setPluginsEnabled(true); - settings->setWebSecurityEnabled(true); - settings->setEditableLinkBehaviorNeverLive(); - settings->setFontRenderingModeNormal(); - settings->setShouldPaintCustomScrollbars(true); - settings->setTextDirectionSubmenuInclusionBehaviorNeverIncluded(); - - settings->setLoadsImagesAutomatically(true); - settings->setImagesEnabled(true); - -#if OS(DARWIN) - settings->setEditingBehavior(WebSettings::EditingBehaviorMac); -#else - settings->setEditingBehavior(WebSettings::EditingBehaviorWin); -#endif - // FIXME: crbug.com/51879 - settings->setAcceleratedCompositingEnabled(false); + m_prefs.reset(); + m_prefs.applyTo(&webView); } void TestShell::runFileTest(const TestParams& params) @@ -244,7 +167,8 @@ void TestShell::runFileTest(const TestParams& params) bool inspectorTestMode = testUrl.find("/inspector/") != string::npos || testUrl.find("\\inspector\\") != string::npos; - m_webView->settings()->setDeveloperExtrasEnabled(inspectorTestMode); + m_prefs.developerExtrasEnabled = inspectorTestMode; + applyPreferences(); if (testUrl.find("loading/") != string::npos || testUrl.find("loading\\") != string::npos) @@ -585,23 +509,15 @@ void TestShell::dumpImage(skia::PlatformCanvas* canvas) const // to keep it. On Windows, the alpha channel is wrong since text/form control // drawing may have erased it in a few places. So on Windows we force it to // opaque and also don't write the alpha channel for the reference. Linux - // doesn't have the wrong alpha like Windows, but we ignore it anyway. -#if OS(WINDOWS) - bool discardTransparency = true; - device.makeOpaque(0, 0, sourceBitmap.width(), sourceBitmap.height()); -#elif OS(MAC_OS_X) + // doesn't have the wrong alpha like Windows, but we match Windows. +#if OS(MAC_OS_X) bool discardTransparency = false; -#elif OS(UNIX) +#else bool discardTransparency = true; - if (areLayoutTestImagesOpaque()) - device.makeOpaque(0, 0, sourceBitmap.width(), sourceBitmap.height()); + device.makeOpaque(0, 0, sourceBitmap.width(), sourceBitmap.height()); #endif - // Compute MD5 sum. We should have done this before calling - // device.makeOpaque on Windows. Because we do it after the call, there are - // some images that are the pixel identical on windows and other platforms - // but have different MD5 sums. At this point, rebaselining all the windows - // tests is too much of a pain, so we just check in different baselines. + // Compute MD5 sum. MD5 digester; Vector<uint8_t, 16> digestValue; digester.addBytes(reinterpret_cast<const uint8_t*>(sourceBitmap.getPixels()), sourceBitmap.getSize()); @@ -619,10 +535,9 @@ void TestShell::dumpImage(skia::PlatformCanvas* canvas) const // is really expensive. if (md5hash.compare(m_params.pixelHash)) { std::vector<unsigned char> png; - gfx::PNGCodec::ColorFormat colorFormat = gfx::PNGCodec::FORMAT_BGRA; - gfx::PNGCodec::Encode( + webkit_support::EncodeBGRAPNG( reinterpret_cast<const unsigned char*>(sourceBitmap.getPixels()), - colorFormat, sourceBitmap.width(), sourceBitmap.height(), + sourceBitmap.width(), sourceBitmap.height(), static_cast<int>(sourceBitmap.rowBytes()), discardTransparency, &png); m_printer->handleImage(md5hash.c_str(), m_params.pixelHash.c_str(), &png[0], png.size(), m_params.pixelFileName.c_str()); @@ -649,7 +564,7 @@ WebViewHost* TestShell::createNewWindow(const WebURL& url) WebViewHost* host = new WebViewHost(this); WebView* view = WebView::create(host, m_drtDevToolsAgent.get()); host->setWebWidget(view); - resetWebSettings(*view); + m_prefs.applyTo(view); view->initializeMainFrame(host); m_windowList.append(host); host->loadURLForFrame(url, WebString()); diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.h b/WebKitTools/DumpRenderTree/chromium/TestShell.h index cb5f862..6d93d4a 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShell.h +++ b/WebKitTools/DumpRenderTree/chromium/TestShell.h @@ -38,6 +38,7 @@ #include "PlainTextController.h" #include "TestEventPrinter.h" #include "TextInputController.h" +#include "WebPreferences.h" #include "WebViewHost.h" #include <string> #include <wtf/OwnPtr.h> @@ -50,7 +51,6 @@ namespace WebKit { class WebDevToolsAgentClient; class WebFrame; class WebNotificationPresenter; -class WebPreferences; class WebView; class WebURL; } @@ -92,6 +92,9 @@ public: NotificationPresenter* notificationPresenter() const { return m_notificationPresenter.get(); } TestEventPrinter* printer() const { return m_printer.get(); } + WebPreferences* preferences() { return &m_prefs; } + void applyPreferences() { m_prefs.applyTo(m_webView); } + void bindJSObjectsToWindow(WebKit::WebFrame*); void runFileTest(const TestParams&); void callJSGC(); @@ -107,6 +110,7 @@ public: void setFocus(WebKit::WebWidget*, bool enable); bool shouldDumpFrameLoadCallbacks() const { return (m_testIsPreparing || m_testIsPending) && layoutTestController()->shouldDumpFrameLoadCallbacks(); } bool shouldDumpResourceLoadCallbacks() const { return (m_testIsPreparing || m_testIsPending) && layoutTestController()->shouldDumpResourceLoadCallbacks(); } + bool shouldDumpResourceResponseMIMETypes() const { return (m_testIsPreparing || m_testIsPending) && layoutTestController()->shouldDumpResourceResponseMIMETypes(); } void setIsLoading(bool flag) { m_isLoading = flag; } // Called by the LayoutTestController to signal test completion. @@ -147,7 +151,7 @@ public: private: void createDRTDevToolsClient(DRTDevToolsAgent*); - static void resetWebSettings(WebKit::WebView&); + void resetWebSettings(WebKit::WebView&); void dump(); std::string dumpAllBackForwardLists(); void dumpImage(skia::PlatformCanvas*) const; @@ -172,6 +176,7 @@ private: TestParams m_params; int m_timeout; // timeout value in millisecond bool m_allowExternalPages; + WebPreferences m_prefs; // List of all windows in this process. // The main window should be put into windowList[0]. diff --git a/WebKitTools/DumpRenderTree/chromium/TextInputController.cpp b/WebKitTools/DumpRenderTree/chromium/TextInputController.cpp index 63c4719..16f1575 100644 --- a/WebKitTools/DumpRenderTree/chromium/TextInputController.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TextInputController.cpp @@ -51,20 +51,21 @@ TextInputController::TextInputController(TestShell* shell) if (!testShell) testShell = shell; - bindMethod("insertText", &TextInputController::insertText); + bindMethod("attributedSubstringFromRange", &TextInputController::attributedSubstringFromRange); + bindMethod("characterIndexForPoint", &TextInputController::characterIndexForPoint); + bindMethod("conversationIdentifier", &TextInputController::conversationIdentifier); bindMethod("doCommand", &TextInputController::doCommand); - bindMethod("setMarkedText", &TextInputController::setMarkedText); - bindMethod("unmarkText", &TextInputController::unmarkText); + bindMethod("firstRectForCharacterRange", &TextInputController::firstRectForCharacterRange); bindMethod("hasMarkedText", &TextInputController::hasMarkedText); - bindMethod("conversationIdentifier", &TextInputController::conversationIdentifier); - bindMethod("substringFromRange", &TextInputController::substringFromRange); - bindMethod("attributedSubstringFromRange", &TextInputController::attributedSubstringFromRange); + bindMethod("hasSpellingMarker", &TextInputController::hasSpellingMarker); + bindMethod("insertText", &TextInputController::insertText); + bindMethod("makeAttributedString", &TextInputController::makeAttributedString); bindMethod("markedRange", &TextInputController::markedRange); bindMethod("selectedRange", &TextInputController::selectedRange); - bindMethod("firstRectForCharacterRange", &TextInputController::firstRectForCharacterRange); - bindMethod("characterIndexForPoint", &TextInputController::characterIndexForPoint); + bindMethod("setMarkedText", &TextInputController::setMarkedText); + bindMethod("substringFromRange", &TextInputController::substringFromRange); + bindMethod("unmarkText", &TextInputController::unmarkText); bindMethod("validAttributesForMarkedText", &TextInputController::validAttributesForMarkedText); - bindMethod("makeAttributedString", &TextInputController::makeAttributedString); } WebFrame* TextInputController::getMainFrame() @@ -214,3 +215,14 @@ void TextInputController::makeAttributedString(const CppArgumentList&, CppVarian // FIXME: Implement this. result->setNull(); } + +void TextInputController::hasSpellingMarker(const CppArgumentList& arguments, CppVariant* result) +{ + if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isNumber()) + return; + WebFrame* mainFrame = getMainFrame(); + if (!mainFrame) + return; + // Returns as a number for a compatibility reason. + result->set(mainFrame->selectionStartHasSpellingMarkerFor(arguments[0].toInt32(), arguments[1].toInt32()) ? 1 : 0); +} diff --git a/WebKitTools/DumpRenderTree/chromium/TextInputController.h b/WebKitTools/DumpRenderTree/chromium/TextInputController.h index 9896be5..ddacefe 100644 --- a/WebKitTools/DumpRenderTree/chromium/TextInputController.h +++ b/WebKitTools/DumpRenderTree/chromium/TextInputController.h @@ -61,6 +61,7 @@ public: void characterIndexForPoint(const CppArgumentList&, CppVariant*); void validAttributesForMarkedText(const CppArgumentList&, CppVariant*); void makeAttributedString(const CppArgumentList&, CppVariant*); + void hasSpellingMarker(const CppArgumentList&, CppVariant*); private: // Returns the test shell's main WebFrame. diff --git a/WebKitTools/DumpRenderTree/chromium/WebPreferences.cpp b/WebKitTools/DumpRenderTree/chromium/WebPreferences.cpp new file mode 100644 index 0000000..004865a --- /dev/null +++ b/WebKitTools/DumpRenderTree/chromium/WebPreferences.cpp @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebPreferences.h" + +#include "public/WebView.h" + +using namespace WebKit; + +void WebPreferences::reset() +{ +#if OS(MAC_OS_X) + cursiveFontFamily = WebString::fromUTF8("Apple Chancery"); + fantasyFontFamily = WebString::fromUTF8("Papyrus"); + WebString serif = WebString::fromUTF8("Times"); +#else + // These two fonts are picked from the intersection of + // Win XP font list and Vista font list : + // http://www.microsoft.com/typography/fonts/winxp.htm + // http://blogs.msdn.com/michkap/archive/2006/04/04/567881.aspx + // Some of them are installed only with CJK and complex script + // support enabled on Windows XP and are out of consideration here. + // (although we enabled both on our buildbots.) + // They (especially Impact for fantasy) are not typical cursive + // and fantasy fonts, but it should not matter for layout tests + // as long as they're available. + cursiveFontFamily = WebString::fromUTF8("Comic Sans MS"); + fantasyFontFamily = WebString::fromUTF8("Impact"); + // NOTE: case matters here, this must be 'times new roman', else + // some layout tests fail. + WebString serif = WebString::fromUTF8("times new roman"); +#endif + serifFontFamily = serif; + standardFontFamily = serif; + fixedFontFamily = WebString::fromUTF8("Courier"); + sansSerifFontFamily = WebString::fromUTF8("Helvetica"); + + defaultFontSize = 16; + defaultFixedFontSize = 13; + minimumFontSize = 1; + minimumLogicalFontSize = 9; + + DOMPasteAllowed = true; + XSSAuditorEnabled = false; + allowFileAccessFromFileURLs = true; + authorAndUserStylesEnabled = true; + defaultTextEncodingName = WebString::fromUTF8("ISO-8859-1"); + developerExtrasEnabled = false; + experimentalWebGLEnabled = false; + javaEnabled = false; + javaScriptCanAccessClipboard = true; + javaScriptCanOpenWindowsAutomatically = true; + javaScriptEnabled = true; + loadsImagesAutomatically = true; + localStorageEnabled = true; + offlineWebApplicationCacheEnabled = true; + pluginsEnabled = true; + shrinksStandaloneImagesToFit = false; + textAreasAreResizable = false; + userStyleSheetLocation = WebURL(); + usesPageCache = false; + webSecurityEnabled = true; + + // Allow those layout tests running as local files, i.e. under + // LayoutTests/http/tests/local, to access http server. + allowUniversalAccessFromFileURLs = true; + +#if OS(DARWIN) + editingBehavior = WebSettings::EditingBehaviorMac; +#else + editingBehavior = WebSettings::EditingBehaviorWin; +#endif + + tabsToLinks = false; +} + +void WebPreferences::applyTo(WebView* webView) +{ + WebSettings* settings = webView->settings(); + settings->setCursiveFontFamily(cursiveFontFamily); + settings->setFantasyFontFamily(fantasyFontFamily); + settings->setSerifFontFamily(serifFontFamily); + settings->setStandardFontFamily(standardFontFamily); + settings->setFixedFontFamily(fixedFontFamily); + settings->setSansSerifFontFamily(sansSerifFontFamily); + + settings->setDefaultFontSize(defaultFontSize); + settings->setDefaultFixedFontSize(defaultFixedFontSize); + settings->setMinimumFontSize(minimumFontSize); + settings->setMinimumLogicalFontSize(minimumLogicalFontSize); + + settings->setDOMPasteAllowed(DOMPasteAllowed); + settings->setXSSAuditorEnabled(XSSAuditorEnabled); + settings->setAllowFileAccessFromFileURLs(allowFileAccessFromFileURLs); + settings->setAuthorAndUserStylesEnabled(authorAndUserStylesEnabled); + settings->setDefaultTextEncodingName(defaultTextEncodingName); + settings->setDeveloperExtrasEnabled(developerExtrasEnabled); + settings->setExperimentalWebGLEnabled(experimentalWebGLEnabled); + settings->setJavaEnabled(javaEnabled); + settings->setJavaScriptCanAccessClipboard(javaScriptCanAccessClipboard); + settings->setJavaScriptCanOpenWindowsAutomatically(javaScriptCanOpenWindowsAutomatically); + settings->setJavaScriptEnabled(javaScriptEnabled); + settings->setLoadsImagesAutomatically(loadsImagesAutomatically); + settings->setLocalStorageEnabled(localStorageEnabled); + settings->setOfflineWebApplicationCacheEnabled(offlineWebApplicationCacheEnabled); + settings->setPluginsEnabled(pluginsEnabled); + settings->setShrinksStandaloneImagesToFit(shrinksStandaloneImagesToFit); + settings->setTextAreasAreResizable(textAreasAreResizable); + settings->setUserStyleSheetLocation(userStyleSheetLocation); + settings->setUsesPageCache(usesPageCache); + settings->setWebSecurityEnabled(webSecurityEnabled); + settings->setAllowUniversalAccessFromFileURLs(allowUniversalAccessFromFileURLs); + settings->setEditingBehavior(editingBehavior); + // LayoutTests were written with Safari Mac in mind which does not allow + // tabbing to links by default. + webView->setTabsToLinks(tabsToLinks); + + // Fixed values. + settings->setShouldPaintCustomScrollbars(true); + settings->setTextDirectionSubmenuInclusionBehaviorNeverIncluded(); + settings->setDownloadableBinaryFontsEnabled(true); + settings->setAllowScriptsToCloseWindows(false); + settings->setNeedsSiteSpecificQuirks(true); + settings->setEditableLinkBehaviorNeverLive(); + settings->setFontRenderingModeNormal(); + settings->setTextDirectionSubmenuInclusionBehaviorNeverIncluded(); + settings->setUsesEncodingDetector(false); + settings->setImagesEnabled(true); + + // FIXME: crbug.com/51879 + settings->setAcceleratedCompositingEnabled(false); +} + diff --git a/WebKitTools/DumpRenderTree/chromium/WebPreferences.h b/WebKitTools/DumpRenderTree/chromium/WebPreferences.h new file mode 100644 index 0000000..f197c16 --- /dev/null +++ b/WebKitTools/DumpRenderTree/chromium/WebPreferences.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebPreferences_h +#define WebPerferences_h + +#include "public/WebSettings.h" +#include "public/WebString.h" +#include "public/WebURL.h" + +namespace WebKit { +class WebView; +} + +struct WebPreferences { + WebKit::WebString cursiveFontFamily; + WebKit::WebString fantasyFontFamily; + WebKit::WebString serifFontFamily; + WebKit::WebString standardFontFamily; + WebKit::WebString fixedFontFamily; + WebKit::WebString sansSerifFontFamily; + + int defaultFontSize; + int defaultFixedFontSize; + int minimumFontSize; + int minimumLogicalFontSize; + + bool DOMPasteAllowed; + bool XSSAuditorEnabled; + bool allowFileAccessFromFileURLs; + bool authorAndUserStylesEnabled; + WebKit::WebString defaultTextEncodingName; + bool developerExtrasEnabled; + bool experimentalWebGLEnabled; + bool javaEnabled; + bool javaScriptCanAccessClipboard; + bool javaScriptCanOpenWindowsAutomatically; + bool javaScriptEnabled; + bool loadsImagesAutomatically; + bool localStorageEnabled; + bool offlineWebApplicationCacheEnabled; + bool pluginsEnabled; + bool shrinksStandaloneImagesToFit; + bool textAreasAreResizable; + WebKit::WebURL userStyleSheetLocation; + bool usesPageCache; + bool webSecurityEnabled; + bool allowUniversalAccessFromFileURLs; + WebKit::WebSettings::EditingBehavior editingBehavior; + bool tabsToLinks; + + WebPreferences() { reset(); } + void reset(); + void applyTo(WebKit::WebView*); +}; + +#endif // WebPreferences_h diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp index 1e3a4d6..9a086e4 100644 --- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp +++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp @@ -40,6 +40,7 @@ #include "public/WebContextMenuData.h" #include "public/WebDataSource.h" #include "public/WebDragData.h" +#include "public/WebElement.h" #include "public/WebFrame.h" #include "public/WebGeolocationServiceMock.h" #include "public/WebHistoryItem.h" @@ -489,10 +490,68 @@ void WebViewHost::focusAccessibilityObject(const WebAccessibilityObject& object) m_shell->accessibilityController()->setFocusedElement(object); } -void WebViewHost::didChangeAccessibilityObjectChildren(const WebAccessibilityObject& object) -{ - if (m_shell->accessibilityController()->shouldDumpAccessibilityNotifications()) - printf("didChangeAccessibilityObjectChildren - new count: %d\n", object.childCount()); +void WebViewHost::postAccessibilityNotification(const WebAccessibilityObject& obj, WebAccessibilityNotification notification) +{ + if (m_shell->accessibilityController()->shouldDumpAccessibilityNotifications()) { + printf("AccessibilityNotification - "); + + switch (notification) { + case WebAccessibilityNotificationActiveDescendantChanged: + printf("ActiveDescendantChanged"); + break; + case WebAccessibilityNotificationCheckedStateChanged: + printf("CheckedStateChanged"); + break; + case WebAccessibilityNotificationChildrenChanged: + printf("ChildrenChanged"); + break; + case WebAccessibilityNotificationFocusedUIElementChanged: + printf("FocusedUIElementChanged"); + break; + case WebAccessibilityNotificationLayoutComplete: + printf("LayoutComplete"); + break; + case WebAccessibilityNotificationLoadComplete: + printf("LoadComplete"); + break; + case WebAccessibilityNotificationSelectedChildrenChanged: + printf("SelectedChildrenChanged"); + break; + case WebAccessibilityNotificationSelectedTextChanged: + printf("SelectedTextChanged"); + break; + case WebAccessibilityNotificationValueChanged: + printf("ValueChanged"); + break; + case WebAccessibilityNotificationScrolledToAnchor: + printf("ScrolledToAnchor"); + break; + case WebAccessibilityNotificationLiveRegionChanged: + printf("LiveRegionChanged"); + break; + case WebAccessibilityNotificationMenuListValueChanged: + printf("MenuListValueChanged"); + break; + case WebAccessibilityNotificationRowCountChanged: + printf("RowCountChanged"); + break; + case WebAccessibilityNotificationRowCollapsed: + printf("RowCollapsed"); + break; + case WebAccessibilityNotificationRowExpanded: + printf("RowExpanded"); + break; + } + + WebKit::WebNode node = obj.node(); + if (!node.isNull() && node.isElementNode()) { + WebKit::WebElement element = node.to<WebKit::WebElement>(); + if (element.hasAttribute("id")) + printf(" - id:%s", element.getAttribute("id").utf8().data()); + } + + printf("\n"); + } } WebNotificationPresenter* WebViewHost::notificationPresenter() @@ -731,6 +790,8 @@ void WebViewHost::didCancelClientRedirect(WebFrame* frame) void WebViewHost::didCreateDataSource(WebFrame*, WebDataSource* ds) { ds->setExtraData(m_pendingExtraData.leakPtr()); + if (!layoutTestController()->deferMainResourceDataLoad()) + ds->setDeferMainResourceDataLoad(false); } void WebViewHost::didStartProvisionalLoad(WebFrame* frame) @@ -920,12 +981,20 @@ void WebViewHost::willSendRequest(WebFrame*, unsigned identifier, WebURLRequest& void WebViewHost::didReceiveResponse(WebFrame*, unsigned identifier, const WebURLResponse& response) { - if (!m_shell->shouldDumpResourceLoadCallbacks()) - return; - printResourceDescription(identifier); - fputs(" - didReceiveResponse ", stdout); - printResponseDescription(response); - fputs("\n", stdout); + if (m_shell->shouldDumpResourceLoadCallbacks()) { + printResourceDescription(identifier); + fputs(" - didReceiveResponse ", stdout); + printResponseDescription(response); + fputs("\n", stdout); + } + if (m_shell->shouldDumpResourceResponseMIMETypes()) { + GURL url = response.url(); + WebString mimeType = response.mimeType(); + printf("%s has MIME type %s\n", + url.ExtractFileName().c_str(), + // Simulate NSURLResponse's mapping of empty/unknown MIME types to application/octet-stream + mimeType.isEmpty() ? "application/octet-stream" : mimeType.utf8().data()); + } } void WebViewHost::didFinishResourceLoad(WebFrame*, unsigned identifier) diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h index 3a84ebd..bbb132d 100644 --- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h +++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h @@ -33,6 +33,7 @@ #include "MockSpellCheck.h" #include "TestNavigationController.h" +#include "public/WebAccessibilityNotification.h" #include "public/WebCursorInfo.h" #include "public/WebFrameClient.h" #include "public/WebViewClient.h" @@ -127,7 +128,7 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, virtual int historyBackListCount(); virtual int historyForwardListCount(); virtual void focusAccessibilityObject(const WebKit::WebAccessibilityObject&); - virtual void didChangeAccessibilityObjectChildren(const WebKit::WebAccessibilityObject&); + virtual void postAccessibilityNotification(const WebKit::WebAccessibilityObject&, WebKit::WebAccessibilityNotification); virtual WebKit::WebNotificationPresenter* notificationPresenter(); virtual WebKit::WebGeolocationService* geolocationService(); virtual WebKit::WebSpeechInputController* speechInputController(WebKit::WebSpeechInputListener*); diff --git a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp index a5c5e9f..d39ff1e 100644 --- a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp @@ -667,6 +667,12 @@ bool AccessibilityUIElement::isCollapsed() const return false; } +bool AccessibilityUIElement::isIgnored() const +{ + // FIXME: implement + return false; +} + bool AccessibilityUIElement::hasPopup() const { // FIXME: implement diff --git a/WebKitTools/DumpRenderTree/gtk/EventSender.cpp b/WebKitTools/DumpRenderTree/gtk/EventSender.cpp index fc118bc..d1529db 100644 --- a/WebKitTools/DumpRenderTree/gtk/EventSender.cpp +++ b/WebKitTools/DumpRenderTree/gtk/EventSender.cpp @@ -42,6 +42,7 @@ #include <webkit/webkitwebview.h> #include <wtf/ASCIICType.h> #include <wtf/Platform.h> +#include <wtf/text/CString.h> #include <gdk/gdk.h> #include <gdk/gdkkeysyms.h> @@ -49,6 +50,7 @@ extern "C" { extern void webkit_web_frame_layout(WebKitWebFrame* frame); + extern GtkMenu* webkit_web_view_get_context_menu(WebKitWebView*); } static bool dragMode; @@ -148,15 +150,37 @@ bool prepareMouseButtonEvent(GdkEvent* event, int eventSenderButtonNumber, guint static JSValueRef contextClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { GdkEvent* pressEvent = gdk_event_new(GDK_BUTTON_PRESS); + if (!prepareMouseButtonEvent(pressEvent, 2, 0)) - return JSValueMakeUndefined(context); + return JSObjectMakeArray(context, 0, 0, 0); GdkEvent* releaseEvent = gdk_event_copy(pressEvent); sendOrQueueEvent(pressEvent); + + JSValueRef valueRef = JSObjectMakeArray(context, 0, 0, 0); + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + GtkMenu* gtkMenu = webkit_web_view_get_context_menu(view); + if (gtkMenu) { + GList* items = gtk_container_get_children(GTK_CONTAINER(gtkMenu)); + JSValueRef arrayValues[g_list_length(items)]; + int index = 0; + for (GList* item = g_list_first(items); item; item = g_list_next(item)) { + CString label; + if (GTK_IS_SEPARATOR_MENU_ITEM(item->data)) + label = "<separator>"; + else + label = gtk_menu_item_get_label(GTK_MENU_ITEM(item->data)); + + arrayValues[index] = JSValueMakeString(context, JSStringCreateWithUTF8CString(label.data())); + index++; + } + if (index) + valueRef = JSObjectMakeArray(context, index - 1, arrayValues, 0); + } + releaseEvent->type = GDK_BUTTON_RELEASE; sendOrQueueEvent(releaseEvent); - - return JSValueMakeUndefined(context); + return valueRef; } static void updateClickCount(int button) @@ -434,30 +458,7 @@ static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JS { if (argumentCount < 1) return JSValueMakeUndefined(context); - - static const JSStringRef lengthProperty = JSStringCreateWithUTF8CString("length"); - - webkit_web_frame_layout(mainFrame); - - // handle modifier keys. - int state = 0; - if (argumentCount > 1) { - JSObjectRef modifiersArray = JSValueToObject(context, arguments[1], exception); - if (modifiersArray) { - for (int i = 0; i < JSValueToNumber(context, JSObjectGetProperty(context, modifiersArray, lengthProperty, 0), 0); ++i) { - JSValueRef value = JSObjectGetPropertyAtIndex(context, modifiersArray, i, 0); - JSStringRef string = JSValueToStringCopy(context, value, 0); - if (JSStringIsEqualToUTF8CString(string, "ctrlKey")) - state |= GDK_CONTROL_MASK; - else if (JSStringIsEqualToUTF8CString(string, "shiftKey")) - state |= GDK_SHIFT_MASK; - else if (JSStringIsEqualToUTF8CString(string, "altKey")) - state |= GDK_MOD1_MASK; - - JSStringRelease(string); - } - } - } + guint modifiers = argumentCount >= 2 ? gdkModifersFromJSValue(context, arguments[1]) : 0; // handle location argument. int location = DOM_KEY_LOCATION_STANDARD; @@ -550,7 +551,7 @@ static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JS else { gdkKeySym = gdk_unicode_to_keyval(charCode); if (WTF::isASCIIUpper(charCode)) - state |= GDK_SHIFT_MASK; + modifiers |= GDK_SHIFT_MASK; } } } @@ -563,7 +564,7 @@ static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JS // create and send the event GdkEvent* pressEvent = gdk_event_new(GDK_KEY_PRESS); pressEvent->key.keyval = gdkKeySym; - pressEvent->key.state = state; + pressEvent->key.state = modifiers; pressEvent->key.window = gtk_widget_get_window(GTK_WIDGET(view)); g_object_ref(pressEvent->key.window); #ifndef GTK_API_VERSION_2 diff --git a/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm b/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm index fa4acf5..5f9705a 100644 --- a/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm +++ b/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm @@ -1160,6 +1160,15 @@ bool AccessibilityUIElement::isCollapsed() const return false; } +bool AccessibilityUIElement::isIgnored() const +{ + BOOL result = NO; + BEGIN_AX_OBJC_EXCEPTIONS + result = [m_element accessibilityIsIgnored]; + END_AX_OBJC_EXCEPTIONS + return result; +} + bool AccessibilityUIElement::hasPopup() const { BEGIN_AX_OBJC_EXCEPTIONS @@ -1246,6 +1255,16 @@ AccessibilityTextMarker AccessibilityUIElement::endTextMarkerForTextMarkerRange( return 0; } +AccessibilityTextMarker AccessibilityUIElement::textMarkerForPoint(int x, int y) +{ + BEGIN_AX_OBJC_EXCEPTIONS + id textMarker = [m_element accessibilityAttributeValue:@"AXTextMarkerForPosition" forParameter:[NSValue valueWithPoint:NSMakePoint(x, y)]]; + return AccessibilityTextMarker(textMarker); + END_AX_OBJC_EXCEPTIONS + + return 0; +} + AccessibilityUIElement AccessibilityUIElement::accessibilityElementForTextMarker(AccessibilityTextMarker* marker) { BEGIN_AX_OBJC_EXCEPTIONS diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm index ffcb18a..3732247 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm @@ -457,6 +457,7 @@ static void resetDefaultsToConsistentValues() [preferences setUsesPageCache:NO]; [preferences setAcceleratedCompositingEnabled:YES]; [preferences setWebGLEnabled:NO]; + [preferences setUsePreHTML5ParserQuirks:NO]; [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain]; diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp index 00ccdb5..4e6f049 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp @@ -567,6 +567,13 @@ void DumpRenderTree::resetToConsistentStateBeforeTesting() setlocale(LC_ALL, ""); } +static bool isGlobalHistoryTest(const QUrl& url) +{ + if (url.path().contains("globalhistory/")) + return true; + return false; +} + static bool isWebInspectorTest(const QUrl& url) { if (url.path().contains("inspector/")) @@ -595,6 +602,9 @@ void DumpRenderTree::open(const QUrl& url) layoutTestController()->showWebInspector(); } + if (isGlobalHistoryTest(url)) + layoutTestController()->dumpHistoryCallbacks(); + // W3C SVG tests expect to be 480x360 bool isW3CTest = url.toString().contains("svg/W3C-SVG-1.1"); int width = isW3CTest ? 480 : LayoutTestController::maxViewWidth; @@ -668,8 +678,10 @@ void DumpRenderTree::processArgsLine(const QStringList &args) void DumpRenderTree::loadNextTestInStandAloneMode() { - if (m_standAloneModeTestList.isEmpty()) + if (m_standAloneModeTestList.isEmpty()) { emit quit(); + return; + } processLine(m_standAloneModeTestList.first()); m_standAloneModeTestList.removeFirst(); diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp index b783141..b2ef716 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp @@ -81,6 +81,8 @@ void LayoutTestController::reset() DumpRenderTreeSupportQt::setWillSendRequestClearHeaders(QStringList()); DumpRenderTreeSupportQt::clearScriptWorlds(); DumpRenderTreeSupportQt::setCustomPolicyDelegate(false, false); + DumpRenderTreeSupportQt::dumpHistoryCallbacks(false); + DumpRenderTreeSupportQt::dumpVisitedLinksCallbacks(false); setIconDatabaseEnabled(false); emit hidePage(); @@ -206,6 +208,11 @@ bool LayoutTestController::checkDesktopNotificationPermission(const QString& ori return !m_ignoreDesktopNotification && m_desktopNotificationAllowedOrigins.contains(origin); } +void LayoutTestController::simulateDesktopNotificationClick(const QString& title) +{ + DumpRenderTreeSupportQt::simulateDesktopNotificationClick(title); +} + void LayoutTestController::display() { emit showPage(); @@ -222,6 +229,12 @@ QString LayoutTestController::pathToLocalResource(const QString& url) return QDir::toNativeSeparators(url); } +void LayoutTestController::dumpConfigurationForViewport(int availableWidth, int availableHeight) +{ + QString res = DumpRenderTreeSupportQt::viewportAsText(m_drt->webPage(), QSize(availableWidth, availableHeight)); + fputs(qPrintable(res), stdout); +} + void LayoutTestController::dumpEditingCallbacks() { qDebug() << ">>>dumpEditingCallbacks"; @@ -243,6 +256,11 @@ void LayoutTestController::dumpResourceResponseMIMETypes() DumpRenderTreeSupportQt::dumpResourceResponseMIMETypes(true); } +void LayoutTestController::dumpHistoryCallbacks() +{ + DumpRenderTreeSupportQt::dumpHistoryCallbacks(true); +} + void LayoutTestController::setWillSendRequestReturnsNullOnRedirect(bool enabled) { DumpRenderTreeSupportQt::setWillSendRequestReturnsNullOnRedirect(enabled); @@ -769,5 +787,12 @@ void LayoutTestController::addUserStyleSheet(const QString& sourceCode) DumpRenderTreeSupportQt::addUserStyleSheet(m_drt->webPage(), sourceCode); } +void LayoutTestController::removeAllVisitedLinks() +{ + QWebHistory* history = m_drt->webPage()->history(); + history->clear(); + DumpRenderTreeSupportQt::dumpVisitedLinksCallbacks(true); +} + const unsigned LayoutTestController::maxViewWidth = 800; const unsigned LayoutTestController::maxViewHeight = 600; diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h index 7e58f44..ec89acb 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h @@ -108,6 +108,8 @@ public slots: void dumpFrameLoadCallbacks(); void dumpResourceLoadCallbacks(); void dumpResourceResponseMIMETypes(); + void dumpHistoryCallbacks(); + void dumpConfigurationForViewport(int availableWidth, int availableHeight); void setWillSendRequestReturnsNullOnRedirect(bool enabled); void setWillSendRequestReturnsNull(bool enabled); void setWillSendRequestClearHeader(const QStringList& headers); @@ -124,6 +126,7 @@ public slots: void grantDesktopNotificationPermission(const QString& origin); void ignoreDesktopNotificationPermissionRequests(); bool checkDesktopNotificationPermission(const QString& origin); + void simulateDesktopNotificationClick(const QString& title); void display(); void clearBackForwardList(); QString pathToLocalResource(const QString& url); @@ -135,6 +138,7 @@ public slots: void showWebInspector(); void closeWebInspector(); void evaluateInWebInspector(long callId, const QString& script); + void removeAllVisitedLinks(); void setMediaType(const QString& type); void setFrameFlatteningEnabled(bool enable); diff --git a/WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp b/WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp index 8c2fea2..96937fd 100644 --- a/WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp +++ b/WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp @@ -614,6 +614,12 @@ bool AccessibilityUIElement::isCollapsed() const return (state & STATE_SYSTEM_COLLAPSED) == STATE_SYSTEM_COLLAPSED; } +bool AccessibilityUIElement::isIgnored() const +{ + // FIXME: implement + return false; +} + bool AccessibilityUIElement::hasPopup() const { DWORD state = accessibilityState(m_element); |