summaryrefslogtreecommitdiff
path: root/Tools/WebKitTestRunner/InjectedBundle
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/WebKitTestRunner/InjectedBundle')
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl5
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp18
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h11
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp53
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h5
5 files changed, 76 insertions, 16 deletions
diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
index 43062c5cc..768e89fe1 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
+++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
@@ -81,7 +81,6 @@ module WTR {
// 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);
@@ -129,6 +128,10 @@ module WTR {
void setShouldStayOnPageAfterHandlingBeforeUnload(in boolean flag);
void setDefersLoading(in boolean flag);
+
+ // Web intents testing.
+ void sendWebIntentResponse(in DOMString reply);
+ void deliverWebIntent(in DOMString action, in DOMString type, in DOMString data);
// Focus testing.
void addChromeInputField(in object callback);
diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
index c5bd14083..16371d1bc 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
+++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
@@ -50,6 +50,7 @@
#endif
#if ENABLE(WEB_INTENTS)
+#include <WebKit2/WKBundleIntentRequest.h>
#include <WebKit2/WKIntentData.h>
#endif
#if ENABLE(WEB_INTENTS_TAG)
@@ -361,7 +362,7 @@ void InjectedBundlePage::resetAfterTest()
WKBundleFrameRef frame = WKBundlePageGetMainFrame(m_page);
JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame);
#if PLATFORM(QT)
- DumpRenderTreeSupportQt::injectInternalsObject(context);
+ DumpRenderTreeSupportQt::resetInternalsObject(context);
#else
WebCoreTestSupport::resetInternalsObject(context);
#endif
@@ -425,20 +426,23 @@ void InjectedBundlePage::didFinishProgress(WKBundlePageRef, const void *clientIn
static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didFinishProgress();
}
-void InjectedBundlePage::didReceiveIntentForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKIntentDataRef intent, WKTypeRef* userData, const void* clientInfo)
+void InjectedBundlePage::didReceiveIntentForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleIntentRequestRef intentRequest, WKTypeRef* userData, const void* clientInfo)
{
#if ENABLE(WEB_INTENTS)
+ static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->m_currentIntentRequest = intentRequest;
+ WKRetainPtr<WKIntentDataRef> intent(AdoptWK, WKBundleIntentRequestCopyIntentData(intentRequest));
+
InjectedBundle::shared().stringBuilder()->append("Received Web Intent: action=");
- WKRetainPtr<WKStringRef> wkAction(AdoptWK, WKIntentDataCopyAction(intent));
+ WKRetainPtr<WKStringRef> wkAction(AdoptWK, WKIntentDataCopyAction(intent.get()));
InjectedBundle::shared().stringBuilder()->append(toWTFString(wkAction.get()));
InjectedBundle::shared().stringBuilder()->append(" type=");
- WKRetainPtr<WKStringRef> wkType(AdoptWK, WKIntentDataCopyType(intent));
+ WKRetainPtr<WKStringRef> wkType(AdoptWK, WKIntentDataCopyType(intent.get()));
InjectedBundle::shared().stringBuilder()->append(toWTFString(wkType.get()));
InjectedBundle::shared().stringBuilder()->append("\n");
// FIXME: Print number of ports when exposed in WebKit2
- WKRetainPtr<WKURLRef> wkServiceUrl(AdoptWK, WKIntentDataCopyService(intent));
+ WKRetainPtr<WKURLRef> wkServiceUrl(AdoptWK, WKIntentDataCopyService(intent.get()));
if (wkServiceUrl) {
WKRetainPtr<WKStringRef> wkService(AdoptWK, WKURLCopyString(wkServiceUrl.get()));
if (wkService && !WKStringIsEmpty(wkService.get())) {
@@ -448,7 +452,7 @@ void InjectedBundlePage::didReceiveIntentForFrame(WKBundlePageRef page, WKBundle
}
}
- WKRetainPtr<WKDictionaryRef> wkExtras(AdoptWK, WKIntentDataCopyExtras(intent));
+ WKRetainPtr<WKDictionaryRef> wkExtras(AdoptWK, WKIntentDataCopyExtras(intent.get()));
WKRetainPtr<WKArrayRef> wkExtraKeys(AdoptWK, WKDictionaryCopyKeys(wkExtras.get()));
const size_t numExtraKeys = WKArrayGetSize(wkExtraKeys.get());
for (size_t i = 0; i < numExtraKeys; ++i) {
@@ -461,7 +465,7 @@ void InjectedBundlePage::didReceiveIntentForFrame(WKBundlePageRef page, WKBundle
InjectedBundle::shared().stringBuilder()->append("\n");
}
- WKRetainPtr<WKArrayRef> wkSuggestions(AdoptWK, WKIntentDataCopySuggestions(intent));
+ WKRetainPtr<WKArrayRef> wkSuggestions(AdoptWK, WKIntentDataCopySuggestions(intent.get()));
const size_t numSuggestions = WKArrayGetSize(wkSuggestions.get());
for (size_t i = 0; i < numSuggestions; ++i) {
WKStringRef wkSuggestion = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkSuggestions.get(), i));
diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
index 824b1dfbd..074314e64 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
+++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
@@ -38,6 +38,11 @@ public:
~InjectedBundlePage();
WKBundlePageRef page() const { return m_page; }
+
+#if ENABLE(WEB_INTENTS)
+ WKBundleIntentRequestRef currentIntentRequest() const { return m_currentIntentRequest.get(); }
+#endif
+
void dump();
void stopLoading();
@@ -72,7 +77,7 @@ private:
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*);
- static void didReceiveIntentForFrame(WKBundlePageRef, WKBundleFrameRef, WKIntentDataRef, WKTypeRef*, const void*);
+ static void didReceiveIntentForFrame(WKBundlePageRef, WKBundleFrameRef, WKBundleIntentRequestRef, WKTypeRef*, const void*);
static void registerIntentServiceForFrame(WKBundlePageRef, WKBundleFrameRef, WKIntentServiceInfoRef, WKTypeRef*, const void*);
void didStartProvisionalLoadForFrame(WKBundleFrameRef);
@@ -164,6 +169,10 @@ private:
WKBundlePageRef m_page;
WKRetainPtr<WKBundleScriptWorldRef> m_world;
WKRetainPtr<WKBundleBackForwardListItemRef> m_previousTestBackForwardListItem;
+
+#if ENABLE(WEB_INTENTS)
+ WKRetainPtr<WKBundleIntentRequestRef> m_currentIntentRequest;
+#endif
};
} // namespace WTR
diff --git a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
index a365bff55..4981b3c58 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
+++ b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
@@ -42,11 +42,17 @@
#include <WebKit2/WKBundlePrivate.h>
#include <WebKit2/WKBundleScriptWorld.h>
#include <WebKit2/WKRetainPtr.h>
+#include <WebKit2/WKSerializedScriptValue.h>
#include <WebKit2/WebKit2.h>
#include <wtf/CurrentTime.h>
#include <wtf/HashMap.h>
#include <wtf/text/StringBuilder.h>
+#if ENABLE(WEB_INTENTS)
+#include <WebKit2/WKBundleIntentRequest.h>
+#include <WebKit2/WKIntentData.h>
+#endif
+
namespace WTR {
// This is lower than DumpRenderTree's timeout, to make it easier to work through the failures
@@ -374,12 +380,6 @@ int LayoutTestController::numberOfPages(double pageWidthInPixels, double pageHei
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());
@@ -613,6 +613,47 @@ void LayoutTestController::overridePreference(JSStringRef preference, bool value
WKBundleOverrideBoolPreferenceForTestRunner(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), toWK(preference).get(), value);
}
+void LayoutTestController::sendWebIntentResponse(JSStringRef reply)
+{
+#if ENABLE(WEB_INTENTS)
+ WKRetainPtr<WKBundleIntentRequestRef> currentRequest = InjectedBundle::shared().page()->currentIntentRequest();
+ if (!currentRequest)
+ return;
+
+ WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+ JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
+
+ if (reply) {
+ WKRetainPtr<WKSerializedScriptValueRef> serializedData(AdoptWK, WKSerializedScriptValueCreate(context, JSValueMakeString(context, reply), 0));
+ WKBundleIntentRequestPostResult(currentRequest.get(), serializedData.get());
+ } else {
+ JSRetainPtr<JSStringRef> errorReply(JSStringCreateWithUTF8CString("ERROR"));
+ WKRetainPtr<WKSerializedScriptValueRef> serializedData(AdoptWK, WKSerializedScriptValueCreate(context, JSValueMakeString(context, errorReply.get()), 0));
+ WKBundleIntentRequestPostFailure(currentRequest.get(), serializedData.get());
+ }
+#endif
+}
+
+void LayoutTestController::deliverWebIntent(JSStringRef action, JSStringRef type, JSStringRef data)
+{
+#if ENABLE(WEB_INTENTS)
+ WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+ JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
+
+ WKRetainPtr<WKStringRef> actionWK = toWK(action);
+ WKRetainPtr<WKStringRef> typeWK = toWK(type);
+ WKRetainPtr<WKSerializedScriptValueRef> dataWK(AdoptWK, WKSerializedScriptValueCreate(context, JSValueMakeString(context, data), 0));
+
+ WKRetainPtr<WKMutableDictionaryRef> intentInitDict(AdoptWK, WKMutableDictionaryCreate());
+ WKDictionaryAddItem(intentInitDict.get(), WKStringCreateWithUTF8CString("action"), actionWK.get());
+ WKDictionaryAddItem(intentInitDict.get(), WKStringCreateWithUTF8CString("type"), typeWK.get());
+ WKDictionaryAddItem(intentInitDict.get(), WKStringCreateWithUTF8CString("data"), dataWK.get());
+
+ WKRetainPtr<WKIntentDataRef> wkIntentData(AdoptWK, WKIntentDataCreate(intentInitDict.get()));
+ WKBundlePageDeliverIntentToFrame(InjectedBundle::shared().page()->page(), mainFrame, wkIntentData.get());
+#endif
+}
+
void LayoutTestController::setAlwaysAcceptCookies(bool accept)
{
WKBundleSetAlwaysAcceptCookies(InjectedBundle::shared().bundle(), accept);
diff --git a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
index 35033e29f..304396343 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
+++ b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
@@ -141,7 +141,6 @@ public:
// 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);
@@ -206,6 +205,10 @@ public:
void overridePreference(JSStringRef preference, bool value);
+ // Web intents testing.
+ void sendWebIntentResponse(JSStringRef reply);
+ void deliverWebIntent(JSStringRef action, JSStringRef type, JSStringRef data);
+
// Cookies testing
void setAlwaysAcceptCookies(bool);