Add a test harness for the Windows WebKit API, and a few tests
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Jan 2010 21:19:41 +0000 (21:19 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Jan 2010 21:19:41 +0000 (21:19 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@52753 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
WebKit/win/ChangeLog
WebKit/win/WebKit.vcproj/WebKit.sln
WebKitTools/ChangeLog
WebKitTools/WebKitAPITest/HostWindow.cpp [new file with mode: 0644]
WebKitTools/WebKitAPITest/HostWindow.h [new file with mode: 0644]
WebKitTools/WebKitAPITest/Test.h [new file with mode: 0644]
WebKitTools/WebKitAPITest/TestsController.cpp [new file with mode: 0644]
WebKitTools/WebKitAPITest/TestsController.h [new file with mode: 0644]
WebKitTools/WebKitAPITest/WebKitAPITest.vcproj [new file with mode: 0644]
WebKitTools/WebKitAPITest/WebKitAPITestCommon.vsprops [new file with mode: 0644]
WebKitTools/WebKitAPITest/main.cpp [new file with mode: 0644]
WebKitTools/WebKitAPITest/tests/WebViewDestruction.cpp [new file with mode: 0644]

index 784208d..969671f 100644 (file)
@@ -1,3 +1,14 @@
+2010-01-04  Adam Roben  <aroben@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@apple.com>
 
         Reviewed by Ada Chan and Mark Rowe.
index ae9322b..9287197 100644 (file)
@@ -80,6 +80,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testapi", "..\..\..\JavaScr
 EndProject\r
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "record-memory-win", "..\..\..\WebKitTools\record-memory-win\record-memory-win.vcproj", "{44B9C152-1870-4035-B94D-7B3285AA0C12}"\r
 EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebKitAPITest", "..\..\..\WebKitTools\WebKitAPITest\WebKitAPITest.vcproj", "{626089A3-25D3-4883-A96C-B8C66E036397}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {6567DFD4-D6DE-4CD5-825D-17E353D160E1} = {6567DFD4-D6DE-4CD5-825D-17E353D160E1}\r
+       EndProjectSection\r
+EndProject\r
 Global\r
        GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
                Debug_Cairo|Win32 = Debug_Cairo|Win32\r
@@ -222,6 +227,14 @@ Global
                {44B9C152-1870-4035-B94D-7B3285AA0C12}.Release_Cairo|Win32.Build.0 = Release|Win32\r
                {44B9C152-1870-4035-B94D-7B3285AA0C12}.Release|Win32.ActiveCfg = Release|Win32\r
                {44B9C152-1870-4035-B94D-7B3285AA0C12}.Release|Win32.Build.0 = Release|Win32\r
+               {626089A3-25D3-4883-A96C-B8C66E036397}.Debug_Cairo|Win32.ActiveCfg = Debug_Internal|Win32\r
+               {626089A3-25D3-4883-A96C-B8C66E036397}.Debug_Cairo|Win32.Build.0 = Debug_Internal|Win32\r
+               {626089A3-25D3-4883-A96C-B8C66E036397}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {626089A3-25D3-4883-A96C-B8C66E036397}.Debug|Win32.Build.0 = Debug|Win32\r
+               {626089A3-25D3-4883-A96C-B8C66E036397}.Release_Cairo|Win32.ActiveCfg = Debug|Win32\r
+               {626089A3-25D3-4883-A96C-B8C66E036397}.Release_Cairo|Win32.Build.0 = Debug|Win32\r
+               {626089A3-25D3-4883-A96C-B8C66E036397}.Release|Win32.ActiveCfg = Debug|Win32\r
+               {626089A3-25D3-4883-A96C-B8C66E036397}.Release|Win32.Build.0 = Debug|Win32\r
        EndGlobalSection\r
        GlobalSection(SolutionProperties) = preSolution\r
                HideSolutionNode = FALSE\r
index ab01ae9..05173be 100644 (file)
@@ -1,3 +1,81 @@
+2010-01-04  Adam Roben  <aroben@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@nokia.com>
 
         Reviewed by David Kilzer.
diff --git a/WebKitTools/WebKitAPITest/HostWindow.cpp b/WebKitTools/WebKitAPITest/HostWindow.cpp
new file mode 100644 (file)
index 0000000..da7d428
--- /dev/null
@@ -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 (file)
index 0000000..a2734ed
--- /dev/null
@@ -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 (file)
index 0000000..33b07c9
--- /dev/null
@@ -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 (file)
index 0000000..52ceabf
--- /dev/null
@@ -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 (file)
index 0000000..11b457d
--- /dev/null
@@ -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 (file)
index 0000000..5473f10
--- /dev/null
@@ -0,0 +1,235 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="WebKitAPITest"\r
+       ProjectGUID="{626089A3-25D3-4883-A96C-B8C66E036397}"\r
+       RootNamespace="WebKitAPITest"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug_All|Win32"\r
+                       ConfigurationType="1"\r
+                       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"\r
+                       CharacterSet="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug_Internal|Win32"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops;.\WebKitAPITestCommon.vsprops"\r
+                       CharacterSet="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;.\WebKitAPITestCommon.vsprops"\r
+                       CharacterSet="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath=".\HostWindow.cpp"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath=".\HostWindow.h"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath=".\main.cpp"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath=".\Test.h"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath=".\TestsController.cpp"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath=".\TestsController.h"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath=".\tests\WebViewDestruction.cpp"\r
+                       >\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/WebKitTools/WebKitAPITest/WebKitAPITestCommon.vsprops b/WebKitTools/WebKitAPITest/WebKitAPITestCommon.vsprops
new file mode 100644 (file)
index 0000000..bac1f6a
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioPropertySheet\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="WebKitAPITestCommon"\r
+       >\r
+       <Tool\r
+               Name="VCCLCompilerTool"\r
+               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;"\r
+               PreprocessorDefinitions="_CONSOLE;NOMINMAX"\r
+       />\r
+       <Tool\r
+               Name="VCLinkerTool"\r
+               AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib"\r
+               SubSystem="1"\r
+       />\r
+       <Tool\r
+               Name="VCPostBuildEventTool"\r
+               CommandLine="if exist &quot;$(WebKitOutputDir)\buildfailed&quot; del &quot;$(WebKitOutputDir)\buildfailed&quot;"\r
+       />\r
+       <Tool\r
+               Name="VCPreBuildEventTool"\r
+               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;"\r
+       />\r
+</VisualStudioPropertySheet>\r
diff --git a/WebKitTools/WebKitAPITest/main.cpp b/WebKitTools/WebKitAPITest/main.cpp
new file mode 100644 (file)
index 0000000..a941c30
--- /dev/null
@@ -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 (file)
index 0000000..e103a8b
--- /dev/null
@@ -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