summaryrefslogtreecommitdiffstats
path: root/Tools/WebKitAPITest
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-05 14:36:32 +0100
committerBen Murdoch <benm@google.com>2011-05-10 15:38:30 +0100
commitf05b935882198ccf7d81675736e3aeb089c5113a (patch)
tree4ea0ca838d9ef1b15cf17ddb3928efb427c7e5a1 /Tools/WebKitAPITest
parent60fbdcc62bced8db2cb1fd233cc4d1e4ea17db1b (diff)
downloadexternal_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.zip
external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.gz
external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.bz2
Merge WebKit at r74534: Initial merge by git.
Change-Id: I6ccd1154fa1b19c2ec2a66878eb675738735f1eb
Diffstat (limited to 'Tools/WebKitAPITest')
-rw-r--r--Tools/WebKitAPITest/HostWindow.cpp83
-rw-r--r--Tools/WebKitAPITest/HostWindow.h51
-rw-r--r--Tools/WebKitAPITest/Test.h59
-rw-r--r--Tools/WebKitAPITest/TestsController.cpp147
-rw-r--r--Tools/WebKitAPITest/TestsController.h65
-rw-r--r--Tools/WebKitAPITest/WebKitAPITest.vcproj418
-rw-r--r--Tools/WebKitAPITest/WebKitAPITestCommon.vsprops21
-rw-r--r--Tools/WebKitAPITest/WebKitAPITestPostBuild.cmd1
-rw-r--r--Tools/WebKitAPITest/WebKitAPITestPreBuild.cmd6
-rw-r--r--Tools/WebKitAPITest/main.cpp35
-rw-r--r--Tools/WebKitAPITest/tests/WebViewDestruction.cpp230
11 files changed, 1116 insertions, 0 deletions
diff --git a/Tools/WebKitAPITest/HostWindow.cpp b/Tools/WebKitAPITest/HostWindow.cpp
new file mode 100644
index 0000000..b364831
--- /dev/null
+++ b/Tools/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, 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/Tools/WebKitAPITest/HostWindow.h b/Tools/WebKitAPITest/HostWindow.h
new file mode 100644
index 0000000..a2734ed
--- /dev/null
+++ b/Tools/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/Tools/WebKitAPITest/Test.h b/Tools/WebKitAPITest/Test.h
new file mode 100644
index 0000000..33b07c9
--- /dev/null
+++ b/Tools/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/Tools/WebKitAPITest/TestsController.cpp b/Tools/WebKitAPITest/TestsController.cpp
new file mode 100644
index 0000000..08b193a
--- /dev/null
+++ b/Tools/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.leakPtr());
+ 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/Tools/WebKitAPITest/TestsController.h b/Tools/WebKitAPITest/TestsController.h
new file mode 100644
index 0000000..11b457d
--- /dev/null
+++ b/Tools/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/Tools/WebKitAPITest/WebKitAPITest.vcproj b/Tools/WebKitAPITest/WebKitAPITest.vcproj
new file mode 100644
index 0000000..e3d8171
--- /dev/null
+++ b/Tools/WebKitAPITest/WebKitAPITest.vcproj
@@ -0,0 +1,418 @@
+<?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="$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\common.vsprops;$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\debug.vsprops;$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\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|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\common.vsprops;$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\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>
+ <Configuration
+ Name="Debug_Cairo_CFLite|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\common.vsprops;$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\debug.vsprops;$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\debug_wincairo.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="Release|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\common.vsprops;$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\release.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="Release_LTCG|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\common.vsprops;$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\release.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="Release_Cairo_CFLite|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\common.vsprops;$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\release.vsprops;$(WebKitVSPropsRedirectionDir)..\..\WebKitLibraries\win\tools\vsprops\WinCairo.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/Tools/WebKitAPITest/WebKitAPITestCommon.vsprops b/Tools/WebKitAPITest/WebKitAPITestCommon.vsprops
new file mode 100644
index 0000000..f57f53c
--- /dev/null
+++ b/Tools/WebKitAPITest/WebKitAPITestCommon.vsprops
@@ -0,0 +1,21 @@
+<?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="user32.lib ole32.lib JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib"
+ SubSystem="1"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/NXCOMPAT"
+ />
+</VisualStudioPropertySheet>
diff --git a/Tools/WebKitAPITest/WebKitAPITestPostBuild.cmd b/Tools/WebKitAPITest/WebKitAPITestPostBuild.cmd
new file mode 100644
index 0000000..f011495
--- /dev/null
+++ b/Tools/WebKitAPITest/WebKitAPITestPostBuild.cmd
@@ -0,0 +1 @@
+if exist "%WEBKITOUTPUTDIR%\buildfailed" del "%WEBKITOUTPUTDIR%\buildfailed"
diff --git a/Tools/WebKitAPITest/WebKitAPITestPreBuild.cmd b/Tools/WebKitAPITest/WebKitAPITestPreBuild.cmd
new file mode 100644
index 0000000..3a84c26
--- /dev/null
+++ b/Tools/WebKitAPITest/WebKitAPITestPreBuild.cmd
@@ -0,0 +1,6 @@
+%SystemDrive%\cygwin\bin\which.exe bash
+if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
+cmd /c
+if exist "%WEBKITOUTPUTDIR%\buildfailed" grep XX%PROJECTNAME%XX "%WEBKITOUTPUTDIR%\buildfailed"
+if errorlevel 1 exit 1
+echo XX%PROJECTNAME%XX > "%WEBKITOUTPUTDIR%\buildfailed"
diff --git a/Tools/WebKitAPITest/main.cpp b/Tools/WebKitAPITest/main.cpp
new file mode 100644
index 0000000..a941c30
--- /dev/null
+++ b/Tools/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/Tools/WebKitAPITest/tests/WebViewDestruction.cpp b/Tools/WebKitAPITest/tests/WebViewDestruction.cpp
new file mode 100644
index 0000000..6c09e6f
--- /dev/null
+++ b/Tools/WebKitAPITest/tests/WebViewDestruction.cpp
@@ -0,0 +1,230 @@
+/*
+ * 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 void createAndInitializeWebView(COMPtr<IWebView>& outWebView, HostWindow& window, HWND& viewWindow)
+{
+ COMPtr<IWebView> webView;
+ TEST_ASSERT(SUCCEEDED(WebKitCreateInstance(__uuidof(WebView), &webView)));
+
+ TEST_ASSERT(window.initialize());
+ TEST_ASSERT(SUCCEEDED(webView->setHostWindow(reinterpret_cast<OLE_HANDLE>(window.window()))));
+ TEST_ASSERT(SUCCEEDED(webView->initWithFrame(window.clientRect(), 0, 0)));
+
+ COMPtr<IWebViewPrivate> viewPrivate(Query, webView);
+ TEST_ASSERT(viewPrivate);
+ TEST_ASSERT(SUCCEEDED(viewPrivate->viewWindow(reinterpret_cast<OLE_HANDLE*>(&viewWindow))));
+ TEST_ASSERT(IsWindow(viewWindow));
+
+ outWebView.adoptRef(webView.releaseRef());
+}
+
+static void runMessagePump(DWORD timeoutMilliseconds)
+{
+ DWORD startTickCount = GetTickCount();
+ MSG msg;
+ BOOL result;
+ while ((result = PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) && GetTickCount() - startTickCount <= timeoutMilliseconds) {
+ if (result == -1)
+ break;
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+}
+
+static void finishWebViewDestructionTest(COMPtr<IWebView>& webView, HWND viewWindow)
+{
+ // Allow window messages to be processed, because in some cases that would trigger a crash (e.g., <http://webkit.org/b/32827>).
+ runMessagePump(50);
+
+ // We haven't crashed. Release the WebView and ensure that its view window has been destroyed and the WebView doesn't leak.
+ int currentWebViewCount = webViewCount();
+ TEST_ASSERT(currentWebViewCount > 0);
+
+ webView = 0;
+
+ TEST_ASSERT(webViewCount() == currentWebViewCount - 1);
+ TEST_ASSERT(!IsWindow(viewWindow));
+}
+
+// Tests that releasing a WebView without calling IWebView::initWithFrame works.
+TEST(WebViewDestruction, NoInitWithFrame)
+{
+ COMPtr<IWebView> webView;
+ TEST_ASSERT(SUCCEEDED(WebKitCreateInstance(__uuidof(WebView), &webView)));
+
+ finishWebViewDestructionTest(webView, 0);
+}
+
+TEST(WebViewDestruction, CloseWithoutInitWithFrame)
+{
+ COMPtr<IWebView> webView;
+ TEST_ASSERT(SUCCEEDED(WebKitCreateInstance(__uuidof(WebView), &webView)));
+
+ TEST_ASSERT(SUCCEEDED(webView->close()));
+
+ finishWebViewDestructionTest(webView, 0);
+}
+
+// Tests that releasing a WebView without calling IWebView::close or DestroyWindow doesn't leak. <http://webkit.org/b/33162>
+TEST(WebViewDestruction, NoCloseOrDestroyViewWindow)
+{
+ COMPtr<IWebView> webView;
+ HostWindow window;
+ HWND viewWindow;
+ createAndInitializeWebView(webView, window, viewWindow);
+
+ finishWebViewDestructionTest(webView, viewWindow);
+}
+
+// Tests that calling IWebView::close without calling DestroyWindow, then releasing a WebView doesn't crash. <http://webkit.org/b/32827>
+TEST(WebViewDestruction, CloseWithoutDestroyViewWindow)
+{
+ COMPtr<IWebView> webView;
+ HostWindow window;
+ HWND viewWindow;
+ createAndInitializeWebView(webView, window, viewWindow);
+
+ TEST_ASSERT(SUCCEEDED(webView->close()));
+
+ finishWebViewDestructionTest(webView, viewWindow);
+}
+
+TEST(WebViewDestruction, DestroyViewWindowWithoutClose)
+{
+ COMPtr<IWebView> webView;
+ HostWindow window;
+ HWND viewWindow;
+ createAndInitializeWebView(webView, window, viewWindow);
+
+ DestroyWindow(viewWindow);
+
+ finishWebViewDestructionTest(webView, viewWindow);
+}
+
+TEST(WebViewDestruction, CloseThenDestroyViewWindow)
+{
+ COMPtr<IWebView> webView;
+ HostWindow window;
+ HWND viewWindow;
+ createAndInitializeWebView(webView, window, viewWindow);
+
+ TEST_ASSERT(SUCCEEDED(webView->close()));
+ DestroyWindow(viewWindow);
+
+ finishWebViewDestructionTest(webView, viewWindow);
+}
+
+TEST(WebViewDestruction, DestroyViewWindowThenClose)
+{
+ COMPtr<IWebView> webView;
+ HostWindow window;
+ HWND viewWindow;
+ createAndInitializeWebView(webView, window, viewWindow);
+
+ DestroyWindow(viewWindow);
+ TEST_ASSERT(SUCCEEDED(webView->close()));
+
+ finishWebViewDestructionTest(webView, viewWindow);
+}
+
+TEST(WebViewDestruction, DestroyHostWindow)
+{
+ COMPtr<IWebView> webView;
+ HostWindow window;
+ HWND viewWindow;
+ createAndInitializeWebView(webView, window, viewWindow);
+
+ DestroyWindow(window.window());
+
+ finishWebViewDestructionTest(webView, viewWindow);
+}
+
+TEST(WebViewDestruction, DestroyHostWindowThenClose)
+{
+ COMPtr<IWebView> webView;
+ HostWindow window;
+ HWND viewWindow;
+ createAndInitializeWebView(webView, window, viewWindow);
+
+ DestroyWindow(window.window());
+ TEST_ASSERT(SUCCEEDED(webView->close()));
+
+ finishWebViewDestructionTest(webView, viewWindow);
+}
+
+TEST(WebViewDestruction, CloseThenDestroyHostWindow)
+{
+ COMPtr<IWebView> webView;
+ HostWindow window;
+ HWND viewWindow;
+ createAndInitializeWebView(webView, window, viewWindow);
+
+ TEST_ASSERT(SUCCEEDED(webView->close()));
+ DestroyWindow(window.window());
+
+ finishWebViewDestructionTest(webView, viewWindow);
+}
+
+// Tests that calling IWebView::mainFrame after calling IWebView::close doesn't crash. <http://webkit.org/b/32868>
+TEST(WebViewDestruction, MainFrameAfterClose)
+{
+ COMPtr<IWebView> webView;
+ HostWindow window;
+ HWND viewWindow;
+ createAndInitializeWebView(webView, window, viewWindow);
+
+ TEST_ASSERT(SUCCEEDED(webView->close()));
+ COMPtr<IWebFrame> mainFrame;
+ TEST_ASSERT(SUCCEEDED(webView->mainFrame(&mainFrame)));
+
+ finishWebViewDestructionTest(webView, viewWindow);
+}
+
+} // namespace WebKitAPITest