Title: [230744] trunk/Tools
Revision
230744
Author
[email protected]
Date
2018-04-17 18:01:09 -0700 (Tue, 17 Apr 2018)

Log Message

[WinCairo][TestWebKitAPI] Implement PlatformWebView for TestWebKit
https://bugs.webkit.org/show_bug.cgi?id=184524

Reviewed by Alex Christensen.

Resurrect PlatformWebView for Windows port which was removed in Bug 104607.

* TestWebKitAPI/PlatformWebView.h:
* TestWebKitAPI/PlatformWin.cmake:
* TestWebKitAPI/win/InjectedBundleControllerWin.cpp: Added.
(TestWebKitAPI::InjectedBundleController::platformInitialize):
* TestWebKitAPI/win/PlatformUtilitiesWin.cpp: Added.
(TestWebKitAPI::Util::moduleDirectory):
(TestWebKitAPI::Util::createInjectedBundlePath):
(TestWebKitAPI::Util::createURLForResource):
(TestWebKitAPI::Util::URLForNonExistentResource):
(TestWebKitAPI::Util::isKeyDown):
* TestWebKitAPI/win/PlatformWebViewWin.cpp: Added.
(TestWebKitAPI::PlatformWebView::registerWindowClass):
(TestWebKitAPI::PlatformWebView::PlatformWebView):
(TestWebKitAPI::PlatformWebView::initialize):
(TestWebKitAPI::PlatformWebView::~PlatformWebView):
(TestWebKitAPI::PlatformWebView::page const):
(TestWebKitAPI::PlatformWebView::resizeTo):
(TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress):
(TestWebKitAPI::PlatformWebView::simulateAltKeyPress):
(TestWebKitAPI::PlatformWebView::simulateRightClick):
(TestWebKitAPI::PlatformWebView::simulateMouseMove):
(TestWebKitAPI::PlatformWebView::wndProc):
* TestWebKitAPI/win/UtilitiesWin.cpp: Added.
(TestWebKitAPI::Util::run):
(TestWebKitAPI::Util::spinRunLoop):
(TestWebKitAPI::Util::sleep):

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (230743 => 230744)


--- trunk/Tools/ChangeLog	2018-04-18 00:46:06 UTC (rev 230743)
+++ trunk/Tools/ChangeLog	2018-04-18 01:01:09 UTC (rev 230744)
@@ -1,3 +1,39 @@
+2018-04-17  Fujii Hironori  <[email protected]>
+
+        [WinCairo][TestWebKitAPI] Implement PlatformWebView for TestWebKit
+        https://bugs.webkit.org/show_bug.cgi?id=184524
+
+        Reviewed by Alex Christensen.
+
+        Resurrect PlatformWebView for Windows port which was removed in Bug 104607.
+
+        * TestWebKitAPI/PlatformWebView.h:
+        * TestWebKitAPI/PlatformWin.cmake:
+        * TestWebKitAPI/win/InjectedBundleControllerWin.cpp: Added.
+        (TestWebKitAPI::InjectedBundleController::platformInitialize):
+        * TestWebKitAPI/win/PlatformUtilitiesWin.cpp: Added.
+        (TestWebKitAPI::Util::moduleDirectory):
+        (TestWebKitAPI::Util::createInjectedBundlePath):
+        (TestWebKitAPI::Util::createURLForResource):
+        (TestWebKitAPI::Util::URLForNonExistentResource):
+        (TestWebKitAPI::Util::isKeyDown):
+        * TestWebKitAPI/win/PlatformWebViewWin.cpp: Added.
+        (TestWebKitAPI::PlatformWebView::registerWindowClass):
+        (TestWebKitAPI::PlatformWebView::PlatformWebView):
+        (TestWebKitAPI::PlatformWebView::initialize):
+        (TestWebKitAPI::PlatformWebView::~PlatformWebView):
+        (TestWebKitAPI::PlatformWebView::page const):
+        (TestWebKitAPI::PlatformWebView::resizeTo):
+        (TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress):
+        (TestWebKitAPI::PlatformWebView::simulateAltKeyPress):
+        (TestWebKitAPI::PlatformWebView::simulateRightClick):
+        (TestWebKitAPI::PlatformWebView::simulateMouseMove):
+        (TestWebKitAPI::PlatformWebView::wndProc):
+        * TestWebKitAPI/win/UtilitiesWin.cpp: Added.
+        (TestWebKitAPI::Util::run):
+        (TestWebKitAPI::Util::spinRunLoop):
+        (TestWebKitAPI::Util::sleep):
+
 2018-04-17  Jonathan Bedard  <[email protected]>
 
         Fix hasher tests for system with 32 bit longs

