diff options
Diffstat (limited to 'WebKitTools/WebKitTestRunner/InjectedBundle')
6 files changed, 77 insertions, 10 deletions
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl index 583eb0a..acc2f47 100644 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl +++ b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl @@ -73,6 +73,9 @@ module WTR { // Compositing testing. DOMString layerTreeAsText(); + + // Text search testing. + boolean findString(in DOMString target, in object optionsArray); }; } diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp index 6bc1802..49d9db6 100644 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp +++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp @@ -61,6 +61,11 @@ void InjectedBundle::willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, c static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->willDestroyPage(page); } +void InjectedBundle::didInitializePageGroup(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, const void* clientInfo) +{ + static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didInitializePageGroup(pageGroup); +} + void InjectedBundle::didReceiveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo) { static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didReceiveMessage(messageName, messageBody); @@ -75,6 +80,7 @@ void InjectedBundle::initialize(WKBundleRef bundle) this, didCreatePage, willDestroyPage, + didInitializePageGroup, didReceiveMessage }; WKBundleSetClient(m_bundle, &client); @@ -99,6 +105,11 @@ void InjectedBundle::willDestroyPage(WKBundlePageRef page) } } +void InjectedBundle::didInitializePageGroup(WKBundlePageGroupRef pageGroup) +{ + m_pageGroup = pageGroup; +} + InjectedBundlePage* InjectedBundle::page() const { // It might be better to have the UI process send over a reference to the main @@ -137,7 +148,7 @@ void InjectedBundle::beginTesting() WKBundleSetShouldTrackVisitedLinks(m_bundle, false); WKBundleRemoveAllVisitedLinks(m_bundle); - WKBundleRemoveAllUserContent(m_bundle); + WKBundleRemoveAllUserContent(m_bundle, m_pageGroup); page()->reset(); } diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h index 2c6d14b..c1d8b37 100644 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h +++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h @@ -48,6 +48,7 @@ public: void initialize(WKBundleRef); WKBundleRef bundle() const { return m_bundle; } + WKBundlePageGroupRef pageGroup() const { return m_pageGroup; } LayoutTestController* layoutTestController() { return m_layoutTestController.get(); } GCController* gcController() { return m_gcController.get(); } @@ -70,15 +71,18 @@ private: static void didCreatePage(WKBundleRef, WKBundlePageRef, const void* clientInfo); static void willDestroyPage(WKBundleRef, WKBundlePageRef, const void* clientInfo); - static void didReceiveMessage(WKBundleRef, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo); + static void didInitializePageGroup(WKBundleRef, WKBundlePageGroupRef, const void* clientInfo); + static void didReceiveMessage(WKBundleRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo); void didCreatePage(WKBundlePageRef); void willDestroyPage(WKBundlePageRef); + void didInitializePageGroup(WKBundlePageGroupRef); void didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody); void beginTesting(); WKBundleRef m_bundle; + WKBundlePageGroupRef m_pageGroup; Vector<OwnPtr<InjectedBundlePage> > m_pages; RefPtr<LayoutTestController> m_layoutTestController; diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp index de37383..60e3130 100644 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp +++ b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp @@ -174,7 +174,7 @@ void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bo WKRetainPtr<WKStringRef> sourceWK = toWK(source); WKRetainPtr<WKBundleScriptWorldRef> scriptWorld(AdoptWK, WKBundleScriptWorldCreateWorld()); - WKBundleAddUserScript(InjectedBundle::shared().bundle(), scriptWorld.get(), sourceWK.get(), 0, 0, 0, + WKBundleAddUserScript(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), scriptWorld.get(), sourceWK.get(), 0, 0, 0, (runAtStart ? kWKInjectAtDocumentStart : kWKInjectAtDocumentEnd), (allFrames ? kWKInjectInAllFrames : kWKInjectInTopFrameOnly)); } @@ -184,7 +184,7 @@ void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames) WKRetainPtr<WKStringRef> sourceWK = toWK(source); WKRetainPtr<WKBundleScriptWorldRef> scriptWorld(AdoptWK, WKBundleScriptWorldCreateWorld()); - WKBundleAddUserStyleSheet(InjectedBundle::shared().bundle(), scriptWorld.get(), sourceWK.get(), 0, 0, 0, + WKBundleAddUserStyleSheet(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), scriptWorld.get(), sourceWK.get(), 0, 0, 0, (allFrames ? kWKInjectInAllFrames : kWKInjectInTopFrameOnly)); } @@ -233,6 +233,44 @@ void LayoutTestController::execCommand(JSStringRef name, JSStringRef argument) WKBundlePageExecuteEditingCommand(InjectedBundle::shared().page()->page(), toWK(name).get(), toWK(argument).get()); } +bool LayoutTestController::findString(JSStringRef target, JSValueRef optionsArrayAsValue) +{ + WKFindOptions options = 0; + + WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); + JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame); + JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length")); + JSObjectRef optionsArray = JSValueToObject(context, optionsArrayAsValue, 0); + JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0); + if (!JSValueIsNumber(context, lengthValue)) + return false; + + size_t length = static_cast<size_t>(JSValueToNumber(context, lengthValue, 0)); + for (size_t i = 0; i < length; ++i) { + JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0); + if (!JSValueIsString(context, value)) + continue; + + JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0)); + + if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive")) + options |= kWKFindOptionsCaseInsensitive; + else if (JSStringIsEqualToUTF8CString(optionName.get(), "AtWordStarts")) + options |= kWKFindOptionsAtWordStarts; + else if (JSStringIsEqualToUTF8CString(optionName.get(), "TreatMedialCapitalAsWordStart")) + options |= kWKFindOptionsTreatMedialCapitalAsWordStart; + else if (JSStringIsEqualToUTF8CString(optionName.get(), "Backwards")) + options |= kWKFindOptionsBackwards; + else if (JSStringIsEqualToUTF8CString(optionName.get(), "WrapAround")) + options |= kWKFindOptionsWrapAround; + else if (JSStringIsEqualToUTF8CString(optionName.get(), "StartInSelection")) { + // FIXME: No kWKFindOptionsStartInSelection. + } + } + + return WKBundlePageFindString(InjectedBundle::shared().page()->page(), toWK(target).get(), options); +} + bool LayoutTestController::isCommandEnabled(JSStringRef name) { return WKBundlePageIsEditingCommandEnabled(InjectedBundle::shared().page()->page(), toWK(name).get()); @@ -246,7 +284,7 @@ void LayoutTestController::setCanOpenWindows(bool) void LayoutTestController::setXSSAuditorEnabled(bool enabled) { - WKBundleOverrideXSSAuditorEnabledForTestRunner(InjectedBundle::shared().bundle(), true); + WKBundleOverrideXSSAuditorEnabledForTestRunner(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), true); } unsigned LayoutTestController::windowCount() diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h index 427d05e..2aaad08 100644 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h +++ b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h @@ -101,6 +101,9 @@ public: void addUserScript(JSStringRef source, bool runAtStart, bool allFrames); void addUserStyleSheet(JSStringRef source, bool allFrames); + // Text search testing. + bool findString(JSStringRef, JSValueRef optionsArray); + enum WhatToDump { RenderTree, MainFrameText, AllFramesText }; WhatToDump whatToDump() const { return m_whatToDump; } diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro b/WebKitTools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro index d596f33..2b3cbaf 100644 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro +++ b/WebKitTools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro @@ -2,6 +2,14 @@ TEMPLATE = lib isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../../.. +CONFIG(standalone_package) { + isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/../../../../WebCore/generated +} else { + isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = ../../../../WebCore/generated +} + +GENERATED_SOURCES_DIR = ../../generated + SOURCES += \ ../InjectedBundle.cpp \ ../InjectedBundle.h \ @@ -17,9 +25,9 @@ SOURCES += \ ../Bindings/JSWrapper.cpp \ ActivateFontsQt.cpp \ LayoutTestControllerQt.cpp \ - $$OUTPUT_DIR/WebKitTools/WebKitTestRunner/generated/JSEventSendingController.cpp \ - $$OUTPUT_DIR/WebKitTools/WebKitTestRunner/generated/JSGCController.cpp \ - $$OUTPUT_DIR/WebKitTools/WebKitTestRunner/generated/JSLayoutTestController.cpp \ + $$GENERATED_SOURCES_DIR/JSEventSendingController.cpp \ + $$GENERATED_SOURCES_DIR/JSGCController.cpp \ + $$GENERATED_SOURCES_DIR/JSLayoutTestController.cpp \ HEADERS += \ ../ActivateFonts.h \ @@ -50,11 +58,11 @@ INCLUDEPATH += \ $$PWD/../../../../JavaScriptCore/wtf \ $$PWD/../../../../WebKit2 \ $$PWD/../../../../WebKit2/Shared \ - $$OUTPUT_DIR/WebKitTools/WebKitTestRunner/generated + $$GENERATED_SOURCES_DIR INCLUDEPATH += \ $$OUTPUT_DIR/include \ - $$OUTPUT_DIR/WebCore/generated + $$WC_GENERATED_SOURCES_DIR PREFIX_HEADER = $$PWD/../../WebKitTestRunnerPrefix.h QMAKE_CXXFLAGS += "-include $$PREFIX_HEADER" |