[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

aroben at apple.com aroben at apple.com
Thu Apr 8 00:53:45 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit cfd42782e98cdfda9777dcadb55e34bce1bb0126
Author: aroben at apple.com <aroben at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jan 4 21:19:41 2010 +0000

    Add a test harness for the Windows WebKit API, and a few tests
    
    We currently only have tests for a handful of bugs regarding WebView
    destruction, but more tests can easily be added later. Eventually
    we'll run these tests as part of run-webkit-tests.
    
    Fixes <http://webkit.org/b/33167>.
    
    Reviewed by Sam Weinig.
    
    WebKit/win:
    
    * WebKit.vcproj/WebKit.sln: Added WebKitAPITest.vcproj. It builds just
    after DumpRenderTree.vcproj.
    
    WebKitTools:
    
    * WebKitAPITest/HostWindow.cpp: Added.
    (WebKitAPITest::HostWindow::HostWindow): Initialize m_window.
    (WebKitAPITest::HostWindow::~HostWindow): Destroy our window if
    needed.
    (WebKitAPITest::HostWindow::initialize): Create our window.
    (WebKitAPITest::HostWindow::clientRect): Return our window's client
    rect.
    (WebKitAPITest::HostWindow::registerWindowClass): Does what it says.
    (WebKitAPITest::HostWindow::wndProc): Just call through to
    DefWindowProcW.
    
    * WebKitAPITest/HostWindow.h: Added.
    (WebKitAPITest::HostWindow::window): Simple getter.
    
    * WebKitAPITest/Test.h: Added. This file defines some macros useful
    for writing tests.
    
    * WebKitAPITest/TestsController.cpp: Added.
    (WebKitAPITest::TestsController::TestsController): Initialize our
    members.
    (WebKitAPITest::TestsController::shared): Return the shared instance.
    (WebKitAPITest::TestsController::runAllTests): Run a message pump
    until a WM_QUIT message is received, then return whether all tests
    succeeded.
    (WebKitAPITest::TestsController::addTest): Add the test to m_tests and
    start running tests soon.
    (WebKitAPITest::TestsController::testFailed): Record the failure and
    print a message about it to stdout.
    (WebKitAPITest::TestsController::runNextTest): If we don't have any
    tests to run, post a WM_QUIT message to stop the message pump.
    Otherwise, run the test and print whether it passed, then schedule the
    next test.
    (WebKitAPITest::TestsController::runNextTestSoon): Set a 0-delay timer
    to run the next test.
    (WebKitAPITest::TestsController::registerWindowClass): Does what it
    says.
    (WebKitAPITest::TestsController::wndProc): If the runNextTestTimer
    fired, call runNextTest(). Pass everything else through to
    DefWindowProcW.
    
    * WebKitAPITest/TestsController.h: Added.
    
    * WebKitAPITest/WebKitAPITest.vcproj: Added.
    
    * WebKitAPITest/WebKitAPITestCommon.vsprops: Added.
    
    * WebKitAPITest/main.cpp: Added.
    (main): (Mostly) just calls TestsController::runAllTests.
    
    * WebKitAPITest/tests/WebViewDestruction.cpp: Added.
    (WebKitAPITest::WebKitCreateInstance): Helper function template to
    call through to the real WebKitCreateInstance.
    (WebKitAPITest::webViewCount): Helper function to call through to
    IWebKitStatistics::webViewCount.
    (WebKitAPITest::createWebView): Helper function to create a WebView
    and put it inside a HostWindow.
    (WebKitAPITest::runMessagePump): Helper function to run a message pump
    for a specified number of milliseconds, or until a WM_QUIT message is
    received.
    (WebKitAPITest::CloseWithoutDestroyWindow): Test for
    <http://webkit.org/b/32827>.
    (WebKitAPITest::MainFrameAfterClose): Test for
    <http://webkit.org/b/32868>.
    (WebKitAPITest::NoCloseOrDestroyWindow): Test for
    <http://webkit.org/b/33162>.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52753 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index 784208d..969671f 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,14 @@
+2010-01-04  Adam Roben  <aroben at apple.com>
+
+        Add WebKitAPITest
+
+        Fixes <http://webkit.org/b/33167>.
+
+        Reviewed by Sam Weinig.
+
+        * WebKit.vcproj/WebKit.sln: Added WebKitAPITest.vcproj. It builds just
+        after DumpRenderTree.vcproj.
+
 2010-01-04  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Ada Chan and Mark Rowe.
diff --git a/WebKit/win/WebKit.vcproj/WebKit.sln b/WebKit/win/WebKit.vcproj/WebKit.sln
index ae9322b..9287197 100644
--- a/WebKit/win/WebKit.vcproj/WebKit.sln
+++ b/WebKit/win/WebKit.vcproj/WebKit.sln
@@ -80,6 +80,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testapi", "..\..\..\JavaScr
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "record-memory-win", "..\..\..\WebKitTools\record-memory-win\record-memory-win.vcproj", "{44B9C152-1870-4035-B94D-7B3285AA0C12}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebKitAPITest", "..\..\..\WebKitTools\WebKitAPITest\WebKitAPITest.vcproj", "{626089A3-25D3-4883-A96C-B8C66E036397}"
+	ProjectSection(ProjectDependencies) = postProject
+		{6567DFD4-D6DE-4CD5-825D-17E353D160E1} = {6567DFD4-D6DE-4CD5-825D-17E353D160E1}
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug_Cairo|Win32 = Debug_Cairo|Win32
@@ -222,6 +227,14 @@ Global
 		{44B9C152-1870-4035-B94D-7B3285AA0C12}.Release_Cairo|Win32.Build.0 = Release|Win32
 		{44B9C152-1870-4035-B94D-7B3285AA0C12}.Release|Win32.ActiveCfg = Release|Win32
 		{44B9C152-1870-4035-B94D-7B3285AA0C12}.Release|Win32.Build.0 = Release|Win32
+		{626089A3-25D3-4883-A96C-B8C66E036397}.Debug_Cairo|Win32.ActiveCfg = Debug_Internal|Win32
+		{626089A3-25D3-4883-A96C-B8C66E036397}.Debug_Cairo|Win32.Build.0 = Debug_Internal|Win32
+		{626089A3-25D3-4883-A96C-B8C66E036397}.Debug|Win32.ActiveCfg = Debug|Win32
+		{626089A3-25D3-4883-A96C-B8C66E036397}.Debug|Win32.Build.0 = Debug|Win32
+		{626089A3-25D3-4883-A96C-B8C66E036397}.Release_Cairo|Win32.ActiveCfg = Debug|Win32
+		{626089A3-25D3-4883-A96C-B8C66E036397}.Release_Cairo|Win32.Build.0 = Debug|Win32
+		{626089A3-25D3-4883-A96C-B8C66E036397}.Release|Win32.ActiveCfg = Debug|Win32
+		{626089A3-25D3-4883-A96C-B8C66E036397}.Release|Win32.Build.0 = Debug|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index ab01ae9..05173be 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,81 @@
+2010-01-04  Adam Roben  <aroben at apple.com>
+
+        Add a test harness for the Windows WebKit API, and a few tests
+
+        We currently only have tests for a handful of bugs regarding WebView
+        destruction, but more tests can easily be added later. Eventually
+        we'll run these tests as part of run-webkit-tests.
+
+        Fixes <http://webkit.org/b/33167>.
+
+        Reviewed by Sam Weinig.
+
+        * WebKitAPITest/HostWindow.cpp: Added.
+        (WebKitAPITest::HostWindow::HostWindow): Initialize m_window.
+        (WebKitAPITest::HostWindow::~HostWindow): Destroy our window if
+        needed.
+        (WebKitAPITest::HostWindow::initialize): Create our window.
+        (WebKitAPITest::HostWindow::clientRect): Return our window's client
+        rect.
+        (WebKitAPITest::HostWindow::registerWindowClass): Does what it says.
+        (WebKitAPITest::HostWindow::wndProc): Just call through to
+        DefWindowProcW.
+
+        * WebKitAPITest/HostWindow.h: Added.
+        (WebKitAPITest::HostWindow::window): Simple getter.
+
+        * WebKitAPITest/Test.h: Added. This file defines some macros useful
+        for writing tests.
+
+        * WebKitAPITest/TestsController.cpp: Added.
+        (WebKitAPITest::TestsController::TestsController): Initialize our
+        members.
+        (WebKitAPITest::TestsController::shared): Return the shared instance.
+        (WebKitAPITest::TestsController::runAllTests): Run a message pump
+        until a WM_QUIT message is received, then return whether all tests
+        succeeded.
+        (WebKitAPITest::TestsController::addTest): Add the test to m_tests and
+        start running tests soon.
+        (WebKitAPITest::TestsController::testFailed): Record the failure and
+        print a message about it to stdout.
+        (WebKitAPITest::TestsController::runNextTest): If we don't have any
+        tests to run, post a WM_QUIT message to stop the message pump.
+        Otherwise, run the test and print whether it passed, then schedule the
+        next test.
+        (WebKitAPITest::TestsController::runNextTestSoon): Set a 0-delay timer
+        to run the next test.
+        (WebKitAPITest::TestsController::registerWindowClass): Does what it
+        says.
+        (WebKitAPITest::TestsController::wndProc): If the runNextTestTimer
+        fired, call runNextTest(). Pass everything else through to
+        DefWindowProcW.
+
+        * WebKitAPITest/TestsController.h: Added.
+
+        * WebKitAPITest/WebKitAPITest.vcproj: Added.
+
+        * WebKitAPITest/WebKitAPITestCommon.vsprops: Added.
+
+        * WebKitAPITest/main.cpp: Added.
+        (main): (Mostly) just calls TestsController::runAllTests.
+
+        * WebKitAPITest/tests/WebViewDestruction.cpp: Added.
+        (WebKitAPITest::WebKitCreateInstance): Helper function template to
+        call through to the real WebKitCreateInstance.
+        (WebKitAPITest::webViewCount): Helper function to call through to
+        IWebKitStatistics::webViewCount.
+        (WebKitAPITest::createWebView): Helper function to create a WebView
+        and put it inside a HostWindow.
+        (WebKitAPITest::runMessagePump): Helper function to run a message pump
+        for a specified number of milliseconds, or until a WM_QUIT message is
+        received.
+        (WebKitAPITest::CloseWithoutDestroyWindow): Test for
+        <http://webkit.org/b/32827>.
+        (WebKitAPITest::MainFrameAfterClose): Test for
+        <http://webkit.org/b/32868>.
+        (WebKitAPITest::NoCloseOrDestroyWindow): Test for
+        <http://webkit.org/b/33162>.
+
 2010-01-04  Tor Arne Vestbø  <tor.arne.vestbo at nokia.com>
 
         Reviewed by David Kilzer.
diff --git a/WebKitTools/WebKitAPITest/HostWindow.cpp b/WebKitTools/WebKitAPITest/HostWindow.cpp
new file mode 100644
index 0000000..da7d428
--- /dev/null
+++ b/WebKitTools/WebKitAPITest/HostWindow.cpp
@@ -0,0 +1,83 @@
+/*
+ * 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 "HostWindow.h"
+
+namespace WebKitAPITest {
+
+static LPCWSTR hostWindowClassName = L"HostWindow";
+
+HostWindow::HostWindow()
+    : m_window(0)
+{
+}
+
+bool HostWindow::initialize()
+{
+    registerWindowClass();
+    m_window = CreateWindowExW(0, hostWindowClassName, L"WebKitAPITest", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, GetModuleHandle(0), 0);
+    return m_window;
+}
+
+HostWindow::~HostWindow()
+{
+    if (!IsWindow(m_window))
+        return;
+    DestroyWindow(m_window);
+}
+
+RECT HostWindow::clientRect() const
+{
+    RECT rect = {0};
+    if (!GetClientRect(m_window, &rect)) {
+        RECT emptyRect = {0};
+        return emptyRect;
+    }
+    return rect;
+}
+
+void HostWindow::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.hInstance = GetModuleHandle(0);
+    wndClass.lpszClassName = hostWindowClassName;
+
+    RegisterClassExW(&wndClass);
+}
+
+LRESULT HostWindow::wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    return DefWindowProcW(hWnd, uMsg, wParam, lParam);
+}
+
+} // namespace WebKitAPITest
diff --git a/WebKitTools/WebKitAPITest/HostWindow.h b/WebKitTools/WebKitAPITest/HostWindow.h
new file mode 100644
index 0000000..a2734ed
--- /dev/null
+++ b/WebKitTools/WebKitAPITest/HostWindow.h
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+#ifndef HostWindow_h
+#define HostWindow_h
+
+#include <windows.h>
+#include <wtf/Noncopyable.h>
+
+namespace WebKitAPITest {
+
+class HostWindow : public Noncopyable {
+public:
+    HostWindow();
+    ~HostWindow();
+    bool initialize();
+
+    RECT clientRect() const;
+    HWND window() const { return m_window; }
+
+private:
+    static void registerWindowClass();
+    static LRESULT CALLBACK wndProc(HWND, UINT uMsg, WPARAM, LPARAM);
+
+    HWND m_window;
+};
+
+} // namespace WebKitAPITest
+
+#endif // HostWindow_h
diff --git a/WebKitTools/WebKitAPITest/Test.h b/WebKitTools/WebKitAPITest/Test.h
new file mode 100644
index 0000000..33b07c9
--- /dev/null
+++ b/WebKitTools/WebKitAPITest/Test.h
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+#ifndef Test_h
+#define Test_h
+
+#include "TestsController.h"
+
+namespace WebKitAPITest {
+
+// Abstract base class that all tests inherit from.
+class Test {
+public:
+    ~Test() { }
+    virtual const char* name() const = 0;
+    virtual void run() = 0;
+};
+
+#define TEST_CLASS_NAME(testCaseName, testName) testCaseName##_##testName##_Test
+
+// Use this to define a new test.
+#define TEST(testCaseName, testName) \
+    class TEST_CLASS_NAME(testCaseName, testName) : public Test { \
+    public: \
+        virtual const char* name() const { return #testCaseName ": " #testName; } \
+        virtual void run(); \
+        static const bool initialized; \
+    }; \
+    \
+    const bool TEST_CLASS_NAME(testCaseName, testName)::initialized = (TestsController::shared().addTest(new TEST_CLASS_NAME(testCaseName, testName)), true); \
+    \
+    void TEST_CLASS_NAME(testCaseName, testName)::run()
+
+#define TEST_ASSERT(expression) do { if (!(expression)) { TestsController::shared().testFailed(__FILE__, __LINE__, #expression); return; } } while (0)
+
+} // namespace WebKitAPITest
+
+#endif // Test_h
diff --git a/WebKitTools/WebKitAPITest/TestsController.cpp b/WebKitTools/WebKitAPITest/TestsController.cpp
new file mode 100644
index 0000000..52ceabf
--- /dev/null
+++ b/WebKitTools/WebKitAPITest/TestsController.cpp
@@ -0,0 +1,147 @@
+/*
+ * 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 "TestsController.h"
+
+#include "Test.h"
+#include <wtf/PassOwnPtr.h>
+
+using namespace std;
+
+namespace WebKitAPITest {
+
+static const LPCWSTR testsControllerWindowClassName = L"TestsControllerWindowClass";
+
+enum { runNextTestTimerID = 1 };
+
+inline TestsController::TestsController()
+    : m_testFailed(false)
+    , m_anyTestFailed(false)
+{
+    registerWindowClass();
+    m_window = CreateWindowExW(0, testsControllerWindowClassName, 0, WS_CHILD, 0, 0, 0, 0, HWND_MESSAGE, 0, GetModuleHandle(0), 0);
+}
+
+TestsController& TestsController::shared()
+{
+    static TestsController& shared = *new TestsController;
+    return shared;
+}
+
+bool TestsController::runAllTests()
+{
+    if (m_tests.isEmpty())
+        return true;
+
+    MSG msg;
+    BOOL result;
+    while ((result = GetMessage(&msg, 0, 0, 0))) {
+        if (result == -1)
+            break;
+        TranslateMessage(&msg);
+        DispatchMessage(&msg);
+    }
+
+    if (msg.message != WM_QUIT)
+        return false;
+
+    return !m_anyTestFailed;
+}
+
+void TestsController::addTest(PassOwnPtr<Test> test)
+{
+    m_tests.append(test.release());
+    runNextTestSoon();
+}
+
+void TestsController::testFailed(const char* file, int line, const char* message)
+{
+    ASSERT(!m_tests.isEmpty());
+
+    m_testFailed = true;
+    m_anyTestFailed = true;
+
+    printf("FAIL: %s\n\t%s (%s:%d)\n", m_tests.first()->name(), message, file, line);
+    fflush(stdout);
+}
+
+void TestsController::runNextTest()
+{
+    if (m_tests.isEmpty()) {
+        PostQuitMessage(0);
+        return;
+    }
+
+    Test* test = m_tests.first();
+
+    m_testFailed = false;
+    printf("RUN: %s\n", test->name());
+    fflush(stdout);
+    test->run();
+
+    if (!m_testFailed) {
+        printf("PASS: %s\n", test->name());
+        fflush(stdout);
+    }
+
+    m_tests.removeFirst();
+    delete test;
+
+    runNextTestSoon();
+}
+
+void TestsController::runNextTestSoon()
+{
+    SetTimer(m_window, runNextTestTimerID, 0, 0);
+}
+
+void TestsController::registerWindowClass()
+{
+    static bool initialized;
+    if (initialized)
+        return;
+    initialized = true;
+
+    WNDCLASSEXW wndClass = {0};
+    wndClass.cbSize = sizeof(wndClass);
+    wndClass.lpfnWndProc = wndProc;
+    wndClass.hCursor = LoadCursor(0, IDC_ARROW);
+    wndClass.hInstance = GetModuleHandle(0);
+    wndClass.lpszClassName = testsControllerWindowClassName;
+
+    RegisterClassExW(&wndClass);
+}
+
+LRESULT TestsController::wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    if (uMsg == WM_TIMER && wParam == runNextTestTimerID) {
+        KillTimer(hWnd, runNextTestTimerID);
+        TestsController::shared().runNextTest();
+        return 0;
+    }
+
+    return DefWindowProcW(hWnd, uMsg, wParam, lParam);
+}
+
+} // namespace WebKitAPITest
diff --git a/WebKitTools/WebKitAPITest/TestsController.h b/WebKitTools/WebKitAPITest/TestsController.h
new file mode 100644
index 0000000..11b457d
--- /dev/null
+++ b/WebKitTools/WebKitAPITest/TestsController.h
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#ifndef TestsController_h
+#define TestsController_h
+
+#include <windows.h>
+#include <wtf/Forward.h>
+#include <wtf/Deque.h>
+#include <wtf/Noncopyable.h>
+
+namespace WebKitAPITest {
+
+class Test;
+
+class TestsController : public Noncopyable {
+public:
+    static TestsController& shared();
+
+    // Returns true if all the tests passed, false otherwise.
+    bool runAllTests();
+
+    void addTest(PassOwnPtr<Test>);
+    void testFailed(const char* file, int line, const char* message);
+
+private:
+    TestsController();
+    ~TestsController();
+
+    void runNextTest();
+    void runNextTestSoon();
+
+    static void registerWindowClass();
+    static LRESULT CALLBACK wndProc(HWND, UINT uMsg, WPARAM, LPARAM);
+
+    HWND m_window;
+    Deque<Test*> m_tests;
+    bool m_testFailed;
+    bool m_anyTestFailed;
+};
+
+} // namespace WebKitAPITest
+
+#endif // TestsController_h
diff --git a/WebKitTools/WebKitAPITest/WebKitAPITest.vcproj b/WebKitTools/WebKitAPITest/WebKitAPITest.vcproj
new file mode 100644
index 0000000..5473f10
--- /dev/null
+++ b/WebKitTools/WebKitAPITest/WebKitAPITest.vcproj
@@ -0,0 +1,235 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="WebKitAPITest"
+	ProjectGUID="{626089A3-25D3-4883-A96C-B8C66E036397}"
+	RootNamespace="WebKitAPITest"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug_All|Win32"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_all.vsprops;.\WebKitAPITestCommon.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug_Internal|Win32"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops;.\WebKitAPITestCommon.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;.\WebKitAPITestCommon.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\HostWindow.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\HostWindow.h"
+			>
+		</File>
+		<File
+			RelativePath=".\main.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\Test.h"
+			>
+		</File>
+		<File
+			RelativePath=".\TestsController.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\TestsController.h"
+			>
+		</File>
+		<File
+			RelativePath=".\tests\WebViewDestruction.cpp"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff --git a/WebKitTools/WebKitAPITest/WebKitAPITestCommon.vsprops b/WebKitTools/WebKitAPITest/WebKitAPITestCommon.vsprops
new file mode 100644
index 0000000..bac1f6a
--- /dev/null
+++ b/WebKitTools/WebKitAPITest/WebKitAPITestCommon.vsprops
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="WebKitAPITestCommon"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalIncludeDirectories="&quot;$(ProjectDir)&quot;;&quot;$(WebKitOutputDir)\include&quot;;&quot;$(WebKitOutputDir)\include\private&quot;;&quot;$(WebKitOutputDir)\include\WebCore\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;;&quot;$(WebKitLibrariesDir)\include\private&quot;;&quot;$(WebKitLibrariesDir)\include\WebCore\ForwardingHeaders&quot;"
+		PreprocessorDefinitions="_CONSOLE;NOMINMAX"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib"
+		SubSystem="1"
+	/>
+	<Tool
+		Name="VCPostBuildEventTool"
+		CommandLine="if exist &quot;$(WebKitOutputDir)\buildfailed&quot; del &quot;$(WebKitOutputDir)\buildfailed&quot;"
+	/>
+	<Tool
+		Name="VCPreBuildEventTool"
+		CommandLine="%SystemDrive%\cygwin\bin\which.exe bash&#x0D;&#x0A;if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%&#x0D;&#x0A;cmd /c&#x0D;&#x0A;if exist &quot;$(WebKitOutputDir)\buildfailed&quot; grep XX$(ProjectName)XX &quot;$(WebKitOutputDir)\buildfailed&quot;&#x0D;&#x0A;if errorlevel 1 exit 1&#x0D;&#x0A;echo XX$(ProjectName)XX &gt; &quot;$(WebKitOutputDir)\buildfailed&quot;&#x0D;&#x0A;"
+	/>
+</VisualStudioPropertySheet>
diff --git a/WebKitTools/WebKitAPITest/main.cpp b/WebKitTools/WebKitAPITest/main.cpp
new file mode 100644
index 0000000..a941c30
--- /dev/null
+++ b/WebKitTools/WebKitAPITest/main.cpp
@@ -0,0 +1,35 @@
+/*
+ * 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 "TestsController.h"
+
+using namespace WebKitAPITest;
+
+int main(int, char*[])
+{
+    // FIXME: Remove this line once <http://webkit.org/b/32867> is fixed.
+    OleInitialize(0);
+
+    return !TestsController::shared().runAllTests();
+}
diff --git a/WebKitTools/WebKitAPITest/tests/WebViewDestruction.cpp b/WebKitTools/WebKitAPITest/tests/WebViewDestruction.cpp
new file mode 100644
index 0000000..e103a8b
--- /dev/null
+++ b/WebKitTools/WebKitAPITest/tests/WebViewDestruction.cpp
@@ -0,0 +1,135 @@
+/*
+ * 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 "HostWindow.h"
+#include "Test.h"
+#include <WebCore/COMPtr.h>
+#include <WebKit/WebKit.h>
+#include <WebKit/WebKitCOMAPI.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKitAPITest {
+
+template <typename T>
+static HRESULT WebKitCreateInstance(REFCLSID clsid, T** object)
+{
+    return WebKitCreateInstance(clsid, 0, __uuidof(T), reinterpret_cast<void**>(&object));
+}
+
+static int webViewCount()
+{
+    COMPtr<IWebKitStatistics> statistics;
+    if (FAILED(WebKitCreateInstance(__uuidof(WebKitStatistics), &statistics)))
+        return -1;
+    int count;
+    if (FAILED(statistics->webViewCount(&count)))
+        return -1;
+    return count;
+}
+
+static COMPtr<IWebView> createWebView(const HostWindow& window)
+{
+    COMPtr<IWebView> webView;
+    if (FAILED(WebKitCreateInstance(__uuidof(WebView), &webView)))
+        return 0;
+
+    if (FAILED(webView->setHostWindow(reinterpret_cast<OLE_HANDLE>(window.window()))))
+        return 0;
+
+    if (FAILED(webView->initWithFrame(window.clientRect(), 0, 0)))
+        return 0;
+
+    return webView;
+}
+
+static void runMessagePump(DWORD timeoutMilliseconds)
+{
+    DWORD startTickCount = GetTickCount();
+    MSG msg;
+    BOOL result;
+    while ((result = GetMessage(&msg, 0, 0, 0)) && GetTickCount() - startTickCount <= timeoutMilliseconds) {
+        if (result == -1)
+            break;
+        TranslateMessage(&msg);
+        DispatchMessage(&msg);
+    }
+}
+
+// Tests that calling IWebView::close without calling DestroyWindow, then releasing a WebView doesn't crash. <http://webkit.org/b/32827>
+TEST(WebViewDestruction, CloseWithoutDestroyWindow)
+{
+    HostWindow window;
+    TEST_ASSERT(window.initialize());
+    COMPtr<IWebView> webView = createWebView(window);
+    TEST_ASSERT(webView);
+
+    TEST_ASSERT(SUCCEEDED(webView->close()));
+
+    // Allow window messages to be processed to trigger the crash.
+    runMessagePump(50);
+
+    // We haven't crashed. Release the WebView and ensure that its view window gets destroyed and the WebView doesn't leak.
+    COMPtr<IWebViewPrivate> viewPrivate(Query, webView);
+    TEST_ASSERT(viewPrivate);
+
+    HWND viewWindow;
+    TEST_ASSERT(SUCCEEDED(viewPrivate->viewWindow(reinterpret_cast<OLE_HANDLE*>(&viewWindow))));
+    TEST_ASSERT(viewWindow);
+
+    int currentWebViewCount = webViewCount();
+    TEST_ASSERT(currentWebViewCount > 0);
+
+    webView = 0;
+    viewPrivate = 0;
+
+    TEST_ASSERT(webViewCount() == currentWebViewCount - 1);
+    TEST_ASSERT(!IsWindow(viewWindow));
+}
+
+// Tests that calling IWebView::mainFrame after calling IWebView::close doesn't crash. <http://webkit.org/b/32868>
+TEST(WebViewDestruction, MainFrameAfterClose)
+{
+    HostWindow window;
+    TEST_ASSERT(window.initialize());
+    COMPtr<IWebView> webView = createWebView(window);
+    TEST_ASSERT(webView);
+
+    TEST_ASSERT(SUCCEEDED(webView->close()));
+    COMPtr<IWebFrame> mainFrame;
+    TEST_ASSERT(SUCCEEDED(webView->mainFrame(&mainFrame)));
+}
+
+// Tests that releasing a WebView without calling IWebView::close or DestroyWindow doesn't leak. <http://webkit.org/b/33162>
+TEST(WebViewDestruction, NoCloseOrDestroyWindow)
+{
+    HostWindow window;
+    TEST_ASSERT(window.initialize());
+    COMPtr<IWebView> webView = createWebView(window);
+    TEST_ASSERT(webView);
+
+    webView = 0;
+    TEST_ASSERT(!webViewCount());
+}
+
+} // namespace WebKitAPITest

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list