summaryrefslogtreecommitdiff
path: root/Source/WebCore/testing/js/WebCoreTestSupport.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/testing/js/WebCoreTestSupport.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/testing/js/WebCoreTestSupport.cpp')
-rw-r--r--Source/WebCore/testing/js/WebCoreTestSupport.cpp130
1 files changed, 125 insertions, 5 deletions
diff --git a/Source/WebCore/testing/js/WebCoreTestSupport.cpp b/Source/WebCore/testing/js/WebCoreTestSupport.cpp
index 92623793c..faffd0c4a 100644
--- a/Source/WebCore/testing/js/WebCoreTestSupport.cpp
+++ b/Source/WebCore/testing/js/WebCoreTestSupport.cpp
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2011, 2015 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -31,8 +32,15 @@
#include "Internals.h"
#include "JSDocument.h"
#include "JSInternals.h"
+#include "LogInitialization.h"
+#include "MockGamepadProvider.h"
+#include "Page.h"
+#include "URLParser.h"
+#include "WheelEventTestTrigger.h"
#include <JavaScriptCore/APICast.h>
+#include <JavaScriptCore/JSValueRef.h>
#include <interpreter/CallFrame.h>
+#include <runtime/IdentifierInlines.h>
using namespace JSC;
using namespace WebCore;
@@ -45,8 +53,8 @@ void injectInternalsObject(JSContextRef context)
JSLockHolder lock(exec);
JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
- if (scriptContext->isDocument())
- globalObject->putDirect(exec->vm(), Identifier(exec, Internals::internalsId), toJS(exec, globalObject, Internals::create(toDocument(scriptContext))));
+ if (is<Document>(*scriptContext))
+ globalObject->putDirect(exec->vm(), Identifier::fromString(exec, Internals::internalsId), toJS(exec, globalObject, Internals::create(downcast<Document>(*scriptContext))));
}
void resetInternalsObject(JSContextRef context)
@@ -55,9 +63,121 @@ void resetInternalsObject(JSContextRef context)
JSLockHolder lock(exec);
JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
- Page* page = toDocument(scriptContext)->frame()->page();
- Internals::resetToConsistentState(page);
+ Page* page = downcast<Document>(scriptContext)->frame()->page();
+ Internals::resetToConsistentState(*page);
InternalSettings::from(page)->resetToConsistentState();
}
+void monitorWheelEvents(WebCore::Frame& frame)
+{
+ Page* page = frame.page();
+ if (!page)
+ return;
+
+ page->ensureTestTrigger();
+}
+
+void setTestCallbackAndStartNotificationTimer(WebCore::Frame& frame, JSContextRef context, JSObjectRef jsCallbackFunction)
+{
+ Page* page = frame.page();
+ if (!page || !page->expectsWheelEventTriggers())
+ return;
+
+ JSValueProtect(context, jsCallbackFunction);
+
+ page->ensureTestTrigger().setTestCallbackAndStartNotificationTimer([=](void) {
+ JSObjectCallAsFunction(context, jsCallbackFunction, nullptr, 0, nullptr, nullptr);
+ JSValueUnprotect(context, jsCallbackFunction);
+ });
+}
+
+void clearWheelEventTestTrigger(WebCore::Frame& frame)
+{
+ Page* page = frame.page();
+ if (!page)
+ return;
+
+ page->clearTrigger();
+}
+
+void setLogChannelToAccumulate(const String& name)
+{
+#if !LOG_DISABLED
+ WebCore::setLogChannelToAccumulate(name);
+#else
+ UNUSED_PARAM(name);
+#endif
+}
+
+void initializeLogChannelsIfNecessary()
+{
+#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
+ WebCore::initializeLogChannelsIfNecessary();
+#endif
+}
+
+void setAllowsAnySSLCertificate(bool allowAnySSLCertificate)
+{
+ InternalSettings::setAllowsAnySSLCertificate(allowAnySSLCertificate);
+}
+
+void installMockGamepadProvider()
+{
+#if ENABLE(GAMEPAD)
+ GamepadProvider::setSharedProvider(MockGamepadProvider::singleton());
+#endif
+}
+
+void connectMockGamepad(unsigned gamepadIndex)
+{
+#if ENABLE(GAMEPAD)
+ MockGamepadProvider::singleton().connectMockGamepad(gamepadIndex);
+#else
+ UNUSED_PARAM(gamepadIndex);
+#endif
+}
+
+void disconnectMockGamepad(unsigned gamepadIndex)
+{
+#if ENABLE(GAMEPAD)
+ MockGamepadProvider::singleton().disconnectMockGamepad(gamepadIndex);
+#else
+ UNUSED_PARAM(gamepadIndex);
+#endif
+}
+
+void setMockGamepadDetails(unsigned gamepadIndex, const WTF::String& gamepadID, unsigned axisCount, unsigned buttonCount)
+{
+#if ENABLE(GAMEPAD)
+ MockGamepadProvider::singleton().setMockGamepadDetails(gamepadIndex, gamepadID, axisCount, buttonCount);
+#else
+ UNUSED_PARAM(gamepadIndex);
+ UNUSED_PARAM(gamepadID);
+ UNUSED_PARAM(axisCount);
+ UNUSED_PARAM(buttonCount);
+#endif
+}
+
+void setMockGamepadAxisValue(unsigned gamepadIndex, unsigned axisIndex, double axisValue)
+{
+#if ENABLE(GAMEPAD)
+ MockGamepadProvider::singleton().setMockGamepadAxisValue(gamepadIndex, axisIndex, axisValue);
+#else
+ UNUSED_PARAM(gamepadIndex);
+ UNUSED_PARAM(axisIndex);
+ UNUSED_PARAM(axisValue);
+#endif
+}
+
+void setMockGamepadButtonValue(unsigned gamepadIndex, unsigned buttonIndex, double buttonValue)
+{
+#if ENABLE(GAMEPAD)
+ MockGamepadProvider::singleton().setMockGamepadButtonValue(gamepadIndex, buttonIndex, buttonValue);
+#else
+ UNUSED_PARAM(gamepadIndex);
+ UNUSED_PARAM(buttonIndex);
+ UNUSED_PARAM(buttonValue);
+#endif
+}
+
}