diff options
Diffstat (limited to 'Tools/WebKitTestRunner/InjectedBundle')
13 files changed, 370 insertions, 41 deletions
diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl index 1e47772..ec33502 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,18 +26,17 @@ module WTR { interface EventSendingController { - [CustomArgumentHandling] void mouseDown(); - [CustomArgumentHandling] void mouseUp(); - [CustomArgumentHandling] void mouseMoveTo(); - [CustomArgumentHandling] void keyDown(); - [CustomArgumentHandling] void contextClick(); // CustomArgumentHandling only to throw exception while not implemented. - [CustomArgumentHandling] void leapForward(/*in unsigned long delay*/); // CustomArgumentHandling only to throw exception while not implemented. + void mouseDown(in long buttonNumber, in object modifierArray); + void mouseUp(in long buttonNumber, in object modifierArray); + void mouseMoveTo(in long x, in long y); + void leapForward(in long milliseconds); // Zoom functions. void textZoomIn(); void textZoomOut(); void zoomPageIn(); void zoomPageOut(); + void scalePageBy(in double scale, in double x, in double y); }; } diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl index a331c64..0593840 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl @@ -39,6 +39,7 @@ module WTR { void dumpSelectionRect(); void dumpStatusCallbacks(); void dumpTitleChanges(); + void dumpFullScreenCallbacks(); // Special options. void keepWebHistory(); @@ -46,6 +47,8 @@ module WTR { void setCanOpenWindows(in boolean value); void setCloseRemainingWindowsWhenComplete(in boolean value); void setXSSAuditorEnabled(in boolean value); + void setAllowUniversalAccessFromFileURLs(in boolean value); + void setAllowFileAccessFromFileURLs(in boolean value); // Special DOM functions. void clearBackForwardList(); @@ -55,12 +58,19 @@ module WTR { boolean isCommandEnabled(in DOMString name); DOMString markerTextForListItem(in object element); unsigned long windowCount(); + object shadowRoot(in object element); // Repaint testing. void testRepaint(); void repaintSweepHorizontally(); void display(); + // Printing + int numberOfPages(in double pageWidthInPixels, in double pageHeightInPixels); + int pageNumberForElementById(in DOMString id, in double pageWidthInPixels, in double pageHeightInPixels); + DOMString pageSizeAndMarginsInPixels(in int pageIndex, in int width, in int height, in int marginTop, in int marginRight, in int marginBottom, in int marginLeft); + boolean isPageBoxVisible(in int pageIndex); + // Animation testing. int numberOfActiveAnimations(); boolean pauseAnimationAtTimeOnElementWithId(in DOMString animationName, in double time, in DOMString elementId); @@ -70,7 +80,12 @@ module WTR { // UserContent testing. void addUserScript(in DOMString source, in boolean runAtStart, in boolean allFrames); void addUserStyleSheet(in DOMString source, in boolean allFrames); - + + // Local storage API + void clearAllDatabases(); + void setDatabaseQuota(in unsigned long long quota); + DOMString pathToLocalResource(in DOMString url); + // Compositing testing. DOMString layerTreeAsText(); diff --git a/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp b/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp index cc1720e..0725a85 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,7 +29,7 @@ #include "InjectedBundle.h" #include "InjectedBundlePage.h" #include "JSEventSendingController.h" -#include <WebKit2/WKBundlePage.h> +#include <WebKit2/WKBundleFrame.h> #include <WebKit2/WKBundlePagePrivate.h> #include <WebKit2/WKBundlePrivate.h> @@ -37,12 +37,67 @@ namespace WTR { static const float ZoomMultiplierRatio = 1.2f; +static bool operator==(const WKPoint& a, const WKPoint& b) +{ + return a.x == b.x && a.y == b.y; +} + +static WKEventModifiers parseModifier(JSStringRef modifier) +{ + if (JSStringIsEqualToUTF8CString(modifier, "ctrlKey")) + return kWKEventModifiersControlKey; + if (JSStringIsEqualToUTF8CString(modifier, "shiftKey") || JSStringIsEqualToUTF8CString(modifier, "rangeSelectionKey")) + return kWKEventModifiersShiftKey; + if (JSStringIsEqualToUTF8CString(modifier, "altKey")) + return kWKEventModifiersAltKey; + if (JSStringIsEqualToUTF8CString(modifier, "metaKey") || JSStringIsEqualToUTF8CString(modifier, "addSelectionKey")) + return kWKEventModifiersMetaKey; + return 0; +} + +static unsigned arrayLength(JSContextRef context, JSObjectRef array) +{ + JSRetainPtr<JSStringRef> lengthString(Adopt, JSStringCreateWithUTF8CString("length")); + JSValueRef lengthValue = JSObjectGetProperty(context, array, lengthString.get(), 0); + if (!lengthValue) + return 0; + return static_cast<unsigned>(JSValueToNumber(context, lengthValue, 0)); +} + +static WKEventModifiers parseModifierArray(JSContextRef context, JSValueRef arrayValue) +{ + if (!arrayValue) + return 0; + if (!JSValueIsObject(context, arrayValue)) + return 0; + JSObjectRef array = const_cast<JSObjectRef>(arrayValue); + unsigned length = arrayLength(context, array); + WKEventModifiers modifiers = 0; + for (unsigned i = 0; i < length; i++) { + JSValueRef exception = 0; + JSValueRef value = JSObjectGetPropertyAtIndex(context, array, i, &exception); + if (exception) + continue; + JSRetainPtr<JSStringRef> string(Adopt, JSValueToStringCopy(context, value, &exception)); + if (exception) + continue; + modifiers |= parseModifier(string.get()); + } + return modifiers; +} + PassRefPtr<EventSendingController> EventSendingController::create() { return adoptRef(new EventSendingController); } EventSendingController::EventSendingController() + : m_time(0) + , m_position() + , m_clickCount(0) + , m_clickTime(0) + , m_clickPosition() + , m_clickButton(kWKEventMouseButtonNoButton) { } @@ -55,40 +110,50 @@ JSClassRef EventSendingController::wrapperClass() return JSEventSendingController::eventSendingControllerClass(); } -static void setExceptionForString(JSContextRef context, JSValueRef* exception, const char* string) -{ - JSRetainPtr<JSStringRef> exceptionString(Adopt, JSStringCreateWithUTF8CString(string)); - *exception = JSValueMakeString(context, exceptionString.get()); -} - -void EventSendingController::mouseDown(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +void EventSendingController::mouseDown(int button, JSValueRef modifierArray) { - setExceptionForString(context, exception, "EventSender.mouseDown is not yet supported."); + WKBundlePageRef page = InjectedBundle::shared().page()->page(); + WKBundleFrameRef frame = WKBundlePageGetMainFrame(page); + JSContextRef context = WKBundleFrameGetJavaScriptContext(frame); + WKEventModifiers modifiers = parseModifierArray(context, modifierArray); + updateClickCount(button); + WKBundlePageSimulateMouseDown(page, button, m_position, m_clickCount, modifiers, m_time); } -void EventSendingController::mouseUp(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +void EventSendingController::mouseUp(int button, JSValueRef modifierArray) { - setExceptionForString(context, exception, "EventSender.mouseUp is not yet supported."); + WKBundlePageRef page = InjectedBundle::shared().page()->page(); + WKBundleFrameRef frame = WKBundlePageGetMainFrame(page); + JSContextRef context = WKBundleFrameGetJavaScriptContext(frame); + WKEventModifiers modifiers = parseModifierArray(context, modifierArray); + updateClickCount(button); + WKBundlePageSimulateMouseUp(page, button, m_position, m_clickCount, modifiers, m_time); } -void EventSendingController::mouseMoveTo(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +void EventSendingController::mouseMoveTo(int x, int y) { - setExceptionForString(context, exception, "EventSender.mouseMoveTo is not yet supported."); + m_position.x = x; + m_position.y = y; + WKBundlePageSimulateMouseMotion(InjectedBundle::shared().page()->page(), m_position, m_time); } -void EventSendingController::keyDown(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +void EventSendingController::leapForward(int milliseconds) { - setExceptionForString(context, exception, "EventSender.keyDown is not yet supported."); + m_time += milliseconds / 1000.0; } -void EventSendingController::contextClick(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +void EventSendingController::updateClickCount(WKEventMouseButton button) { - setExceptionForString(context, exception, "EventSender.contextClick is not yet supported."); -} + if (m_time - m_clickTime < 1 && m_position == m_clickPosition && button == m_clickButton) { + ++m_clickCount; + m_clickTime = m_time; + return; + } -void EventSendingController::leapForward(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) -{ - setExceptionForString(context, exception, "EventSender.leapForward is not yet supported."); + m_clickCount = 1; + m_clickTime = m_time; + m_clickPosition = m_position; + m_clickButton = button; } void EventSendingController::textZoomIn() @@ -127,6 +192,12 @@ void EventSendingController::zoomPageOut() WKBundlePageSetPageZoomFactor(InjectedBundle::shared().page()->page(), zoomFactor / ZoomMultiplierRatio); } +void EventSendingController::scalePageBy(double scale, double x, double y) +{ + WKPoint origin = { x, y }; + WKBundlePageSetScaleAtOrigin(InjectedBundle::shared().page()->page(), scale, origin); +} + // Object Creation void EventSendingController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception) diff --git a/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h b/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h index 400f60d..702b8e2 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h +++ b/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,6 +27,8 @@ #define EventSendingController_h #include "JSWrappable.h" +#include <WebKit2/WKEvent.h> +#include <WebKit2/WKGeometry.h> #include <wtf/PassRefPtr.h> namespace WTR { @@ -41,21 +43,30 @@ public: // JSWrappable virtual JSClassRef wrapperClass(); - void mouseDown(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); - void mouseUp(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); - void mouseMoveTo(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); - void keyDown(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); - void contextClick(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); - void leapForward(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + void mouseDown(int button, JSValueRef modifierArray); + void mouseUp(int button, JSValueRef modifierArray); + void mouseMoveTo(int x, int y); + void leapForward(int milliseconds); // Zoom functions. void textZoomIn(); void textZoomOut(); void zoomPageIn(); void zoomPageOut(); + void scalePageBy(double scale, double x, double y); private: EventSendingController(); + + void updateClickCount(WKEventMouseButton); + + double m_time; + WKPoint m_position; + + int m_clickCount; + double m_clickTime; + WKPoint m_clickPosition; + WKEventMouseButton m_clickButton; }; } // namespace WTR diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp index ec6b723..311530f 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp @@ -172,6 +172,8 @@ void InjectedBundle::beginTesting() WKBundleRemoveAllUserContent(m_bundle, m_pageGroup); page()->reset(); + + WKBundleClearAllDatabases(m_bundle); } void InjectedBundle::done() diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp index 3b73174..911e08f 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp @@ -202,6 +202,16 @@ InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page) }; WKBundlePageSetResourceLoadClient(m_page, &resourceLoadClient); + WKBundlePagePolicyClient policyClient = { + 0, + this, + decidePolicyForNavigationAction, + decidePolicyForNewWindowAction, + decidePolicyForResponse, + unableToImplementPolicy + }; + WKBundlePageSetPolicyClient(m_page, &policyClient); + WKBundlePageUIClient uiClient = { 0, this, @@ -234,6 +244,17 @@ InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page) didChangeSelection }; WKBundlePageSetEditorClient(m_page, &editorClient); + +#if ENABLE(FULLSCREEN_API) + WKBundlePageFullScreenClient fullScreenClient = { + 0, + this, + supportsFullScreen, + enterFullScreenForElement, + exitFullScreenForElement, + }; + WKBundlePageSetFullScreenClient(m_page, &fullScreenClient); +#endif } InjectedBundlePage::~InjectedBundlePage() @@ -252,6 +273,9 @@ void InjectedBundlePage::reset() WKBundlePageSetPageZoomFactor(m_page, 1); WKBundlePageSetTextZoomFactor(m_page, 1); + WKPoint origin = { 0, 0 }; + WKBundlePageSetScaleAtOrigin(m_page, 1, origin); + m_previousTestBackForwardListItem = adoptWK(WKBundleBackForwardListCopyItemAtIndex(WKBundlePageGetBackForwardList(m_page), 0)); WKBundleFrameClearOpener(WKBundlePageGetMainFrame(m_page)); @@ -666,6 +690,48 @@ void InjectedBundlePage::didFailLoadForResource(WKBundlePageRef, WKBundleFrameRe { } + +// Policy Client Callbacks + +WKBundlePagePolicyAction InjectedBundlePage::decidePolicyForNavigationAction(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo) +{ + return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->decidePolicyForNavigationAction(page, frame, navigationAction, request, userData); +} + +WKBundlePagePolicyAction InjectedBundlePage::decidePolicyForNewWindowAction(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKStringRef frameName, WKTypeRef* userData, const void* clientInfo) +{ + return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->decidePolicyForNewWindowAction(page, frame, navigationAction, request, frameName, userData); +} + +WKBundlePagePolicyAction InjectedBundlePage::decidePolicyForResponse(WKBundlePageRef page, WKBundleFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo) +{ + return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->decidePolicyForResponse(page, frame, response, request, userData); +} + +void InjectedBundlePage::unableToImplementPolicy(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void* clientInfo) +{ + static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->unableToImplementPolicy(page, frame, error, userData); +} + +WKBundlePagePolicyAction InjectedBundlePage::decidePolicyForNavigationAction(WKBundlePageRef, WKBundleFrameRef, WKBundleNavigationActionRef, WKURLRequestRef request, WKTypeRef*) +{ + return WKBundlePagePolicyActionUse; +} + +WKBundlePagePolicyAction InjectedBundlePage::decidePolicyForNewWindowAction(WKBundlePageRef, WKBundleFrameRef, WKBundleNavigationActionRef, WKURLRequestRef, WKStringRef, WKTypeRef*) +{ + return WKBundlePagePolicyActionUse; +} + +WKBundlePagePolicyAction InjectedBundlePage::decidePolicyForResponse(WKBundlePageRef, WKBundleFrameRef, WKURLResponseRef, WKURLRequestRef, WKTypeRef*) +{ + return WKBundlePagePolicyActionUse; +} + +void InjectedBundlePage::unableToImplementPolicy(WKBundlePageRef, WKBundleFrameRef, WKErrorRef, WKTypeRef*) +{ +} + // UI Client Callbacks void InjectedBundlePage::willAddMessageToConsole(WKBundlePageRef page, WKStringRef message, uint32_t lineNumber, const void *clientInfo) @@ -693,13 +759,38 @@ void InjectedBundlePage::willRunJavaScriptPrompt(WKBundlePageRef page, WKStringR static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->willRunJavaScriptPrompt(message, defaultValue, frame); } +static string lastFileURLPathComponent(const string& path) +{ + size_t pos = path.find("file://"); + ASSERT(string::npos != pos); + + string tmpPath = path.substr(pos + 7); + if (tmpPath.empty()) + return tmpPath; + + // Remove the trailing delimiter + if (tmpPath[tmpPath.length() - 1] == '/') + tmpPath.erase(tmpPath.length() - 1); + + pos = tmpPath.rfind('/'); + if (string::npos != pos) + return tmpPath.substr(pos + 1); + + return tmpPath; +} + void InjectedBundlePage::willAddMessageToConsole(WKStringRef message, uint32_t lineNumber) { if (!InjectedBundle::shared().isTestRunning()) return; - // FIXME: Strip file: urls. - InjectedBundle::shared().os() << "CONSOLE MESSAGE: line " << lineNumber << ": " << message << "\n"; + string messageString = toSTD(message); + size_t fileProtocolStart = messageString.find("file://"); + if (fileProtocolStart != string::npos) + // FIXME: The code below does not handle additional text after url nor multiple urls. This matches DumpRenderTree implementation. + messageString = messageString.substr(0, fileProtocolStart) + lastFileURLPathComponent(messageString.substr(fileProtocolStart)); + + InjectedBundle::shared().os() << "CONSOLE MESSAGE: line " << lineNumber << ": " << messageString << "\n"; } void InjectedBundlePage::willSetStatusbarText(WKStringRef statusbarText) @@ -918,6 +1009,31 @@ void InjectedBundlePage::didChangeSelection(WKStringRef notificationName) InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidChangeSelection:" << notificationName << "\n"; } +#if ENABLE(FULLSCREEN_API) +bool InjectedBundlePage::supportsFullScreen(WKBundlePageRef pageRef, WKFullScreenKeyboardRequestType requestType) +{ + if (InjectedBundle::shared().layoutTestController()->shouldDumpFullScreenCallbacks()) + InjectedBundle::shared().os() << "supportsFullScreen() == true\n"; + return true; +} + +void InjectedBundlePage::enterFullScreenForElement(WKBundlePageRef pageRef, WKBundleNodeHandleRef elementRef) +{ + if (InjectedBundle::shared().layoutTestController()->shouldDumpFullScreenCallbacks()) + InjectedBundle::shared().os() << "enterFullScreenForElement()\n"; + WKBundlePageWillEnterFullScreen(pageRef); + WKBundlePageDidEnterFullScreen(pageRef); +} + +void InjectedBundlePage::exitFullScreenForElement(WKBundlePageRef pageRef, WKBundleNodeHandleRef elementRef) +{ + if (InjectedBundle::shared().layoutTestController()->shouldDumpFullScreenCallbacks()) + InjectedBundle::shared().os() << "exitFullScreenForElement()\n"; + WKBundlePageWillExitFullScreen(pageRef); + WKBundlePageDidExitFullScreen(pageRef); +} +#endif + static bool compareByTargetName(WKBundleBackForwardListItemRef item1, WKBundleBackForwardListItemRef item2) { return toSTD(adoptWK(WKBundleBackForwardListItemCopyTarget(item1))) < toSTD(adoptWK(WKBundleBackForwardListItemCopyTarget(item2))); diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h index 2c3e9df..bc04e9a 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h @@ -94,6 +94,16 @@ private: void didFinishLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier); void didFailLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKErrorRef); + // WKBundlePagePolicyClient + static WKBundlePagePolicyAction decidePolicyForNavigationAction(WKBundlePageRef, WKBundleFrameRef, WKBundleNavigationActionRef, WKURLRequestRef, WKTypeRef*, const void*); + static WKBundlePagePolicyAction decidePolicyForNewWindowAction(WKBundlePageRef, WKBundleFrameRef, WKBundleNavigationActionRef, WKURLRequestRef, WKStringRef frameName, WKTypeRef*, const void*); + static WKBundlePagePolicyAction decidePolicyForResponse(WKBundlePageRef, WKBundleFrameRef, WKURLResponseRef, WKURLRequestRef, WKTypeRef*, const void*); + static void unableToImplementPolicy(WKBundlePageRef, WKBundleFrameRef, WKErrorRef, WKTypeRef*, const void*); + WKBundlePagePolicyAction decidePolicyForNavigationAction(WKBundlePageRef, WKBundleFrameRef, WKBundleNavigationActionRef, WKURLRequestRef, WKTypeRef*); + WKBundlePagePolicyAction decidePolicyForNewWindowAction(WKBundlePageRef, WKBundleFrameRef, WKBundleNavigationActionRef, WKURLRequestRef, WKStringRef frameName, WKTypeRef*); + WKBundlePagePolicyAction decidePolicyForResponse(WKBundlePageRef, WKBundleFrameRef, WKURLResponseRef, WKURLRequestRef, WKTypeRef*); + void unableToImplementPolicy(WKBundlePageRef, WKBundleFrameRef, WKErrorRef, WKTypeRef*); + // UI Client static void willAddMessageToConsole(WKBundlePageRef, WKStringRef message, uint32_t lineNumber, const void* clientInfo); static void willSetStatusbarText(WKBundlePageRef, WKStringRef statusbarText, const void* clientInfo); @@ -106,6 +116,13 @@ private: void willRunJavaScriptConfirm(WKStringRef message, WKBundleFrameRef); void willRunJavaScriptPrompt(WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef); +#if ENABLE(FULLSCREEN_API) + // Full Screen client + static bool supportsFullScreen(WKBundlePageRef, WKFullScreenKeyboardRequestType); + static void enterFullScreenForElement(WKBundlePageRef, WKBundleNodeHandleRef element); + static void exitFullScreenForElement(WKBundlePageRef, WKBundleNodeHandleRef element); +#endif + // Editor client static bool shouldBeginEditing(WKBundlePageRef, WKBundleRangeHandleRef, const void* clientInfo); static bool shouldEndEditing(WKBundlePageRef, WKBundleRangeHandleRef, const void* clientInfo); diff --git a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp index 7c49d03..45725b4 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp @@ -29,14 +29,17 @@ #include "InjectedBundle.h" #include "InjectedBundlePage.h" #include "JSLayoutTestController.h" +#include "PlatformWebView.h" #include "StringFunctions.h" +#include "TestController.h" #include <WebKit2/WKBundleBackForwardList.h> #include <WebKit2/WKBundleFrame.h> #include <WebKit2/WKBundleFramePrivate.h> #include <WebKit2/WKBundleInspector.h> +#include <WebKit2/WKBundleNodeHandlePrivate.h> #include <WebKit2/WKBundlePagePrivate.h> -#include <WebKit2/WKBundleScriptWorld.h> #include <WebKit2/WKBundlePrivate.h> +#include <WebKit2/WKBundleScriptWorld.h> #include <WebKit2/WKRetainPtr.h> #include <WebKit2/WebKit2.h> #include <wtf/HashMap.h> @@ -96,6 +99,7 @@ LayoutTestController::LayoutTestController() , m_dumpStatusCallbacks(false) , m_dumpTitleChanges(false) , m_dumpPixels(true) + , m_dumpFullScreenCallbacks(false) , m_waitToDump(false) , m_testRepaint(false) , m_testRepaintSweepHorizontally(false) @@ -286,6 +290,16 @@ bool LayoutTestController::findString(JSStringRef target, JSValueRef optionsArra return WKBundlePageFindString(InjectedBundle::shared().page()->page(), toWK(target).get(), options); } +void LayoutTestController::clearAllDatabases() +{ + WKBundleClearAllDatabases(InjectedBundle::shared().bundle()); +} + +void LayoutTestController::setDatabaseQuota(uint64_t quota) +{ + return WKBundleSetDatabaseQuota(InjectedBundle::shared().bundle(), quota); +} + bool LayoutTestController::isCommandEnabled(JSStringRef name) { return WKBundlePageIsEditingCommandEnabled(InjectedBundle::shared().page()->page(), toWK(name).get()); @@ -307,11 +321,59 @@ void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool enabled) WKBundleOverrideAllowUniversalAccessFromFileURLsForTestRunner(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), enabled); } +void LayoutTestController::setAllowFileAccessFromFileURLs(bool enabled) +{ + WKBundleSetAllowFileAccessFromFileURLs(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), enabled); +} + +int LayoutTestController::numberOfPages(double pageWidthInPixels, double pageHeightInPixels) +{ + WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); + return WKBundleNumberOfPages(InjectedBundle::shared().bundle(), mainFrame, pageWidthInPixels, pageHeightInPixels); +} + +int LayoutTestController::pageNumberForElementById(JSStringRef id, double pageWidthInPixels, double pageHeightInPixels) +{ + WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); + return WKBundlePageNumberForElementById(InjectedBundle::shared().bundle(), mainFrame, toWK(id).get(), pageWidthInPixels, pageHeightInPixels); +} + +JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) +{ + WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); + return toJS(WKBundlePageSizeAndMarginsInPixels(InjectedBundle::shared().bundle(), mainFrame, pageIndex, width, height, marginTop, marginRight, marginBottom, marginLeft)); +} + +bool LayoutTestController::isPageBoxVisible(int pageIndex) +{ + WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); + return WKBundleIsPageBoxVisible(InjectedBundle::shared().bundle(), mainFrame, pageIndex); +} + unsigned LayoutTestController::windowCount() { return InjectedBundle::shared().pageCount(); } +JSValueRef LayoutTestController::shadowRoot(JSValueRef element) +{ + WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); + JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame); + + if (!element || !JSValueIsObject(context, element)) + return JSValueMakeNull(context); + + WKRetainPtr<WKBundleNodeHandleRef> domElement = adoptWK(WKBundleNodeHandleCreate(context, const_cast<JSObjectRef>(element))); + if (!domElement) + return JSValueMakeNull(context); + + WKRetainPtr<WKBundleNodeHandleRef> shadowRootDOMElement = adoptWK(WKBundleNodeHandleCopyElementShadowRoot(domElement.get())); + if (!shadowRootDOMElement) + return JSValueMakeNull(context); + + return WKBundleFrameGetJavaScriptWrapperForNodeForWorld(mainFrame, shadowRootDOMElement.get(), WKBundleScriptWorldNormalWorld()); +} + void LayoutTestController::clearBackForwardList() { WKBundleBackForwardListClear(WKBundlePageGetBackForwardList(InjectedBundle::shared().page()->page())); diff --git a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h index b37f102..00d7e57 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h +++ b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h @@ -67,6 +67,7 @@ public: void dumpSelectionRect() { } // Will need to do something when we support pixel tests. void dumpStatusCallbacks() { m_dumpStatusCallbacks = true; } void dumpTitleChanges() { m_dumpTitleChanges = true; } + void dumpFullScreenCallbacks() { m_dumpFullScreenCallbacks = true; } // Special options. void keepWebHistory(); @@ -75,6 +76,7 @@ public: void setCloseRemainingWindowsWhenComplete(bool value) { m_shouldCloseExtraWindows = value; } void setXSSAuditorEnabled(bool); void setAllowUniversalAccessFromFileURLs(bool); + void setAllowFileAccessFromFileURLs(bool); // Special DOM functions. JSValueRef computedStyleIncludingVisitedInfo(JSValueRef element); @@ -84,6 +86,7 @@ public: bool isCommandEnabled(JSStringRef name); JSRetainPtr<JSStringRef> markerTextForListItem(JSValueRef element); unsigned windowCount(); + JSValueRef shadowRoot(JSValueRef element); // Repaint testing. void testRepaint() { m_testRepaint = true; } @@ -106,6 +109,17 @@ public: // Text search testing. bool findString(JSStringRef, JSValueRef optionsArray); + // Local storage + void clearAllDatabases(); + void setDatabaseQuota(uint64_t); + JSRetainPtr<JSStringRef> pathToLocalResource(JSStringRef); + + // Printing + int numberOfPages(double pageWidthInPixels, double pageHeightInPixels); + int pageNumberForElementById(JSStringRef, double pageWidthInPixels, double pageHeightInPixels); + JSRetainPtr<JSStringRef> pageSizeAndMarginsInPixels(int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft); + bool isPageBoxVisible(int pageIndex); + enum WhatToDump { RenderTree, MainFrameText, AllFramesText }; WhatToDump whatToDump() const { return m_whatToDump; } @@ -116,6 +130,7 @@ public: bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; } bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; } bool shouldDumpPixels() const { return m_dumpPixels; } + bool shouldDumpFullScreenCallbacks() const { return m_dumpFullScreenCallbacks; } bool waitToDump() const { return m_waitToDump; } void waitToDumpWatchdogTimerFired(); @@ -157,6 +172,7 @@ private: bool m_dumpStatusCallbacks; bool m_dumpTitleChanges; bool m_dumpPixels; + bool m_dumpFullScreenCallbacks; bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called. bool m_testRepaint; bool m_testRepaintSweepHorizontally; diff --git a/Tools/WebKitTestRunner/InjectedBundle/mac/LayoutTestControllerMac.mm b/Tools/WebKitTestRunner/InjectedBundle/mac/LayoutTestControllerMac.mm index 2eb4d5b..1d5d008 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/mac/LayoutTestControllerMac.mm +++ b/Tools/WebKitTestRunner/InjectedBundle/mac/LayoutTestControllerMac.mm @@ -56,4 +56,9 @@ void LayoutTestController::initializeWaitToDumpWatchdogTimerIfNeeded() CFRunLoopAddTimer(CFRunLoopGetCurrent(), m_waitToDumpWatchdogTimer.get(), kCFRunLoopCommonModes); } +JSRetainPtr<JSStringRef> LayoutTestController::pathToLocalResource(JSStringRef url) +{ + return JSStringRetain(url); // Do nothing on mac. +} + } // namespace WTR diff --git a/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro b/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro index 6838205..0bac510 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro +++ b/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro @@ -72,7 +72,7 @@ INCLUDEPATH = \ PREFIX_HEADER = $$PWD/../../WebKitTestRunnerPrefix.h *-g++*:QMAKE_CXXFLAGS += "-include $$PREFIX_HEADER" -unix:!mac:!symbian { +unix:!mac:!symbian:!embedded { CONFIG += link_pkgconfig PKGCONFIG += fontconfig } @@ -80,3 +80,6 @@ unix:!mac:!symbian { TARGET = WTRInjectedBundle DESTDIR = $$OUTPUT_DIR/lib !CONFIG(standalone_package): CONFIG -= app_bundle +linux-* { + QMAKE_LFLAGS += -Wl,--no-undefined +} diff --git a/Tools/WebKitTestRunner/InjectedBundle/qt/LayoutTestControllerQt.cpp b/Tools/WebKitTestRunner/InjectedBundle/qt/LayoutTestControllerQt.cpp index 91f49ea..72902e1 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/qt/LayoutTestControllerQt.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/qt/LayoutTestControllerQt.cpp @@ -28,6 +28,7 @@ #include "LayoutTestController.h" #include "InjectedBundle.h" +#include <QDir> #include <QObject> namespace WTR { @@ -70,6 +71,12 @@ void LayoutTestController::initializeWaitToDumpWatchdogTimerIfNeeded() m_waitToDumpWatchdogTimer.start(waitToDumpWatchdogTimerInterval * 1000); } +JSRetainPtr<JSStringRef> LayoutTestController::pathToLocalResource(JSStringRef url) +{ + QString path = QDir::toNativeSeparators(QString(reinterpret_cast<const QChar*>(JSStringGetCharactersPtr(url)), JSStringGetLength(url))); + return JSStringCreateWithCharacters(reinterpret_cast<const JSChar*>(path.constData()), path.length()); +} + } // namespace WTR #include "LayoutTestControllerQt.moc" diff --git a/Tools/WebKitTestRunner/InjectedBundle/win/LayoutTestControllerWin.cpp b/Tools/WebKitTestRunner/InjectedBundle/win/LayoutTestControllerWin.cpp index 7c500f2..88230c4 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/win/LayoutTestControllerWin.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/win/LayoutTestControllerWin.cpp @@ -59,4 +59,9 @@ void LayoutTestController::initializeWaitToDumpWatchdogTimerIfNeeded() m_waitToDumpWatchdogTimer = ::SetTimer(0, waitToDumpWatchdogTimerIdentifier, waitToDumpWatchdogTimerInterval * 1000, WTR::waitToDumpWatchdogTimerFired); } +JSRetainPtr<JSStringRef> LayoutTestController::pathToLocalResource(JSStringRef url) +{ + return JSStringRetain(url); // TODO. +} + } // namespace WTR |