diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree')
10 files changed, 112 insertions, 24 deletions
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp index e71cd29..0537d7c 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp @@ -61,6 +61,7 @@ LayoutTestController::LayoutTestController(const std::string& testPathOrURL, con , m_callCloseOnWebViews(true) , m_canOpenWindows(false) , m_closeRemainingWindowsWhenComplete(true) + , m_newWindowsCopyBackForwardList(false) , m_stopProvisionalFrameLoads(false) , m_testOnscreen(false) , m_testRepaint(false) @@ -464,6 +465,36 @@ static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, return JSValueMakeUndefined(context); } +static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // FIXME: These values should sync with maxViewWidth/Height in + // DumpRenderTree.mm. Factor these values out to somewhere. + float pageWidthInPixels = 800; + float pageHeightInPixels = 600; + switch (argumentCount) { + case 1: + break; + case 3: + pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception)); + if (*exception) + return JSValueMakeUndefined(context); + pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[2], exception)); + if (*exception) + return JSValueMakeUndefined(context); + break; + default: + return JSValueMakeUndefined(context); + } + + JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception)); + if (*exception) + return JSValueMakeUndefined(context); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + int pageNumber = controller->pageNumberForElementById(elementId.get(), pageWidthInPixels, pageHeightInPixels); + return JSValueMakeNumber(context, pageNumber); +} + static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation @@ -743,6 +774,18 @@ static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObject return JSValueMakeUndefined(context); } +static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // Has mac implementation + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setNewWindowsCopyBackForwardList(JSValueToBoolean(context, arguments[0])); + + return JSValueMakeUndefined(context); +} + static JSValueRef setGeolocationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation @@ -1289,6 +1332,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -1324,6 +1368,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h index c8da6ab..76e7cb3 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/LayoutTestController.h @@ -57,6 +57,7 @@ public: void keepWebHistory(); void notifyDone(); void overridePreference(JSStringRef key, JSStringRef value); + int pageNumberForElementById(JSStringRef id, float pageWidthInPixels, float pageHeightInPixels); JSStringRef pathToLocalResource(JSContextRef, JSStringRef url); void queueBackNavigation(int howFarBackward); void queueForwardNavigation(int howFarForward); @@ -66,28 +67,29 @@ public: void queueReload(); void removeAllVisitedLinks(); void setAcceptsEditing(bool acceptsEditing); - void setAppCacheMaximumSize(unsigned long long quota); void setAllowUniversalAccessFromFileURLs(bool); + void setAppCacheMaximumSize(unsigned long long quota); void setAuthorAndUserStylesEnabled(bool); void setCacheModel(int); void setCustomPolicyDelegate(bool setDelegate, bool permissive); void setDatabaseQuota(unsigned long long quota); void setDomainRelaxationForbiddenForURLScheme(bool forbidden, JSStringRef scheme); - void setMockGeolocationPosition(double latitude, double longitude, double accuracy); - void setMockGeolocationError(int code, JSStringRef message); void setIconDatabaseEnabled(bool iconDatabaseEnabled); void setJavaScriptProfilingEnabled(bool profilingEnabled); void setMainFrameIsFirstResponder(bool flag); + void setMockGeolocationError(int code, JSStringRef message); + void setMockGeolocationPosition(double latitude, double longitude, double accuracy); void setPersistentUserStyleSheetLocation(JSStringRef path); void setPopupBlockingEnabled(bool flag); void setPrivateBrowsingEnabled(bool flag); - void setXSSAuditorEnabled(bool flag); void setSelectTrailingWhitespaceEnabled(bool flag); void setSmartInsertDeleteEnabled(bool flag); void setTabKeyCyclesThroughElements(bool cycles); void setUseDashboardCompatibilityMode(bool flag); void setUserStyleSheetEnabled(bool flag); void setUserStyleSheetLocation(JSStringRef path); + void setXSSAuditorEnabled(bool flag); + void waitForPolicyDelegate(); size_t webHistoryItemCount(); unsigned workerThreadCount() const; @@ -161,6 +163,9 @@ public: bool closeRemainingWindowsWhenComplete() const { return m_closeRemainingWindowsWhenComplete; } void setCloseRemainingWindowsWhenComplete(bool closeRemainingWindowsWhenComplete) { m_closeRemainingWindowsWhenComplete = closeRemainingWindowsWhenComplete; } + bool newWindowsCopyBackForwardList() const { return m_newWindowsCopyBackForwardList; } + void setNewWindowsCopyBackForwardList(bool newWindowsCopyBackForwardList) { m_newWindowsCopyBackForwardList = newWindowsCopyBackForwardList; } + bool stopProvisionalFrameLoads() const { return m_stopProvisionalFrameLoads; } void setStopProvisionalFrameLoads(bool stopProvisionalFrameLoads) { m_stopProvisionalFrameLoads = stopProvisionalFrameLoads; } @@ -248,6 +253,7 @@ private: bool m_callCloseOnWebViews; bool m_canOpenWindows; bool m_closeRemainingWindowsWhenComplete; + bool m_newWindowsCopyBackForwardList; bool m_stopProvisionalFrameLoads; bool m_testOnscreen; bool m_testRepaint; diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp index a74f7ad..bad09fb 100644 --- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp @@ -140,6 +140,12 @@ void LayoutTestController::keepWebHistory() // FIXME: implement } +int LayoutTestController::pageNumberForElementById(JSStringRef, float, float) +{ + // FIXME: implement + return -1; +} + size_t LayoutTestController::webHistoryItemCount() { // FIXME: implement diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm index 5f020fa..67c8c91 100644 --- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm @@ -176,6 +176,18 @@ void LayoutTestController::keepWebHistory() } } +int LayoutTestController::pageNumberForElementById(JSStringRef id, float pageWidthInPixels, float pageHeightInPixels) +{ + RetainPtr<CFStringRef> idCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, id)); + NSString *idNS = (NSString *)idCF.get(); + + DOMElement *element = [[mainFrame DOMDocument] getElementById:idNS]; + if (!element) + return -1; + + return [mainFrame pageNumberForElement:element:pageWidthInPixels:pageHeightInPixels]; +} + size_t LayoutTestController::webHistoryItemCount() { return [[[WebHistory optionalSharedHistory] allItems] count]; diff --git a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm index 81c03d2..19ceb95 100644 --- a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm @@ -38,6 +38,7 @@ #import <WebKit/WebSecurityOriginPrivate.h> #import <WebKit/WebUIDelegatePrivate.h> #import <WebKit/WebView.h> +#import <WebKit/WebViewPrivate.h> #import <wtf/Assertions.h> DumpRenderTreeDraggingInfo *draggingInfo = nil; @@ -122,6 +123,9 @@ DumpRenderTreeDraggingInfo *draggingInfo = nil; WebView *webView = createWebViewAndOffscreenWindow(); + if (gLayoutTestController->newWindowsCopyBackForwardList()) + [webView _loadBackForwardListFromOtherView:sender]; + return [webView autorelease]; } diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp index 9916f24..c16a786 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp @@ -412,23 +412,10 @@ void DumpRenderTree::resetToConsistentStateBeforeTesting() setlocale(LC_ALL, ""); } -void DumpRenderTree::open(const QUrl& aurl) +void DumpRenderTree::open(const QUrl& url) { resetToConsistentStateBeforeTesting(); - QUrl url = aurl; - m_expectedHash = QString(); - if (m_dumpPixels) { - // single quote marks the pixel dump hash - QString str = url.toString(); - int i = str.indexOf('\''); - if (i > -1) { - m_expectedHash = str.mid(i + 1, str.length()); - str.remove(i, str.length()); - url = QUrl(str); - } - } - // W3C SVG tests expect to be 480x360 bool isW3CTest = url.toString().contains("svg/W3C-SVG-1.1"); int width = isW3CTest ? 480 : maxViewWidth; @@ -477,6 +464,16 @@ void DumpRenderTree::processLine(const QString &input) { QString line = input; + m_expectedHash = QString(); + if (m_dumpPixels) { + // single quote marks the pixel dump hash + int i = line.indexOf('\''); + if (i > -1) { + m_expectedHash = line.mid(i + 1, line.length()); + line.remove(i, line.length()); + } + } + if (line.startsWith(QLatin1String("http:")) || line.startsWith(QLatin1String("https:")) || line.startsWith(QLatin1String("file:"))) { @@ -720,14 +717,16 @@ void DumpRenderTree::dump() printf("Content-Type: %s\n", "image/png"); printf("Content-Length: %lu\n", static_cast<unsigned long>(data.length())); + const quint32 bytesToWriteInOneChunk = 1 << 15; + quint32 dataRemainingToWrite = data.length(); const char *ptr = data.data(); - for(quint32 left = data.length(); left; ) { - quint32 block = qMin(left, quint32(1 << 15)); - quint32 written = fwrite(ptr, 1, block, stdout); - ptr += written; - left -= written; - if (written == block) + while (dataRemainingToWrite) { + quint32 bytesToWriteInThisChunk = qMin(dataRemainingToWrite, bytesToWriteInOneChunk); + quint32 bytesWritten = fwrite(ptr, 1, bytesToWriteInThisChunk, stdout); + if (bytesWritten != bytesToWriteInThisChunk) break; + dataRemainingToWrite -= bytesWritten; + ptr += bytesWritten; } } diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp index 9430ec7..ca48003 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp @@ -73,6 +73,7 @@ void LayoutTestController::reset() m_waitForPolicy = false; m_handleErrorPages = false; m_webHistory = 0; + m_globalFlag = false; qt_dump_editing_callbacks(false); qt_dump_resource_load_callbacks(false); emit hidePage(); diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h index 64b3a15..365640d 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h @@ -53,6 +53,7 @@ class LayoutTestController : public QObject { Q_OBJECT Q_PROPERTY(int webHistoryItemCount READ webHistoryItemCount) Q_PROPERTY(int workerThreadCount READ workerThreadCount) + Q_PROPERTY(bool globalFlag READ globalFlag WRITE setGlobalFlag) public: LayoutTestController(WebCore::DumpRenderTree* drt); @@ -91,6 +92,8 @@ public slots: void keepWebHistory(); void notifyDone(); void dumpBackForwardList() { m_dumpBackForwardList = true; } + bool globalFlag() const { return m_globalFlag; } + void setGlobalFlag(bool flag) { m_globalFlag = flag; } void handleErrorPages() { m_handleErrorPages = true; } void dumpEditingCallbacks(); void dumpResourceLoadCallbacks(); @@ -160,6 +163,7 @@ private: bool m_waitForPolicy; bool m_handleErrorPages; bool m_loadFinished; + bool m_globalFlag; QUrl m_userStyleSheetLocation; QBasicTimer m_timeoutTimer; diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp index b7a63fc..4f5e925 100644 --- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp +++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp @@ -1104,3 +1104,8 @@ JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStri return counterValueJS; } +int LayoutTestController::pageNumberForElementById(JSStringRef, float, float) +{ + // FIXME: implement + return -1; +} diff --git a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp index 4b811ec..6d3b624 100644 --- a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp +++ b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp @@ -359,3 +359,9 @@ JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStri { return 0; } + +int LayoutTestController::pageNumberForElementById(JSStringRef, float, float) +{ + // FIXME: implement + return -1; +} |