Modified: trunk/Tools/TestWebKitAPI/PlatformWebView.h (230743 => 230744)


--- trunk/Tools/TestWebKitAPI/PlatformWebView.h	2018-04-18 00:46:06 UTC (rev 230743)
+++ trunk/Tools/TestWebKitAPI/PlatformWebView.h	2018-04-18 01:01:09 UTC (rev 230744)
@@ -52,6 +52,9 @@
 struct wpe_view_backend;
 typedef WKViewRef PlatformWKView;
 typedef HeadlessViewBackend *PlatformWindow;
+#elif PLATFORM(WIN)
+typedef WKViewRef PlatformWKView;
+typedef HWND PlatformWindow;
 #endif
 
 namespace TestWebKitAPI {
@@ -82,9 +85,13 @@
 private:
 #if PLATFORM(MAC)
     void initialize(WKPageConfigurationRef, Class wkViewSubclass);
-#elif PLATFORM(GTK) || PLATFORM(WPE)
+#elif PLATFORM(GTK) || PLATFORM(WPE) || PLATFORM(WIN)
     void initialize(WKPageConfigurationRef);
 #endif
+#if PLATFORM(WIN)
+    static void registerWindowClass();
+    static LRESULT CALLBACK wndProc(HWND, UINT message, WPARAM, LPARAM);
+#endif
 
     PlatformWKView m_view;
     PlatformWindow m_window;

Modified: trunk/Tools/TestWebKitAPI/PlatformWin.cmake (230743 => 230744)


--- trunk/Tools/TestWebKitAPI/PlatformWin.cmake	2018-04-18 00:46:06 UTC (rev 230743)
+++ trunk/Tools/TestWebKitAPI/PlatformWin.cmake	2018-04-18 01:01:09 UTC (rev 230744)
@@ -162,6 +162,38 @@
     add_dependencies(TestWebKitLegacy TestWebKitLegacyLib)
 endif ()
 
+if (ENABLE_WEBKIT)
+    set(bundle_harness_SOURCES
+        ${TESTWEBKITAPI_DIR}/win/UtilitiesWin.cpp
+        ${TESTWEBKITAPI_DIR}/win/InjectedBundleControllerWin.cpp
+        ${TESTWEBKITAPI_DIR}/win/PlatformUtilitiesWin.cpp
+    )
+
+    set(webkit_api_harness_SOURCES
+        ${TESTWEBKITAPI_DIR}/win/PlatformUtilitiesWin.cpp
+        ${TESTWEBKITAPI_DIR}/win/PlatformWebViewWin.cpp
+        ${TESTWEBKITAPI_DIR}/win/UtilitiesWin.cpp
+    )
+
+    add_library(TestWebKitLib SHARED
+        ${TESTWEBKITAPI_DIR}/win/main.cpp
+        ${test_webkit_api_SOURCES}
+    )
+
+    target_link_libraries(TestWebKitLib ${test_webkit_api_LIBRARIES})
+
+    add_executable(TestWebKit
+        ${TOOLS_DIR}/win/DLLLauncher/DLLLauncherMain.cpp
+    )
+    target_link_libraries(TestWebKit shlwapi)
+
+    add_test(TestWebKit ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebKit/TestWebKit)
+    set_tests_properties(TestWebKit PROPERTIES TIMEOUT 60)
+    set_target_properties(TestWebKit PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebKit)
+
+    add_dependencies(TestWebKit TestWebKitAPIBase)
+endif ()
+
 set(test_main_SOURCES
     ${TOOLS_DIR}/win/DLLLauncher/DLLLauncherMain.cpp
 )

Added: trunk/Tools/TestWebKitAPI/win/InjectedBundleControllerWin.cpp (0 => 230744)


--- trunk/Tools/TestWebKitAPI/win/InjectedBundleControllerWin.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/win/InjectedBundleControllerWin.cpp	2018-04-18 01:01:09 UTC (rev 230744)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2018 Sony Interactive Entertainment Inc.
+ *
+ * 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. 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 INC. 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 "InjectedBundleController.h"
+
+namespace TestWebKitAPI {
+
+void InjectedBundleController::platformInitialize()
+{
+}
+
+} // namespace TestWebKitAPI

Added: trunk/Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp (0 => 230744)


--- trunk/Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp	2018-04-18 01:01:09 UTC (rev 230744)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2018 Sony Interactive Entertainment Inc.
+ *
+ * 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. 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 INC. 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 "PlatformUtilities.h"
+
+#include <Shlwapi.h>
+#include <WebCore/FileSystem.h>
+#include <WebCore/URL.h>
+#include <wtf/text/win/WCharStringExtras.h>
+
+namespace TestWebKitAPI {
+namespace Util {
+
+static String moduleDirectory()
+{
+    constexpr size_t bufferLength = _MAX_PATH + 1;
+    wchar_t filename[bufferLength];
+    auto len = GetModuleFileName(nullptr, filename, bufferLength);
+    ASSERT(len > 0);
+    return WebCore::FileSystem::directoryName(wcharToString(filename, len));
+}
+
+WKStringRef createInjectedBundlePath()
+{
+    auto path = WebCore::FileSystem::pathByAppendingComponent(moduleDirectory(), String(L"TestWebKitAPIInjectedBundle.dll"));
+    return WKStringCreateWithUTF8CString(path.utf8().data());
+}
+
+WKURLRef createURLForResource(const char* resource, const char* extension)
+{
+    String filename = String::format("..\\..\\..\\Tools\\TestWebKitAPI\\Tests\\WebKit\\%s.%s", resource, extension);
+    auto url = "" filename));
+    return WKURLCreateWithUTF8CString(url.string().utf8().data());
+}
+
+WKURLRef URLForNonExistentResource()
+{
+    return WKURLCreateWithUTF8CString("file:///does-not-exist.html");
+}
+
+bool isKeyDown(WKNativeEventPtr event)
+{
+    // FIXME
+    return false;
+}
+
+} // namespace Util
+} // namespace TestWebKitAPI

