diff options
Diffstat (limited to 'Tools/WebKitTestRunner/InjectedBundle')
9 files changed, 182 insertions, 13 deletions
diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl index a88a838..a331c64 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl @@ -77,8 +77,18 @@ module WTR { // Text search testing. boolean findString(in DOMString target, in object optionsArray); - // Evaluating script in a special context - [PassContext] void evaluateScriptInIsolatedWorld(in unsigned long worldID, in DOMString script) + // Evaluating script in a special context. + [PassContext] void evaluateScriptInIsolatedWorld(in unsigned long worldID, in DOMString script); + + // For Web Inspector tests + void showWebInspector(); + void closeWebInspector(); + void evaluateInWebInspector(in long callID, in DOMString script); + void setTimelineProfilingEnabled(in boolean enabled); + + void setPOSIXLocale(in DOMString locale); + + void setWillSendRequestReturnsNull(in boolean flag); }; } diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp index 972a606..d042431 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp @@ -118,6 +118,11 @@ InjectedBundlePage* InjectedBundle::page() const return m_pages[0].get(); } +void InjectedBundle::resetLocalSettings() +{ + setlocale(LC_ALL, ""); +} + void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody) { if (WKStringIsEqualToUTF8CString(messageName, "BeginTest")) { @@ -131,6 +136,9 @@ void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag return; } else if (WKStringIsEqualToUTF8CString(messageName, "Reset")) { m_state = Idle; + + resetLocalSettings(); + return; } diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h index 9778441..741ade4 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h @@ -82,6 +82,8 @@ private: void didInitializePageGroup(WKBundlePageGroupRef); void didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody); + void resetLocalSettings(); + void beginTesting(); WKBundleRef m_bundle; diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp index c5f4909..739da3b 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp @@ -29,6 +29,7 @@ #include "StringFunctions.h" #include <cmath> #include <JavaScriptCore/JSRetainPtr.h> +#include <WebCore/KURL.h> #include <WebKit2/WKArray.h> #include <WebKit2/WKBundle.h> #include <WebKit2/WKBundleBackForwardList.h> @@ -36,6 +37,7 @@ #include <WebKit2/WKBundleFrame.h> #include <WebKit2/WKBundleFramePrivate.h> #include <WebKit2/WKBundlePagePrivate.h> +#include <WebKit2/WKURLRequest.h> using namespace std; @@ -190,9 +192,20 @@ InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page) didCancelClientRedirectForFrame, willPerformClientRedirectForFrame, didHandleOnloadEventsForFrame, - shouldLoadResourceForFrame }; - WKBundlePageSetLoaderClient(m_page, &loaderClient); + WKBundlePageSetPageLoaderClient(m_page, &loaderClient); + + WKBundlePageResourceLoadClient resourceLoadClient = { + 0, + this, + didInitiateLoadForResource, + willSendRequestForFrame, + didReceiveResponseForResource, + didReceiveContentLengthForResource, + didFinishLoadForResource, + didFailLoadForResource + }; + WKBundlePageSetResourceLoadClient(m_page, &resourceLoadClient); WKBundlePageUIClient uiClient = { 0, @@ -204,6 +217,7 @@ InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page) willRunJavaScriptPrompt, 0, /*mouseDidMoveOverElement*/ 0, /*pageDidScroll*/ + 0, /*paintCustomOverhangArea*/ }; WKBundlePageSetUIClient(m_page, &uiClient); @@ -321,11 +335,35 @@ void InjectedBundlePage::didRunInsecureContentForFrame(WKBundlePageRef page, WKB static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didRunInsecureContentForFrame(frame); } -bool InjectedBundlePage::shouldLoadResourceForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKStringRef, const void* clientInfo) +void InjectedBundlePage::didInitiateLoadForResource(WKBundlePageRef page, WKBundleFrameRef frame, uint64_t identifier, WKURLRequestRef request, bool pageLoadIsProvisional, const void* clientInfo) +{ + static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didInitiateLoadForResource(page, frame, identifier, request, pageLoadIsProvisional); +} + +WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef page, WKBundleFrameRef frame, uint64_t identifier, WKURLRequestRef request, WKURLResponseRef redirectResponse, const void* clientInfo) +{ + return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->willSendRequestForFrame(page, frame, identifier, request, redirectResponse); +} + +void InjectedBundlePage::didReceiveResponseForResource(WKBundlePageRef page, WKBundleFrameRef frame, uint64_t identifier, WKURLResponseRef response, const void* clientInfo) { - return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldLoadResourceForFrame(frame); + static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didReceiveResponseForResource(page, frame, identifier, response); } +void InjectedBundlePage::didReceiveContentLengthForResource(WKBundlePageRef page, WKBundleFrameRef frame, uint64_t identifier, uint64_t length, const void* clientInfo) +{ + static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didReceiveContentLengthForResource(page, frame, identifier, length); +} + +void InjectedBundlePage::didFinishLoadForResource(WKBundlePageRef page, WKBundleFrameRef frame, uint64_t identifier, const void* clientInfo) +{ + static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didFinishLoadForResource(page, frame, identifier); +} + +void InjectedBundlePage::didFailLoadForResource(WKBundlePageRef page, WKBundleFrameRef frame, uint64_t identifier, WKErrorRef error, const void* clientInfo) +{ + static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didFinishLoadForResource(page, frame, identifier, error); +} void InjectedBundlePage::didStartProvisionalLoadForFrame(WKBundleFrameRef frame) { @@ -574,9 +612,46 @@ void InjectedBundlePage::didRunInsecureContentForFrame(WKBundleFrameRef frame) { } -bool InjectedBundlePage::shouldLoadResourceForFrame(WKBundleFrameRef frame) +void InjectedBundlePage::didInitiateLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKURLRequestRef, bool) +{ +} + +// Resource Load Client Callbacks + +WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef, uint64_t, WKURLRequestRef request, WKURLResponseRef) +{ + if (InjectedBundle::shared().isTestRunning() && InjectedBundle::shared().layoutTestController()->willSendRequestReturnsNull()) + return 0; + + string urlString = toSTD(adoptWK(WKURLCopyString(adoptWK(WKURLRequestCopyURL(request)).get()))); + WebCore::KURL url(WebCore::ParsedURLString, urlString.c_str()); + + if (!url.host().isEmpty() + && (equalIgnoringCase(url.protocol(), "http") || (equalIgnoringCase(url.protocol(), "https"))) + && (url.host() != "127.0.0.1") + && (url.host() != "255.255.255.255") // used in some tests that expect to get back an error + && (!equalIgnoringCase(url.host(), "localhost"))) { + InjectedBundle::shared().os() << "Blocked access to external URL " << urlString << "\n"; + return 0; + } + + return request; +} + +void InjectedBundlePage::didReceiveResponseForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t, WKURLResponseRef) +{ +} + +void InjectedBundlePage::didReceiveContentLengthForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t, uint64_t) +{ +} + +void InjectedBundlePage::didFinishLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t) +{ +} + +void InjectedBundlePage::didFailLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t, WKErrorRef) { - return true; } // UI Client Callbacks diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h index 3b99109..2c3e9df 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h @@ -63,7 +63,13 @@ private: static void didHandleOnloadEventsForFrame(WKBundlePageRef, WKBundleFrameRef, const void*); static void didDisplayInsecureContentForFrame(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void*); static void didRunInsecureContentForFrame(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void*); - static bool shouldLoadResourceForFrame(WKBundlePageRef, WKBundleFrameRef, WKStringRef, const void*); + static void didInitiateLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKURLRequestRef, bool pageLoadIsProvisional, const void*); + static WKURLRequestRef willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKURLRequestRef, WKURLResponseRef, const void*); + static void didReceiveResponseForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKURLResponseRef, const void*); + static void didReceiveContentLengthForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, uint64_t length, const void*); + static void didFinishLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, const void*); + static void didFailLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKErrorRef, const void*); + void didStartProvisionalLoadForFrame(WKBundleFrameRef); void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundleFrameRef); void didFailProvisionalLoadWithErrorForFrame(WKBundleFrameRef, WKErrorRef); @@ -79,7 +85,14 @@ private: void didHandleOnloadEventsForFrame(WKBundleFrameRef); void didDisplayInsecureContentForFrame(WKBundleFrameRef); void didRunInsecureContentForFrame(WKBundleFrameRef); - bool shouldLoadResourceForFrame(WKBundleFrameRef); + + // Resource Load Client + void didInitiateLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKURLRequestRef, bool pageLoadIsProvisional); + WKURLRequestRef willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKURLRequestRef, WKURLResponseRef); + void didReceiveResponseForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKURLResponseRef); + void didReceiveContentLengthForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, uint64_t length); + void didFinishLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier); + void didFailLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKErrorRef); // UI Client static void willAddMessageToConsole(WKBundlePageRef, WKStringRef message, uint32_t lineNumber, const void* clientInfo); diff --git a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp index 13c7b10..4707ed8 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp @@ -32,6 +32,7 @@ #include <WebKit2/WKBundleBackForwardList.h> #include <WebKit2/WKBundleFrame.h> #include <WebKit2/WKBundleFramePrivate.h> +#include <WebKit2/WKBundleInspector.h> #include <WebKit2/WKBundlePagePrivate.h> #include <WebKit2/WKBundleScriptWorld.h> #include <WebKit2/WKBundlePrivate.h> @@ -96,6 +97,7 @@ LayoutTestController::LayoutTestController() , m_waitToDump(false) , m_testRepaint(false) , m_testRepaintSweepHorizontally(false) + , m_willSendRequestReturnsNull(false) { platformInitialize(); } @@ -309,6 +311,27 @@ void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef wi setProperty(context, windowObject, "layoutTestController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception); } +void LayoutTestController::showWebInspector() +{ + WKBundleInspectorShow(WKBundlePageGetInspector(InjectedBundle::shared().page()->page())); +} + +void LayoutTestController::closeWebInspector() +{ + WKBundleInspectorClose(WKBundlePageGetInspector(InjectedBundle::shared().page()->page())); +} + +void LayoutTestController::evaluateInWebInspector(long callID, JSStringRef script) +{ + WKRetainPtr<WKStringRef> scriptWK = toWK(script); + WKBundleInspectorEvaluateScriptForTest(WKBundlePageGetInspector(InjectedBundle::shared().page()->page()), callID, scriptWK.get()); +} + +void LayoutTestController::setTimelineProfilingEnabled(bool enabled) +{ + WKBundleInspectorSetPageProfilingEnabled(WKBundlePageGetInspector(InjectedBundle::shared().page()->page()), enabled); +} + typedef WTF::HashMap<unsigned, WKRetainPtr<WKBundleScriptWorldRef> > WorldMap; static WorldMap& worldMap() { @@ -349,4 +372,11 @@ void LayoutTestController::evaluateScriptInIsolatedWorld(JSContextRef context, u JSEvaluateScript(jsContext, script, 0, 0, 0, 0); } +void LayoutTestController::setPOSIXLocale(JSStringRef locale) +{ + char localeBuf[32]; + JSStringGetUTF8CString(locale, localeBuf, sizeof(localeBuf)); + setlocale(LC_ALL, localeBuf); +} + } // namespace WTR diff --git a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h index 1f81970..9271124 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h +++ b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h @@ -126,6 +126,16 @@ public: void evaluateScriptInIsolatedWorld(JSContextRef, unsigned worldID, JSStringRef script); static unsigned worldIDForWorld(WKBundleScriptWorldRef); + void showWebInspector(); + void closeWebInspector(); + void evaluateInWebInspector(long callId, JSStringRef script); + void setTimelineProfilingEnabled(bool); + + void setPOSIXLocale(JSStringRef); + + bool willSendRequestReturnsNull() { return m_willSendRequestReturnsNull; } + void setWillSendRequestReturnsNull(bool f) { m_willSendRequestReturnsNull = f; } + private: static const double waitToDumpWatchdogTimerInterval; @@ -148,6 +158,8 @@ private: bool m_testRepaint; bool m_testRepaintSweepHorizontally; + bool m_willSendRequestReturnsNull; + PlatformTimerRef m_waitToDumpWatchdogTimer; }; diff --git a/Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp b/Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp index d8166d0..9c4bc68 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp @@ -29,10 +29,13 @@ #include "ActivateFonts.h" +#include <QApplication> #include <QByteArray> #include <QDir> +#include <QWindowsStyle> #ifdef Q_WS_X11 +#include <QX11Info> #include <fontconfig/fontconfig.h> #endif @@ -43,6 +46,8 @@ namespace WTR { void activateFonts() { #if defined(Q_WS_X11) + FcInit(); + static int numFonts = -1; // Some test cases may add or remove application fonts (via @font-face). @@ -78,6 +83,18 @@ void activateFonts() appFontSet = FcConfigGetFonts(config, FcSetApplication); numFonts = appFontSet->nfont; #endif + + QApplication::setGraphicsSystem("raster"); + QApplication::setStyle(new QWindowsStyle); + + QFont f("Sans Serif"); + f.setPointSize(9); + f.setWeight(QFont::Normal); + f.setStyle(QFont::StyleNormal); + QApplication::setFont(f); + + QX11Info::setAppDpiX(0, 96); + QX11Info::setAppDpiY(0, 96); } } diff --git a/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro b/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro index 92d31b8..24db4b8 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro +++ b/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro @@ -43,11 +43,11 @@ HEADERS += \ OBJECTS_DIR = obj/release } -include(../../../../WebKit.pri) +include(../../../../Source/WebKit.pri) include(../../../../Source/JavaScriptCore/JavaScriptCore.pri) -addJavaScriptCoreLib(../../../../Source/JavaScriptCore) +addJavaScriptCoreLib(../../../JavaScriptCore) include(../../../../Source/WebKit2/WebKit2.pri) -addWebKit2Lib(../../../../Source/WebKit2) +addWebKit2Lib(../../../WebKit2) INCLUDEPATH += \ $$PWD \ @@ -56,6 +56,8 @@ INCLUDEPATH += \ $$PWD/../Bindings \ $$PWD/../../../../Source/JavaScriptCore \ $$PWD/../../../../Source/JavaScriptCore/wtf \ + $$PWD/../../../../Source/WebCore \ + $$PWD/../../../../Source/WebCore/platform/text \ $$PWD/../../../../Source/WebKit2 \ $$PWD/../../../../Source/WebKit2/Shared \ $$GENERATED_SOURCES_DIR |