summaryrefslogtreecommitdiff
path: root/Source/WebCore/testing/js
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-10-15 09:45:50 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-10-15 09:45:50 +0000
commite15dd966d523731101f70ccf768bba12435a0208 (patch)
treeae9cb828a24ded2585a41af3f21411523b47897d /Source/WebCore/testing/js
downloadWebKitGtk-tarball-e15dd966d523731101f70ccf768bba12435a0208.tar.gz
webkitgtk-2.10.2webkitgtk-2.10.2
Diffstat (limited to 'Source/WebCore/testing/js')
-rw-r--r--Source/WebCore/testing/js/WebCoreTestSupport.cpp100
-rw-r--r--Source/WebCore/testing/js/WebCoreTestSupport.h52
-rw-r--r--Source/WebCore/testing/js/WebCoreTestSupportPrefix.cpp26
-rw-r--r--Source/WebCore/testing/js/WebCoreTestSupportPrefix.h156
4 files changed, 334 insertions, 0 deletions
diff --git a/Source/WebCore/testing/js/WebCoreTestSupport.cpp b/Source/WebCore/testing/js/WebCoreTestSupport.cpp
new file mode 100644
index 000000000..f7c971c80
--- /dev/null
+++ b/Source/WebCore/testing/js/WebCoreTestSupport.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2011, 2015 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebCoreTestSupport.h"
+
+#include "Frame.h"
+#include "InternalSettings.h"
+#include "Internals.h"
+#include "JSDocument.h"
+#include "JSInternals.h"
+#include "Page.h"
+#include "WheelEventTestTrigger.h"
+#include <JavaScriptCore/APICast.h>
+#include <JavaScriptCore/JSValueRef.h>
+#include <JavaScriptCore/Profile.h>
+#include <interpreter/CallFrame.h>
+#include <runtime/IdentifierInlines.h>
+
+using namespace JSC;
+using namespace WebCore;
+
+namespace WebCoreTestSupport {
+
+void injectInternalsObject(JSContextRef context)
+{
+ ExecState* exec = toJS(context);
+ JSLockHolder lock(exec);
+ JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
+ ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
+ 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)
+{
+ ExecState* exec = toJS(context);
+ JSLockHolder lock(exec);
+ JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
+ ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
+ 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();
+}
+
+}
diff --git a/Source/WebCore/testing/js/WebCoreTestSupport.h b/Source/WebCore/testing/js/WebCoreTestSupport.h
new file mode 100644
index 000000000..1dc8333ce
--- /dev/null
+++ b/Source/WebCore/testing/js/WebCoreTestSupport.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011, 2015 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebCoreTestSupport_h
+#define WebCoreTestSupport_h
+
+typedef const struct OpaqueJSContext* JSContextRef;
+typedef struct OpaqueJSValue* JSObjectRef;
+
+#if PLATFORM(COCOA)
+#define TEST_SUPPORT_EXPORT WTF_EXPORT_PRIVATE
+#else
+#define TEST_SUPPORT_EXPORT
+#endif
+
+namespace WebCore {
+class Frame;
+}
+
+namespace WebCoreTestSupport {
+
+void injectInternalsObject(JSContextRef) TEST_SUPPORT_EXPORT;
+void resetInternalsObject(JSContextRef) TEST_SUPPORT_EXPORT;
+void monitorWheelEvents(WebCore::Frame&) TEST_SUPPORT_EXPORT;
+void setTestCallbackAndStartNotificationTimer(WebCore::Frame&, JSContextRef, JSObjectRef) TEST_SUPPORT_EXPORT;
+void clearWheelEventTestTrigger(WebCore::Frame&) TEST_SUPPORT_EXPORT;
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/testing/js/WebCoreTestSupportPrefix.cpp b/Source/WebCore/testing/js/WebCoreTestSupportPrefix.cpp
new file mode 100644
index 000000000..30eaa33c4
--- /dev/null
+++ b/Source/WebCore/testing/js/WebCoreTestSupportPrefix.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "WebCoreTestSupportPrefix.h"
diff --git a/Source/WebCore/testing/js/WebCoreTestSupportPrefix.h b/Source/WebCore/testing/js/WebCoreTestSupportPrefix.h
new file mode 100644
index 000000000..db378e485
--- /dev/null
+++ b/Source/WebCore/testing/js/WebCoreTestSupportPrefix.h
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2015 Apple Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+/* This prefix file should contain only:
+ * 1) files to precompile for faster builds
+ * 2) in one case at least: OS-X-specific performance bug workarounds
+ * 3) the special trick to catch us using new or delete without including "config.h"
+ * The project should be able to build without this header, although we rarely test that.
+ */
+
+/* Things that need to be defined globally should go into "config.h". */
+
+#include <wtf/Platform.h>
+
+#if defined(__APPLE__)
+#ifdef __cplusplus
+#define NULL __null
+#else
+#define NULL ((void *)0)
+#endif
+#endif
+
+#if OS(WINDOWS)
+
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x601
+#endif
+
+#ifndef WINVER
+#define WINVER 0x0601
+#endif
+
+#if !USE(CURL)
+#ifndef _WINSOCKAPI_
+#define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h
+#endif
+#endif
+
+#undef WEBCORE_EXPORT
+#define WEBCORE_EXPORT WTF_IMPORT_DECLARATION
+#define WEBCORE_TESTSUPPORT_EXPORT WTF_EXPORT_DECLARATION
+
+#else
+
+#include <pthread.h>
+
+#define WEBCORE_TESTSUPPORT_EXPORT WEBCORE_EXPORT
+
+#endif // OS(WINDOWS)
+
+#include <fcntl.h>
+#include <sys/types.h>
+#if defined(__APPLE__)
+#include <regex.h>
+#endif
+
+#include <setjmp.h>
+
+#include <signal.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#if defined(__APPLE__)
+#include <unistd.h>
+#endif
+
+#ifdef __cplusplus
+#include <algorithm>
+#include <cstddef>
+#include <new>
+#endif
+
+#if defined(__APPLE__)
+#include <sys/param.h>
+#endif
+#include <sys/stat.h>
+#if defined(__APPLE__)
+#include <sys/resource.h>
+#include <sys/time.h>
+#endif
+
+#include <CoreFoundation/CoreFoundation.h>
+#if PLATFORM(WIN_CAIRO)
+#include <ConditionalMacros.h>
+#include <windows.h>
+#else
+
+#if OS(WINDOWS)
+#if USE(CG)
+
+// FIXME <rdar://problem/8208868> Remove support for obsolete ColorSync API, CoreServices header in CoreGraphics
+// We can remove this once the new ColorSync APIs are available in an internal Safari SDK.
+#include <ColorSync/ColorSync.h>
+#ifdef __COLORSYNCDEPRECATED__
+#define COREGRAPHICS_INCLUDES_CORESERVICES_HEADER
+#define OBSOLETE_COLORSYNC_API
+#endif
+#endif
+#if USE(CFNETWORK)
+/* Windows doesn't include CFNetwork.h via CoreServices.h, so we do
+ it explicitly here to make Windows more consistent with Mac. */
+#include <CFNetwork/CFNetwork.h>
+// On Windows, dispatch.h needs to be included before certain CFNetwork headers.
+#include <dispatch/dispatch.h>
+#endif
+#include <windows.h>
+#else
+#if !PLATFORM(IOS)
+#include <CoreServices/CoreServices.h>
+#endif // !PLATFORM(IOS)
+#endif // OS(WINDOWS)
+
+#endif
+
+#ifdef __OBJC__
+#if PLATFORM(IOS)
+#import <Foundation/Foundation.h>
+#else
+#import <Cocoa/Cocoa.h>
+#endif // PLATFORM(IOS)
+#endif
+
+#ifdef __cplusplus
+#define new ("if you use new/delete make sure to include config.h at the top of the file"())
+#define delete ("if you use new/delete make sure to include config.h at the top of the file"())
+#endif
+
+/* When C++ exceptions are disabled, the C++ library defines |try| and |catch|
+ * to allow C++ code that expects exceptions to build. These definitions
+ * interfere with Objective-C++ uses of Objective-C exception handlers, which
+ * use |@try| and |@catch|. As a workaround, undefine these macros. */
+#ifdef __OBJC__
+#undef try
+#undef catch
+#endif
+