Added: trunk/Tools/TestWebKitAPI/win/PlatformWebViewWin.cpp (0 => 230744)


--- trunk/Tools/TestWebKitAPI/win/PlatformWebViewWin.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/win/PlatformWebViewWin.cpp	2018-04-18 01:01:09 UTC (rev 230744)
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2010 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. 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 INC. 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 "PlatformWebView.h"
+
+#include <WebKit/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+static const wchar_t* hostWindowClassName = L"org.WebKit.TestWebKitAPI.PlatformWebViewHostWindow";
+static const wchar_t* webViewPointerProperty = L"org.WebKit.TestWebKitAPI.PlatformWebView.InstancePointer";
+
+// These offsets come from rom <http://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx>.
+static const size_t repeatCountBitOffset = 0;
+static const size_t scanCodeBitOffset = 16;
+static const size_t contextCodeBitOffset = 29;
+static const size_t previousStateBitOffset = 30;
+static const size_t transitionStateBitOffset = 31;
+
+void PlatformWebView::registerWindowClass()
+{
+    static bool initialized;
+    if (initialized)
+        return;
+    initialized = true;
+
+    WNDCLASSEXW wndClass = {0};
+    wndClass.cbSize = sizeof(wndClass);
+    wndClass.style = CS_HREDRAW | CS_VREDRAW;
+    wndClass.lpfnWndProc = wndProc;
+    wndClass.hCursor = LoadCursor(0, IDC_ARROW);
+    wndClass.lpszClassName = hostWindowClassName;
+
+    ::RegisterClassExW(&wndClass);
+}
+
+PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+{
+    WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
+    WKPageConfigurationSetContext(configuration.get(), contextRef);
+    WKPageConfigurationSetPageGroup(configuration.get(), pageGroupRef);
+
+    initialize(configuration.get());
+}
+
+PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration)
+{
+    initialize(configuration);
+}
+
+PlatformWebView::PlatformWebView(WKPageRef relatedPage)
+{
+    WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
+    WKPageConfigurationSetContext(configuration.get(), WKPageGetContext(relatedPage));
+    WKPageConfigurationSetPageGroup(configuration.get(), WKPageGetPageGroup(relatedPage));
+    WKPageConfigurationSetRelatedPage(configuration.get(), relatedPage);
+
+    initialize(configuration.get());
+}
+
+void PlatformWebView::initialize(WKPageConfigurationRef configuration)
+{
+    registerWindowClass();
+
+    RECT viewRect = {0, 0, 800, 600};
+    m_window = CreateWindowExW(0, hostWindowClassName, L"TestWebKitAPI", WS_OVERLAPPEDWINDOW, viewRect.left, viewRect.top, viewRect.right, viewRect.bottom, 0, 0, 0, this);
+    m_view = WKViewCreate(viewRect, configuration, m_window);
+}
+
+PlatformWebView::~PlatformWebView()
+{
+    ::DestroyWindow(m_window);
+}
+
+WKPageRef PlatformWebView::page() const
+{
+    return WKViewGetPage(m_view);
+}
+
+void PlatformWebView::resizeTo(unsigned width, unsigned height)
+{
+    ::SetWindowPos(WKViewGetWindow(m_view), 0, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS);
+}
+
+void PlatformWebView::simulateSpacebarKeyPress()
+{
+    HWND window = WKViewGetWindow(m_view);
+
+    // These values match what happens when you press the spacebar in Notepad, as observed by Spy++.
+    ::SendMessageW(window, WM_KEYDOWN, VK_SPACE, (1 << repeatCountBitOffset) | (39 << scanCodeBitOffset));
+    ::SendMessageW(window, WM_CHAR, ' ', (1 << repeatCountBitOffset) | (39 << scanCodeBitOffset));
+    ::SendMessageW(window, WM_KEYUP, VK_SPACE, (1 << repeatCountBitOffset) | (39 << scanCodeBitOffset) | (1 << previousStateBitOffset) | (1 << transitionStateBitOffset));
+}
+
+void PlatformWebView::simulateAltKeyPress()
+{
+    HWND window = WKViewGetWindow(m_view);
+
+    // These values match what happens when you press the Alt key in Notepad, as observed by Spy++.
+    ::SendMessageW(window, WM_SYSKEYDOWN, VK_MENU, (1 << repeatCountBitOffset) | (38 << scanCodeBitOffset) | (1 << contextCodeBitOffset));
+    ::SendMessageW(window, WM_SYSKEYUP, VK_MENU, (1 << repeatCountBitOffset) | (38 << scanCodeBitOffset) | (1 << previousStateBitOffset) | (1 << transitionStateBitOffset));
+}
+
+void PlatformWebView::simulateRightClick(unsigned x, unsigned y)
+{
+    HWND window = WKViewGetWindow(m_view);
+
+    ::SendMessageW(window, WM_RBUTTONDOWN, 0, MAKELPARAM(x, y));
+    ::SendMessageW(window, WM_RBUTTONUP, 0, MAKELPARAM(x, y));
+}
+
+void PlatformWebView::simulateMouseMove(unsigned x, unsigned y, WKEventModifiers)
+{
+    HWND window = WKViewGetWindow(m_view);
+
+    ::SendMessageW(window, WM_MOUSEMOVE, 0, MAKELPARAM(x, y));
+}
+
+LRESULT PlatformWebView::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    PlatformWebView* webView;
+    if (message == WM_CREATE) {
+        CREATESTRUCT* createStruct = reinterpret_cast<CREATESTRUCT*>(lParam);
+        webView = static_cast<PlatformWebView*>(createStruct->lpCreateParams);
+        ::SetPropW(hWnd, webViewPointerProperty, webView);
+    } else
+        webView = reinterpret_cast<PlatformWebView*>(::GetPropW(hWnd, webViewPointerProperty));
+
+    if (message == WM_NCDESTROY)
+        ::RemovePropW(hWnd, webViewPointerProperty);
+
+    return ::DefWindowProcW(hWnd, message, wParam, lParam);
+}
+
+} // namespace TestWebKitAPI

Added: trunk/Tools/TestWebKitAPI/win/UtilitiesWin.cpp (0 => 230744)


--- trunk/Tools/TestWebKitAPI/win/UtilitiesWin.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/win/UtilitiesWin.cpp	2018-04-18 01:01:09 UTC (rev 230744)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2018 Sony Interactive Entertainment Inc.
+ *
+ * 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. 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 INC. 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 "Utilities.h"
+
+#include <wtf/RunLoop.h>
+
+namespace TestWebKitAPI {
+namespace Util {
+
+void run(bool* done)
+{
+    while (!*done) {
+        MSG message;
+        BOOL result = GetMessage(&message, 0, 0, 0);
+        if (!result)
+            break;
+        TranslateMessage(&message);
+        DispatchMessage(&message);
+    }
+}
+
+void spinRunLoop(uint64_t count)
+{
+    for (uint64_t i = 0; i < count; i++) {
+        MSG message;
+        BOOL result = GetMessage(&message, 0, 0, 0);
+        if (!result)
+            break;
+        TranslateMessage(&message);
+        DispatchMessage(&message);
+    }
+}
+
+void sleep(double seconds)
+{
+    WTF::sleep(Seconds(seconds));
+}
+
+} // namespace Util
+} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to