summaryrefslogtreecommitdiff
path: root/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp')
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp81
1 files changed, 68 insertions, 13 deletions
diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
index c2fd342e1..740049544 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
@@ -48,6 +48,7 @@
#include <wtf/HashMap.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/PassOwnArrayPtr.h>
+#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
#if ENABLE(WEB_INTENTS)
@@ -123,11 +124,12 @@ void TestRunner::dumpAsText(bool dumpPixels)
m_dumpPixels = dumpPixels;
}
-// FIXME: Needs a full implementation see https://bugs.webkit.org/show_bug.cgi?id=42546
void TestRunner::setCustomPolicyDelegate(bool enabled, bool permissive)
{
m_policyDelegateEnabled = enabled;
m_policyDelegatePermissive = permissive;
+
+ InjectedBundle::shared().setCustomPolicyDelegate(enabled, permissive);
}
void TestRunner::waitForPolicyDelegate()
@@ -193,13 +195,6 @@ void TestRunner::suspendAnimations()
WKBundleFrameSuspendAnimations(mainFrame);
}
-JSRetainPtr<JSStringRef> TestRunner::layerTreeAsText() const
-{
- WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
- WKRetainPtr<WKStringRef> text(AdoptWK, WKBundleFrameCopyLayerTreeAsText(mainFrame));
- return toJS(text);
-}
-
void TestRunner::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
{
WKRetainPtr<WKStringRef> sourceWK = toWK(source);
@@ -489,8 +484,8 @@ unsigned TestRunner::worldIDForWorld(WKBundleScriptWorldRef world)
{
WorldMap::const_iterator end = worldMap().end();
for (WorldMap::const_iterator it = worldMap().begin(); it != end; ++it) {
- if (it->second == world)
- return it->first;
+ if (it->value == world)
+ return it->key;
}
return 0;
@@ -504,7 +499,7 @@ void TestRunner::evaluateScriptInIsolatedWorld(JSContextRef context, unsigned wo
if (!worldID)
world.adopt(WKBundleScriptWorldCreateWorld());
else {
- WKRetainPtr<WKBundleScriptWorldRef>& worldSlot = worldMap().add(worldID, 0).iterator->second;
+ WKRetainPtr<WKBundleScriptWorldRef>& worldSlot = worldMap().add(worldID, 0).iterator->value;
if (!worldSlot)
worldSlot.adopt(WKBundleScriptWorldCreateWorld());
world = worldSlot;
@@ -749,6 +744,16 @@ void TestRunner::setTabKeyCyclesThroughElements(bool enabled)
WKBundleSetTabKeyCyclesThroughElements(InjectedBundle::shared().bundle(), InjectedBundle::shared().page()->page(), enabled);
}
+void TestRunner::setSerializeHTTPLoads()
+{
+ WKBundleSetSerialLoadingEnabled(InjectedBundle::shared().bundle(), true);
+}
+
+void TestRunner::dispatchPendingLoadRequests()
+{
+ WKBundleDispatchPendingLoadRequests(InjectedBundle::shared().bundle());
+}
+
void TestRunner::grantWebNotificationPermission(JSStringRef origin)
{
WKRetainPtr<WKStringRef> originWK = toWK(origin);
@@ -780,9 +785,40 @@ void TestRunner::setGeolocationPermission(bool enabled)
InjectedBundle::shared().setGeolocationPermission(enabled);
}
-void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
+void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, JSValueRef jsAltitude, JSValueRef jsAltitudeAccuracy, JSValueRef jsHeading, JSValueRef jsSpeed)
{
- InjectedBundle::shared().setMockGeolocationPosition(latitude, longitude, accuracy);
+ WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+ JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
+
+ bool providesAltitude = false;
+ double altitude = 0.;
+ if (!JSValueIsUndefined(context, jsAltitude)) {
+ providesAltitude = true;
+ altitude = JSValueToNumber(context, jsAltitude, 0);
+ }
+
+ bool providesAltitudeAccuracy = false;
+ double altitudeAccuracy = 0.;
+ if (!JSValueIsUndefined(context, jsAltitudeAccuracy)) {
+ providesAltitudeAccuracy = true;
+ altitudeAccuracy = JSValueToNumber(context, jsAltitudeAccuracy, 0);
+ }
+
+ bool providesHeading = false;
+ double heading = 0.;
+ if (!JSValueIsUndefined(context, jsHeading)) {
+ providesHeading = true;
+ heading = JSValueToNumber(context, jsHeading, 0);
+ }
+
+ bool providesSpeed = false;
+ double speed = 0.;
+ if (!JSValueIsUndefined(context, jsSpeed)) {
+ providesSpeed = true;
+ speed = JSValueToNumber(context, jsSpeed, 0);
+ }
+
+ InjectedBundle::shared().setMockGeolocationPosition(latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed);
}
void TestRunner::setMockGeolocationPositionUnavailableError(JSStringRef message)
@@ -797,4 +833,23 @@ bool TestRunner::callShouldCloseOnWebView()
return WKBundleFrameCallShouldCloseOnWebView(mainFrame);
}
+void TestRunner::queueBackNavigation(unsigned howFarBackward)
+{
+ InjectedBundle::shared().queueBackNavigation(howFarBackward);
+}
+
+void TestRunner::queueLoad(JSStringRef url, JSStringRef target)
+{
+ WKRetainPtr<WKURLRef> baseURLWK(AdoptWK, WKBundleFrameCopyURL(WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page())));
+ WKRetainPtr<WKURLRef> urlWK(AdoptWK, WKURLCreateWithBaseURL(baseURLWK.get(), toWTFString(toWK(url)).utf8().data()));
+ WKRetainPtr<WKStringRef> urlStringWK(AdoptWK, WKURLCopyString(urlWK.get()));
+
+ InjectedBundle::shared().queueLoad(urlStringWK.get(), toWK(target).get());
+}
+
+void TestRunner::queueReload()
+{
+ InjectedBundle::shared().queueReload();
+}
+
} // namespace WTR