diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree')
30 files changed, 360 insertions, 45 deletions
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp index cd294bc..6a957c1 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp @@ -60,6 +60,7 @@ LayoutTestController::LayoutTestController(const std::string& testPathOrURL, con , m_dumpIconChanges(false) , m_dumpVisitedLinksCallback(false) , m_dumpWillCacheResponse(false) + , m_generatePixelResults(true) , m_callCloseOnWebViews(true) , m_canOpenWindows(false) , m_closeRemainingWindowsWhenComplete(true) @@ -78,6 +79,7 @@ LayoutTestController::LayoutTestController(const std::string& testPathOrURL, con , m_geolocationPermission(false) , m_handlesAuthenticationChallenges(false) , m_isPrinting(false) + , m_deferMainResourceDataLoad(true) , m_testPathOrURL(testPathOrURL) , m_expectedPixelHash(expectedPixelHash) { @@ -101,6 +103,10 @@ static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, { LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); controller->setDumpAsText(true); + + // Optional paramater, describing whether it's allowed to dump pixel results in dumpAsText mode. + controller->setGeneratePixelResults(argumentCount > 0 ? JSValueToBoolean(context, arguments[0]) : false); + return JSValueMakeUndefined(context); } @@ -734,6 +740,28 @@ static JSValueRef queueLoadCallback(JSContextRef context, JSObjectRef function, return JSValueMakeUndefined(context); } +static JSValueRef queueLoadHTMLStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // Has Mac & Windows implementation + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + JSRetainPtr<JSStringRef> content(Adopt, JSValueToStringCopy(context, arguments[0], exception)); + ASSERT(!*exception); + + JSRetainPtr<JSStringRef> baseURL; + if (argumentCount >= 2) { + baseURL.adopt(JSValueToStringCopy(context, arguments[1], exception)); + ASSERT(!*exception); + } else + baseURL.adopt(JSStringCreateWithUTF8CString("")); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->queueLoadHTMLString(content.get(), baseURL.get()); + + return JSValueMakeUndefined(context); +} + static JSValueRef queueReloadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation @@ -915,6 +943,18 @@ static JSValueRef setDatabaseQuotaCallback(JSContextRef context, JSObjectRef fun return JSValueMakeUndefined(context); } +static JSValueRef setDeferMainResourceDataLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // Has Mac and Windows implementation + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setDeferMainResourceDataLoad(JSValueToBoolean(context, arguments[0])); + + return JSValueMakeUndefined(context); +} + static JSValueRef setDomainRelaxationForbiddenForURLSchemeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has Mac and Windows implementation @@ -1754,6 +1794,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "queueForwardNavigation", queueForwardNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "queueLoad", queueLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "queueLoadHTMLString", queueLoadHTMLStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "queueLoadingScript", queueLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "queueNonLoadingScript", queueNonLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "queueReload", queueReloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -1774,6 +1815,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "setCloseRemainingWindowsWhenComplete", setCloseRemainingWindowsWhenCompleteCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setDatabaseQuota", setDatabaseQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setDeferMainResourceDataLoad", setDeferMainResourceDataLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setDomainRelaxationForbiddenForURLScheme", setDomainRelaxationForbiddenForURLSchemeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setEditingBehavior", setEditingBehaviorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setFrameFlatteningEnabled", setFrameFlatteningEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -1822,6 +1864,11 @@ JSStaticFunction* LayoutTestController::staticFunctions() return staticFunctions; } +void LayoutTestController::queueLoadHTMLString(JSStringRef content, JSStringRef baseURL) +{ + WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL)); +} + void LayoutTestController::queueBackNavigation(int howFarBack) { WorkQueue::shared()->queue(new BackItem(howFarBack)); diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h index 16eda2c..30eb9bd 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/LayoutTestController.h @@ -70,6 +70,7 @@ public: void queueBackNavigation(int howFarBackward); void queueForwardNavigation(int howFarForward); void queueLoad(JSStringRef url, JSStringRef target); + void queueLoadHTMLString(JSStringRef content, JSStringRef baseURL); void queueLoadingScript(JSStringRef script); void queueNonLoadingScript(JSStringRef script); void queueReload(); @@ -120,7 +121,10 @@ public: bool dumpAsText() const { return m_dumpAsText; } void setDumpAsText(bool dumpAsText) { m_dumpAsText = dumpAsText; } - + + bool generatePixelResults() const { return m_generatePixelResults; } + void setGeneratePixelResults(bool generatePixelResults) { m_generatePixelResults = generatePixelResults; } + bool dumpBackForwardList() const { return m_dumpBackForwardList; } void setDumpBackForwardList(bool dumpBackForwardList) { m_dumpBackForwardList = dumpBackForwardList; } @@ -230,6 +234,9 @@ public: bool globalFlag() const { return m_globalFlag; } void setGlobalFlag(bool globalFlag) { m_globalFlag = globalFlag; } + bool deferMainResourceDataLoad() const { return m_deferMainResourceDataLoad; } + void setDeferMainResourceDataLoad(bool flag) { m_deferMainResourceDataLoad = flag; } + const std::string& testPathOrURL() const { return m_testPathOrURL; } const std::string& expectedPixelHash() const { return m_expectedPixelHash; } @@ -298,6 +305,7 @@ private: bool m_dumpIconChanges; bool m_dumpVisitedLinksCallback; bool m_dumpWillCacheResponse; + bool m_generatePixelResults; bool m_callCloseOnWebViews; bool m_canOpenWindows; bool m_closeRemainingWindowsWhenComplete; @@ -316,6 +324,7 @@ private: bool m_geolocationPermission; bool m_handlesAuthenticationChallenges; bool m_isPrinting; + bool m_deferMainResourceDataLoad; std::string m_authenticationUsername; std::string m_authenticationPassword; diff --git a/WebKitTools/DumpRenderTree/PixelDumpSupport.cpp b/WebKitTools/DumpRenderTree/PixelDumpSupport.cpp index e372827..b5a5146 100644 --- a/WebKitTools/DumpRenderTree/PixelDumpSupport.cpp +++ b/WebKitTools/DumpRenderTree/PixelDumpSupport.cpp @@ -42,7 +42,13 @@ void dumpWebViewAsPixelsAndCompareWithExpected(const std::string& expectedHash) { - RefPtr<BitmapContext> context = createBitmapContextFromWebView(gLayoutTestController->testOnscreen(), gLayoutTestController->testRepaint(), gLayoutTestController->testRepaintSweepHorizontally(), gLayoutTestController->dumpSelectionRect()); + RefPtr<BitmapContext> context; +#if PLATFORM(MAC) + if (gLayoutTestController->isPrinting()) + context = createPagedBitmapContext(); + else +#endif + context = createBitmapContextFromWebView(gLayoutTestController->testOnscreen(), gLayoutTestController->testRepaint(), gLayoutTestController->testRepaintSweepHorizontally(), gLayoutTestController->dumpSelectionRect()); ASSERT(context); // Compute the hash of the bitmap context pixels diff --git a/WebKitTools/DumpRenderTree/PixelDumpSupport.h b/WebKitTools/DumpRenderTree/PixelDumpSupport.h index 94c5312..e172a83 100644 --- a/WebKitTools/DumpRenderTree/PixelDumpSupport.h +++ b/WebKitTools/DumpRenderTree/PixelDumpSupport.h @@ -36,6 +36,7 @@ class BitmapContext; void computeMD5HashStringForBitmapContext(BitmapContext*, char hashString[33]); +PassRefPtr<BitmapContext> createPagedBitmapContext(); PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect); void dumpBitmap(BitmapContext*); void dumpWebViewAsPixelsAndCompareWithExpected(const std::string& expectedHash); diff --git a/WebKitTools/DumpRenderTree/WorkQueueItem.h b/WebKitTools/DumpRenderTree/WorkQueueItem.h index 56be377..34276c8 100644 --- a/WebKitTools/DumpRenderTree/WorkQueueItem.h +++ b/WebKitTools/DumpRenderTree/WorkQueueItem.h @@ -53,6 +53,21 @@ private: JSRetainPtr<JSStringRef> m_target; }; +class LoadHTMLStringItem : public WorkQueueItem { +public: + LoadHTMLStringItem(const JSStringRef content, const JSStringRef baseURL) + : m_content(content) + , m_baseURL(baseURL) + { + } + +private: + virtual bool invoke() const; + + JSRetainPtr<JSStringRef> m_content; + JSRetainPtr<JSStringRef> m_baseURL; +}; + class ReloadItem : public WorkQueueItem { private: virtual bool invoke() const; diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp index 0f37d7e..ea1fd01 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp @@ -230,9 +230,15 @@ void LayoutTestController::WorkQueue::addWork(WorkItem* work) m_queue.append(work); } -void LayoutTestController::dumpAsText(const CppArgumentList&, CppVariant* result) +void LayoutTestController::dumpAsText(const CppArgumentList& arguments, CppVariant* result) { m_dumpAsText = true; + m_generatePixelResults = false; + + // Optional paramater, describing whether it's allowed to dump pixel results in dumpAsText mode. + if (arguments.size() > 0 && arguments[0].isBool()) + m_generatePixelResults = arguments[0].value.boolValue; + result->setNull(); } @@ -475,6 +481,7 @@ void LayoutTestController::reset() m_dumpWindowStatusChanges = false; m_dumpSelectionRect = false; m_dumpTitleChanges = false; + m_generatePixelResults = true; m_acceptsEditing = true; m_waitUntilDone = false; m_canOpenWindows = false; diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h index 5d65726..46a14de 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h @@ -57,7 +57,7 @@ public: // This function sets a flag that tells the test_shell to dump pages as // plain text, rather than as a text representation of the renderer's state. - // It takes no arguments, and ignores any that may be present. + // It takes an optional argument, whether to dump pixels results or not. void dumpAsText(const CppArgumentList&, CppVariant*); // This function should set a flag that tells the test_shell to print a line @@ -305,6 +305,7 @@ public: bool shouldDumpTitleChanges() { return m_dumpTitleChanges; } bool shouldDumpChildFrameScrollPositions() { return m_dumpChildFrameScrollPositions; } bool shouldDumpChildFramesAsText() { return m_dumpChildFramesAsText; } + bool shouldGeneratePixelResults() { return m_generatePixelResults; } bool acceptsEditing() { return m_acceptsEditing; } bool canOpenWindows() { return m_canOpenWindows; } bool shouldAddFileToPasteboard() { return m_shouldAddFileToPasteboard; } @@ -420,6 +421,9 @@ private: // If true, output a message when the page title is changed. bool m_dumpTitleChanges; + // If true, the test_shell will generate pixel results in dumpAsText mode + bool m_generatePixelResults; + // If true, the element will be treated as editable. This value is returned // from various editing callbacks that are called just before edit operations // are allowed. diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp index a4b161a..507f084 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp @@ -511,7 +511,7 @@ void TestShell::dump() if (dumpedAnything && m_params.printSeparators) m_printer->handleTextFooter(); - if (m_params.dumpPixels && !shouldDumpAsText) { + if (m_params.dumpPixels && m_layoutTestController->shouldGeneratePixelResults()) { // Image output: we write the image data to the file given on the // command line (for the dump pixels argument), and the MD5 sum to // stdout. diff --git a/WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.cpp b/WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.cpp index c28da1f..ef6c26a 100755 --- a/WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.cpp +++ b/WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.cpp @@ -583,6 +583,64 @@ void WebThemeEngineDRT::paintScrollbarTrack(WebCanvas* canvas, drawControl(canvas, rect, ctype, cstate); } +void WebThemeEngineDRT::paintSpinButton(WebCanvas* canvas, + int part, + int state, + int classicState, + const WebRect& rect) +{ + WebThemeControlDRT::Type ctype = WebThemeControlDRT::UnknownType; + WebThemeControlDRT::State cstate = WebThemeControlDRT::UnknownState; + + if (part == SPNP_UP) { + ctype = WebThemeControlDRT::UpArrowType; + switch (state) { + case UPS_NORMAL: + ASSERT(classicState == DFCS_SCROLLUP); + cstate = WebThemeControlDRT::NormalState; + break; + case UPS_DISABLED: + ASSERT(classicState == (DFCS_SCROLLUP | DFCS_INACTIVE)); + cstate = WebThemeControlDRT::DisabledState; + break; + case UPS_PRESSED: + ASSERT(classicState == (DFCS_SCROLLUP | DFCS_PUSHED)); + cstate = WebThemeControlDRT::PressedState; + break; + case UPS_HOT: + ASSERT(classicState == (DFCS_SCROLLUP | DFCS_HOT)); + cstate = WebThemeControlDRT::HoverState; + break; + default: + ASSERT_NOT_REACHED(); + } + } else if (part == SPNP_DOWN) { + ctype = WebThemeControlDRT::DownArrowType; + switch (state) { + case DNS_NORMAL: + ASSERT(classicState == DFCS_SCROLLDOWN); + cstate = WebThemeControlDRT::NormalState; + break; + case DNS_DISABLED: + ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_INACTIVE)); + cstate = WebThemeControlDRT::DisabledState; + break; + case DNS_PRESSED: + ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_PUSHED)); + cstate = WebThemeControlDRT::PressedState; + break; + case DNS_HOT: + ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_HOT)); + cstate = WebThemeControlDRT::HoverState; + break; + default: + ASSERT_NOT_REACHED(); + } + } else + ASSERT_NOT_REACHED(); + drawControl(canvas, rect, ctype, cstate); +} + void WebThemeEngineDRT::paintTextField(WebCanvas* canvas, int part, int state, diff --git a/WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.h b/WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.h index 89805b1..c731540 100644 --- a/WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.h +++ b/WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.h @@ -75,6 +75,10 @@ public: WebKit::WebCanvas*, int part, int state, int classicState, const WebKit::WebRect&, const WebKit::WebRect& alignRect); + virtual void paintSpinButton( + WebKit::WebCanvas*, int part, int state, int classicState, + const WebKit::WebRect&); + virtual void paintTextField( WebKit::WebCanvas*, int part, int state, int classicState, const WebKit::WebRect&, WebKit::WebColor, bool fillContentArea, diff --git a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp index da05804..2812224 100644 --- a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp @@ -419,11 +419,11 @@ void dump() } } - if (dumpPixels) { - if (!gLayoutTestController->dumpAsText() && !gLayoutTestController->dumpDOMAsWebArchive() && !gLayoutTestController->dumpSourceAsWebArchive()) { - dumpWebViewAsPixelsAndCompareWithExpected(gLayoutTestController->expectedPixelHash()); - } - } + if (dumpPixels + && gLayoutTestController->generatePixelResults() + && !gLayoutTestController->dumpDOMAsWebArchive() + && !gLayoutTestController->dumpSourceAsWebArchive()) + dumpWebViewAsPixelsAndCompareWithExpected(gLayoutTestController->expectedPixelHash()); // FIXME: call displayWebView here when we support --paint diff --git a/WebKitTools/DumpRenderTree/gtk/WorkQueueItemGtk.cpp b/WebKitTools/DumpRenderTree/gtk/WorkQueueItemGtk.cpp index e0e0ffb..afe81be 100644 --- a/WebKitTools/DumpRenderTree/gtk/WorkQueueItemGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/WorkQueueItemGtk.cpp @@ -56,6 +56,11 @@ bool LoadItem::invoke() const return true; } +bool LoadHTMLStringItem::invoke() const +{ + return false; +} + bool ReloadItem::invoke() const { webkit_web_frame_reload(mainFrame); diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm index ce02081..89a25cf 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm @@ -1129,7 +1129,7 @@ void dump() } } - if (dumpPixels && !dumpAsText) + if (dumpPixels && gLayoutTestController->generatePixelResults()) // FIXME: when isPrinting is set, dump the image with page separators. dumpWebViewAsPixelsAndCompareWithExpected(gLayoutTestController->expectedPixelHash()); diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm index aec4c19..6b921f0 100644 --- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm @@ -46,6 +46,7 @@ #import <WebKit/WebCoreStatistics.h> #import <WebKit/WebDataSource.h> #import <WebKit/WebDatabaseManagerPrivate.h> +#import <WebKit/WebDOMOperationsPrivate.h> #import <WebKit/WebFrame.h> #import <WebKit/WebFrameViewPrivate.h> #import <WebKit/WebGeolocationPosition.h> @@ -196,8 +197,12 @@ JSRetainPtr<JSStringRef> LayoutTestController::layerTreeAsText() const JSRetainPtr<JSStringRef> LayoutTestController::markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const { - // FIXME: Implement me. - return JSRetainPtr<JSStringRef>(); + DOMElement *element = [DOMElement _DOMElementFromJSContext:context value:nodeObject]; + if (!element) + return JSRetainPtr<JSStringRef>(); + + JSRetainPtr<JSStringRef> markerText(Adopt, JSStringCreateWithCFString((CFStringRef)[element _markerTextForListItem])); + return markerText; } int LayoutTestController::pageNumberForElementById(JSStringRef id, float pageWidthInPixels, float pageHeightInPixels) diff --git a/WebKitTools/DumpRenderTree/mac/ObjCController.m b/WebKitTools/DumpRenderTree/mac/ObjCController.m index aa9ee49..641d2cc 100644 --- a/WebKitTools/DumpRenderTree/mac/ObjCController.m +++ b/WebKitTools/DumpRenderTree/mac/ObjCController.m @@ -36,6 +36,11 @@ #import <pthread.h> #import <wtf/Assertions.h> +// Remove this once hasWebScriptKey has been made public. +@interface WebScriptObject (StagedForPublic) +- (BOOL)hasWebScriptKey:(NSString *)name; +@end + static void* runJavaScriptThread(void* arg) { JSGlobalContextRef ctx = JSGlobalContextCreate(0); @@ -66,6 +71,7 @@ static void* runJavaScriptThread(void* arg) || aSelector == @selector(accessStoredWebScriptObject) || aSelector == @selector(storeWebScriptObject:) || aSelector == @selector(testValueForKey) + || aSelector == @selector(testHasWebScriptKey:) || aSelector == @selector(testArray) ) return NO; @@ -92,6 +98,8 @@ static void* runJavaScriptThread(void* arg) return @"storeWebScriptObject"; if (aSelector == @selector(testValueForKey)) return @"testValueForKey"; + if (aSelector == @selector(testHasWebScriptKey:)) + return @"testHasWebScriptKey"; if (aSelector == @selector(testArray)) return @"testArray"; @@ -166,6 +174,12 @@ static void* runJavaScriptThread(void* arg) pthread_join(pthread, 0); } +- (BOOL)testHasWebScriptKey:(NSString *)key +{ + ASSERT(storedWebScriptObject); + return [storedWebScriptObject hasWebScriptKey:key]; +} + - (BOOL)testWrapperRoundTripping:(WebScriptObject *)webScriptObject { JSObjectRef jsObject = [webScriptObject JSObject]; diff --git a/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm b/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm index 0059b69..3967186 100644 --- a/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm +++ b/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm @@ -38,6 +38,7 @@ #include <wtf/Assertions.h> #include <wtf/RefPtr.h> +#import <WebKit/WebCoreStatistics.h> #import <WebKit/WebDocumentPrivate.h> #import <WebKit/WebHTMLViewPrivate.h> #import <WebKit/WebKit.h> @@ -104,21 +105,11 @@ void setupMainDisplayColorProfile() signal(SIGTERM, restoreMainDisplayColorProfile); } -PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect) +static PassRefPtr<BitmapContext> createBitmapContext(size_t pixelsWide, size_t pixelsHigh, size_t& rowBytes, void*& buffer) { - WebView* view = [mainFrame webView]; + rowBytes = (4 * pixelsWide + 63) & ~63; // Use a multiple of 64 bytes to improve CG performance - // If the WebHTMLView uses accelerated compositing, we need for force the on-screen capture path - // and also force Core Animation to start its animations with -display since the DRT window has autodisplay disabled. - if ([view _isUsingAcceleratedCompositing]) - onscreen = YES; - - NSSize webViewSize = [view frame].size; - size_t pixelsWide = static_cast<size_t>(webViewSize.width); - size_t pixelsHigh = static_cast<size_t>(webViewSize.height); - size_t rowBytes = (4 * pixelsWide + 63) & ~63; // Use a multiple of 64 bytes to improve CG performance - - void *buffer = calloc(pixelsHigh, rowBytes); + buffer = calloc(pixelsHigh, rowBytes); if (!buffer) return 0; @@ -140,9 +131,28 @@ PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool inc return 0; } - // The BitmapContext keeps the CGContextRef and the pixel buffer alive - RefPtr<BitmapContext> bitmapContext = BitmapContext::createByAdoptingBitmapAndContext(buffer, context); - + return BitmapContext::createByAdoptingBitmapAndContext(buffer, context); +} + +PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect) +{ + WebView* view = [mainFrame webView]; + + // If the WebHTMLView uses accelerated compositing, we need for force the on-screen capture path + // and also force Core Animation to start its animations with -display since the DRT window has autodisplay disabled. + if ([view _isUsingAcceleratedCompositing]) + onscreen = YES; + + NSSize webViewSize = [view frame].size; + size_t pixelsWide = static_cast<size_t>(webViewSize.width); + size_t pixelsHigh = static_cast<size_t>(webViewSize.height); + size_t rowBytes = 0; + void* buffer = 0; + RefPtr<BitmapContext> bitmapContext = createBitmapContext(pixelsWide, pixelsHigh, rowBytes, buffer); + if (!bitmapContext) + return 0; + CGContextRef context = bitmapContext->cgContext(); + NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO]; ASSERT(nsContext); @@ -254,3 +264,16 @@ PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool inc return bitmapContext.release(); } + +PassRefPtr<BitmapContext> createPagedBitmapContext() +{ + int pageWidthInPixels = LayoutTestController::maxViewWidth; + int pageHeightInPixels = LayoutTestController::maxViewHeight; + int numberOfPages = [mainFrame numberOfPages:pageWidthInPixels:pageHeightInPixels]; + size_t rowBytes = 0; + void* buffer = 0; + + RefPtr<BitmapContext> bitmapContext = createBitmapContext(pageWidthInPixels, numberOfPages * (pageHeightInPixels + 1) - 1, rowBytes, buffer); + [mainFrame printToCGContext:bitmapContext->cgContext():pageWidthInPixels:pageHeightInPixels]; + return bitmapContext.release(); +} diff --git a/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm b/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm index fca65f9..0855b83 100644 --- a/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm @@ -33,6 +33,7 @@ #import "LayoutTestController.h" #import <WebKit/WebKit.h> #import <WebKit/WebTypesInternal.h> +#import <WebKit/WebDataSourcePrivate.h> #import <wtf/Assertions.h> using namespace std; @@ -131,6 +132,10 @@ using namespace std; printf("%s\n", [string UTF8String]); } + if (!done && !gLayoutTestController->deferMainResourceDataLoad()) { + [dataSource _setDeferMainResourceDataLoad:false]; + } + if (!done && gLayoutTestController->willSendRequestReturnsNull()) return nil; @@ -167,6 +172,9 @@ using namespace std; - (void)webView:(WebView *)wv resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource { if (!gLayoutTestController->handlesAuthenticationChallenges()) { + NSString *string = [NSString stringWithFormat:@"%@ - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet", identifier]; + printf("%s\n", [string UTF8String]); + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; return; } diff --git a/WebKitTools/DumpRenderTree/mac/WorkQueueItemMac.mm b/WebKitTools/DumpRenderTree/mac/WorkQueueItemMac.mm index 4e39a5a..797afb7 100644 --- a/WebKitTools/DumpRenderTree/mac/WorkQueueItemMac.mm +++ b/WebKitTools/DumpRenderTree/mac/WorkQueueItemMac.mm @@ -54,6 +54,15 @@ bool LoadItem::invoke() const return true; } +bool LoadHTMLStringItem::invoke() const +{ + RetainPtr<CFStringRef> contentCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, m_content.get())); + RetainPtr<CFStringRef> baseURLCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, m_baseURL.get())); + + [mainFrame loadHTMLString:(NSString *)contentCF.get() baseURL:[NSURL URLWithString:(NSString *)baseURLCF.get()]]; + return true; +} + bool ReloadItem::invoke() const { [[mainFrame webView] reload:nil]; diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp index 3eb1714..022a867 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp @@ -847,6 +847,7 @@ void DumpRenderTree::dump() fputs("#EOF\n", stdout); fputs("#EOF\n", stderr); + // FIXME: All other ports don't dump pixels, if generatePixelResults is false. if (m_dumpPixels) { QImage image(m_page->viewportSize(), QImage::Format_ARGB32); image.fill(Qt::white); diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp index dd11428..3a6229f 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp @@ -72,6 +72,7 @@ void LayoutTestController::reset() DumpRenderTreeSupportQt::dumpFrameLoader(false); DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(false); DumpRenderTreeSupportQt::dumpResourceResponseMIMETypes(false); + DumpRenderTreeSupportQt::setDeferMainResourceDataLoad(true); DumpRenderTreeSupportQt::setWillSendRequestReturnsNullOnRedirect(false); DumpRenderTreeSupportQt::setWillSendRequestReturnsNull(false); DumpRenderTreeSupportQt::setWillSendRequestClearHeaders(QStringList()); @@ -249,6 +250,11 @@ void LayoutTestController::setWillSendRequestClearHeader(const QStringList& head DumpRenderTreeSupportQt::setWillSendRequestClearHeaders(headers); } +void LayoutTestController::setDeferMainResourceDataLoad(bool defer) +{ + DumpRenderTreeSupportQt::setDeferMainResourceDataLoad(defer); +} + void LayoutTestController::queueBackNavigation(int howFarBackward) { //qDebug() << ">>>queueBackNavigation" << howFarBackward; @@ -269,6 +275,11 @@ void LayoutTestController::queueLoad(const QString& url, const QString& target) WorkQueue::shared()->queue(new LoadItem(absoluteUrl, target, m_drt->webPage())); } +void LayoutTestController::queueLoadHTMLString(const QString& content, const QString& baseURL) +{ + WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL, m_drt->webPage())); +} + void LayoutTestController::queueReload() { //qDebug() << ">>>queueReload"; diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h index 76bc802..4e95381 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h @@ -112,6 +112,7 @@ public slots: void queueBackNavigation(int howFarBackward); void queueForwardNavigation(int howFarForward); void queueLoad(const QString& url, const QString& target = QString()); + void queueLoadHTMLString(const QString& content, const QString& baseURL = QString()); void queueReload(); void queueLoadingScript(const QString& script); void queueNonLoadingScript(const QString& script); @@ -148,6 +149,7 @@ public slots: void resetLoadFinished() { m_loadFinished = false; } void setWindowIsKey(bool isKey); void setMainFrameIsFirstResponder(bool isFirst); + void setDeferMainResourceDataLoad(bool); void setJavaScriptCanAccessClipboard(bool enable); void setXSSAuditorEnabled(bool enable); void setCaretBrowsingEnabled(bool enable); diff --git a/WebKitTools/DumpRenderTree/qt/WorkQueueItemQt.cpp b/WebKitTools/DumpRenderTree/qt/WorkQueueItemQt.cpp index 067e6aa..d1baf08 100644 --- a/WebKitTools/DumpRenderTree/qt/WorkQueueItemQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/WorkQueueItemQt.cpp @@ -60,6 +60,18 @@ bool LoadItem::invoke() const return true; } +bool LoadHTMLStringItem::invoke() const +{ + Q_ASSERT(m_webPage); + + QWebFrame* frame = m_webPage->mainFrame(); + if (!frame) + return false; + + frame->setHtml(m_content, QUrl(m_baseURL)); + return true; +} + bool ReloadItem::invoke() const { //qDebug() << ">>>ReloadItem::invoke"; diff --git a/WebKitTools/DumpRenderTree/qt/WorkQueueItemQt.h b/WebKitTools/DumpRenderTree/qt/WorkQueueItemQt.h index 94da5e1..97c9b04 100644 --- a/WebKitTools/DumpRenderTree/qt/WorkQueueItemQt.h +++ b/WebKitTools/DumpRenderTree/qt/WorkQueueItemQt.h @@ -64,6 +64,22 @@ private: QString m_target; }; +class LoadHTMLStringItem : public WorkQueueItem { +public: + LoadHTMLStringItem(const QString& content, const QString &baseURL, QWebPage *page) + : WorkQueueItem(page) + , m_content(content) + , m_baseURL(baseURL) + { + } + +private: + virtual bool invoke() const; + + QString m_content; + QString m_baseURL; +}; + class ReloadItem : public WorkQueueItem { public: ReloadItem(QWebPage *page) diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp index 451ff86..a1b72e1 100644 --- a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp @@ -134,7 +134,15 @@ bool setAlwaysAcceptCookies(bool alwaysAcceptCookies) wstring urlSuitableForTestResult(const wstring& url) { - if (!url.c_str() || url.find(L"file://") == wstring::npos) + if (url.find(L"file://") == wstring::npos) + return url; + + return lastPathComponent(url); +} + +wstring lastPathComponent(const wstring& url) +{ + if (url.empty()) return url; return PathFindFileNameW(url.c_str()); @@ -723,10 +731,11 @@ void dump() fflush(stderr); } - if (dumpPixels) { - if (!gLayoutTestController->dumpAsText() && !gLayoutTestController->dumpDOMAsWebArchive() && !gLayoutTestController->dumpSourceAsWebArchive()) - dumpWebViewAsPixelsAndCompareWithExpected(gLayoutTestController->expectedPixelHash()); - } + if (dumpPixels + && gLayoutTestController->generatePixelResults() + && !gLayoutTestController->dumpDOMAsWebArchive() + && !gLayoutTestController->dumpSourceAsWebArchive()) + dumpWebViewAsPixelsAndCompareWithExpected(gLayoutTestController->expectedPixelHash()); printf("#EOF\n"); // terminate the (possibly empty) pixels block fflush(stdout); diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h b/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h index cc4337b..e3497c9 100644 --- a/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h +++ b/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h @@ -49,6 +49,7 @@ extern HWND webViewWindow; #include <wtf/Vector.h> std::wstring urlSuitableForTestResult(const std::wstring& url); +std::wstring lastPathComponent(const std::wstring&); std::string toUTF8(BSTR); std::string toUTF8(const std::wstring&); IWebView* createWebViewAndOffscreenWindow(HWND* webViewWindow = 0); diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp index b79bb2a..a29623e 100644 --- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp +++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp @@ -196,8 +196,29 @@ JSRetainPtr<JSStringRef> LayoutTestController::layerTreeAsText() const JSRetainPtr<JSStringRef> LayoutTestController::markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const { - // FIXME: Implement me. - return JSRetainPtr<JSStringRef>(); + COMPtr<IWebView> webView; + if (FAILED(frame->webView(&webView))) + return 0; + + COMPtr<IWebViewPrivate> webViewPrivate(Query, webView); + if (!webViewPrivate) + return 0; + + COMPtr<IDOMElement> element; + if (FAILED(webViewPrivate->elementFromJS(context, nodeObject, &element))) + return 0; + + COMPtr<IDOMElementPrivate> elementPrivate(Query, element); + if (!elementPrivate) + return 0; + + BSTR textBSTR = 0; + if (FAILED(elementPrivate->markerTextForListItem(&textBSTR))) + return 0; + + JSRetainPtr<JSStringRef> markerText(Adopt, JSStringCreateWithBSTR(textBSTR)); + SysFreeString(textBSTR); + return markerText; } void LayoutTestController::waitForPolicyDelegate() diff --git a/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp b/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp index ce01933..825366a 100644 --- a/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp +++ b/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp @@ -250,6 +250,13 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::willSendRequest( descriptionSuitableForTestResult(redirectResponse).c_str()); } + if (!done && !gLayoutTestController->deferMainResourceDataLoad()) { + COMPtr<IWebDataSourcePrivate> dataSourcePrivate(Query, dataSource); + if (!dataSourcePrivate) + return E_FAIL; + dataSourcePrivate->setDeferMainResourceDataLoad(FALSE); + } + if (!done && gLayoutTestController->willSendRequestReturnsNull()) { *newRequest = 0; return S_OK; @@ -285,6 +292,7 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didReceiveAuthenticationChalleng return E_FAIL; if (!gLayoutTestController->handlesAuthenticationChallenges()) { + printf("%S - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet\n", descriptionSuitableForTestResult(identifier).c_str()); sender->continueWithoutCredentialForAuthenticationChallenge(challenge); return S_OK; } @@ -326,10 +334,10 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didReceiveResponse( if (FAILED(response->URL(&urlBSTR))) E_FAIL; - wstring url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR)); + wstring url = wstringFromBSTR(urlBSTR); ::SysFreeString(urlBSTR); - printf("%S has MIME type %S\n", url.c_str(), mimeType.c_str()); + printf("%S has MIME type %S\n", lastPathComponent(url).c_str(), mimeType.c_str()); } return S_OK; diff --git a/WebKitTools/DumpRenderTree/win/WorkQueueItemWin.cpp b/WebKitTools/DumpRenderTree/win/WorkQueueItemWin.cpp index 7c60d3d..a24ca37 100644 --- a/WebKitTools/DumpRenderTree/win/WorkQueueItemWin.cpp +++ b/WebKitTools/DumpRenderTree/win/WorkQueueItemWin.cpp @@ -81,6 +81,22 @@ bool LoadItem::invoke() const return true; } +bool LoadHTMLStringItem::invoke() const +{ + wstring content = jsStringRefToWString(m_content.get()); + wstring baseURL = jsStringRefToWString(m_baseURL.get()); + + BSTR contentBSTR = SysAllocString(content.c_str()); + BSTR baseURLBSTR = SysAllocString(baseURL.c_str()); + + frame->loadHTMLString(contentBSTR, baseURLBSTR); + + SysFreeString(contentBSTR); + SysFreeString(baseURLBSTR); + + return true; +} + bool ReloadItem::invoke() const { COMPtr<IWebView> webView; diff --git a/WebKitTools/DumpRenderTree/wx/DumpRenderTreeWx.cpp b/WebKitTools/DumpRenderTree/wx/DumpRenderTreeWx.cpp index c56f129..7142af2 100644 --- a/WebKitTools/DumpRenderTree/wx/DumpRenderTreeWx.cpp +++ b/WebKitTools/DumpRenderTree/wx/DumpRenderTreeWx.cpp @@ -201,13 +201,11 @@ void dump() } } - if (dumpPixels) { - if (!gLayoutTestController->dumpAsText() && - !gLayoutTestController->dumpDOMAsWebArchive() && - !gLayoutTestController->dumpSourceAsWebArchive()) { - // FIXME: Add support for dumping pixels - } - + if (dumpPixels + && gLayoutTestController->generatePixelResults() + && !gLayoutTestController->dumpDOMAsWebArchive() + && !gLayoutTestController->dumpSourceAsWebArchive()) { + // FIXME: Add support for dumping pixels fflush(stdout); } diff --git a/WebKitTools/DumpRenderTree/wx/WorkQueueItemWx.cpp b/WebKitTools/DumpRenderTree/wx/WorkQueueItemWx.cpp index 3e8da19..e6ecb75 100644 --- a/WebKitTools/DumpRenderTree/wx/WorkQueueItemWx.cpp +++ b/WebKitTools/DumpRenderTree/wx/WorkQueueItemWx.cpp @@ -36,6 +36,11 @@ bool LoadItem::invoke() const return false; } +bool LoadHTMLStringItem::invoke() const +{ + return false; +} + bool ReloadItem::invoke() const { return false; |