diff options
author | Ben Murdoch <benm@google.com> | 2011-05-05 14:36:32 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-10 15:38:30 +0100 |
commit | f05b935882198ccf7d81675736e3aeb089c5113a (patch) | |
tree | 4ea0ca838d9ef1b15cf17ddb3928efb427c7e5a1 /WebKitTools/TestWebKitAPI/Tests/WebKit2 | |
parent | 60fbdcc62bced8db2cb1fd233cc4d1e4ea17db1b (diff) | |
download | external_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 'WebKitTools/TestWebKitAPI/Tests/WebKit2')
21 files changed, 0 insertions, 1341 deletions
diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/DocumentStartUserScriptAlertCrash.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/DocumentStartUserScriptAlertCrash.cpp deleted file mode 100644 index 5e0655e..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/DocumentStartUserScriptAlertCrash.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 "Test.h" - -#include "PlatformUtilities.h" -#include "PlatformWebView.h" -#include <WebKit2/WebKit2.h> -#include <WebKit2/WKRetainPtr.h> - -namespace TestWebKitAPI { - -static bool done; - -static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo) -{ - TEST_ASSERT(frame); - TEST_ASSERT(WKFrameGetPage(frame) == page); - TEST_ASSERT(WKStringIsEqualToUTF8CString(alertText, "an alert")); - - done = true; -} - -TEST(WebKit2, DocumentStartUserScriptAlertCrashTest) -{ - WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("DocumentStartUserScriptAlertCrashTest")); - WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); - PlatformWebView webView(pageNamespace.get()); - - WKPageUIClient uiClient; - memset(&uiClient, 0, sizeof(uiClient)); - uiClient.version = 0; - uiClient.clientInfo = 0; - uiClient.runJavaScriptAlert = runJavaScriptAlert; - WKPageSetPageUIClient(webView.page(), &uiClient); - - WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html")); - WKPageLoadURL(webView.page(), url.get()); - - Util::run(&done); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/DocumentStartUserScriptAlertCrash_Bundle.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/DocumentStartUserScriptAlertCrash_Bundle.cpp deleted file mode 100644 index a96bef2..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/DocumentStartUserScriptAlertCrash_Bundle.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 "InjectedBundleTest.h" -#include <WebKit2/WebKit2.h> -#include <WebKit2/WKBundlePrivate.h> -#include <WebKit2/WKBundleScriptWorld.h> -#include <WebKit2/WKRetainPtr.h> - -namespace TestWebKitAPI { - -class DocumentStartUserScriptAlertCrashTest : public InjectedBundleTest { -public: - DocumentStartUserScriptAlertCrashTest(const std::string& identifier) - : InjectedBundleTest(identifier) - { - } - - virtual void initialize(WKBundleRef bundle) - { - WKRetainPtr<WKStringRef> source(AdoptWK, WKStringCreateWithUTF8CString("alert('an alert');")); - WKBundleAddUserScript(bundle, WKBundleScriptWorldNormalWorld(), source.get(), 0, 0, 0, kWKInjectAtDocumentStart, kWKInjectInAllFrames); - } -}; - -static InjectedBundleTest::Register<DocumentStartUserScriptAlertCrashTest> registrar("DocumentStartUserScriptAlertCrashTest"); - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/EvaluateJavaScript.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/EvaluateJavaScript.cpp deleted file mode 100644 index bbdece3..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/EvaluateJavaScript.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 "Test.h" - -#include "PlatformUtilities.h" -#include "PlatformWebView.h" -#include <WebKit2/WKRetainPtr.h> -#include <WebKit2/WebKit2.h> - -namespace TestWebKitAPI { - -static bool testDone; - -static void didRunJavaScript(WKStringRef resultString, WKErrorRef error, void* context) -{ - TEST_ASSERT(context == reinterpret_cast<void*>(0x1234578)); - TEST_ASSERT(WKStringIsEmpty(resultString)); - - // FIXME: We should also check the error, but right now it's always null. - // Assert that it's null so we can revisit when this changes. - TEST_ASSERT(!error); - - testDone = true; -} - -TEST(WebKit2, EvaluateJavaScriptThatThrowsAnException) -{ - WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); - WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); - PlatformWebView webView(pageNamespace.get()); - - WKRetainPtr<WKStringRef> javaScriptString(AdoptWK, WKStringCreateWithUTF8CString("throw 'Hello'")); - WKPageRunJavaScriptInMainFrame(webView.page(), javaScriptString.get(), reinterpret_cast<void*>(0x1234578), didRunJavaScript); - - Util::run(&testDone); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/FailedLoad.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/FailedLoad.cpp deleted file mode 100644 index 0ccee5a..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/FailedLoad.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 "Test.h" - -#include "PlatformUtilities.h" -#include "PlatformWebView.h" -#include <WebKit2/WebKit2.h> -#include <WebKit2/WKRetainPtr.h> - -namespace TestWebKitAPI { - -// FIXME: This should also test the that the load state after didFailLoadWithErrorForFrame is kWKFrameLoadStateFinished - -static bool testDone; - -static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo) -{ - TEST_ASSERT(WKFrameGetFrameLoadState(frame) == kWKFrameLoadStateFinished); - - WKURLRef url = WKFrameCopyProvisionalURL(frame); - TEST_ASSERT(!url); - - testDone = true; -} - -TEST(WebKit2, FailedLoad) -{ - WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); - WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); - PlatformWebView webView(pageNamespace.get()); - - WKPageLoaderClient loaderClient; - memset(&loaderClient, 0, sizeof(loaderClient)); - - loaderClient.version = 0; - loaderClient.clientInfo = 0; - loaderClient.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame; - WKPageSetPageLoaderClient(webView.page(), &loaderClient); - - WKRetainPtr<WKURLRef> url(AdoptWK, Util::URLForNonExistentResource()); - WKPageLoadURL(webView.page(), url.get()); - - Util::run(&testDone); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/Find.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/Find.cpp deleted file mode 100644 index 63bcea8..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/Find.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 "Test.h" - -#include "PlatformUtilities.h" -#include "PlatformWebView.h" -#include <WebKit2/WKRetainPtr.h> -#include <WebKit2/WebKit2.h> - -namespace TestWebKitAPI { - -static bool didFinishLoad = false; -static bool didCallCountStringMatches = false; - -static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - didFinishLoad = true; -} - -static void didCountStringMatches(WKPageRef page, WKStringRef string, unsigned numMatches, const void* clientInfo) -{ - TEST_ASSERT(WKStringIsEqualToUTF8CString(string, "Hello")); - TEST_ASSERT(numMatches == 3); - - didCallCountStringMatches = true; -} - -TEST(WebKit2, Find) -{ - WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); - WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); - - PlatformWebView webView(pageNamespace.get()); - - WKPageLoaderClient loaderClient; - memset(&loaderClient, 0, sizeof(loaderClient)); - - loaderClient.version = 0; - loaderClient.didFinishLoadForFrame = didFinishLoadForFrame; - WKPageSetPageLoaderClient(webView.page(), &loaderClient); - - WKPageFindClient findClient; - memset(&findClient, 0, sizeof(findClient)); - - findClient.version = 0; - findClient.didCountStringMatches = didCountStringMatches; - WKPageSetPageFindClient(webView.page(), &findClient); - - WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("find", "html")); - WKPageLoadURL(webView.page(), url.get()); - - Util::run(&didFinishLoad); - - WKRetainPtr<WKStringRef> findString(AdoptWK, WKStringCreateWithUTF8CString("Hello")); - WKPageCountStringMatches(webView.page(), findString.get(), true, 100); - - Util::run(&didCallCountStringMatches); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/FrameMIMETypeHTML.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/FrameMIMETypeHTML.cpp deleted file mode 100644 index a270357..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/FrameMIMETypeHTML.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 "Test.h" - -#include "PlatformUtilities.h" -#include "PlatformWebView.h" -#include <WebKit2/WebKit2.h> -#include <WebKit2/WKRetainPtr.h> - -namespace TestWebKitAPI { - -static bool testDone; - -static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - WKRetainPtr<WKStringRef> wkMIME(AdoptWK, WKFrameCopyMIMEType(frame)); - TEST_ASSERT(WKStringIsEmpty(wkMIME.get())); -} - -static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - WKRetainPtr<WKStringRef> wkMIME(AdoptWK, WKFrameCopyMIMEType(frame)); - TEST_ASSERT(WKStringIsEqualToUTF8CString(wkMIME.get(), "text/html")); -} - -static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - WKRetainPtr<WKStringRef> wkMIME(AdoptWK, WKFrameCopyMIMEType(frame)); - TEST_ASSERT(WKStringIsEqualToUTF8CString(wkMIME.get(), "text/html")); - - testDone = true; -} - -TEST(WebKit2, FrameMIMETypeHTML) -{ - WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); - WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); - PlatformWebView webView(pageNamespace.get()); - - WKPageLoaderClient loaderClient; - memset(&loaderClient, 0, sizeof(loaderClient)); - - loaderClient.version = 0; - loaderClient.clientInfo = 0; - loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame; - loaderClient.didCommitLoadForFrame = didCommitLoadForFrame; - loaderClient.didFinishLoadForFrame = didFinishLoadForFrame; - WKPageSetPageLoaderClient(webView.page(), &loaderClient); - - WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html")); - WKPageLoadURL(webView.page(), url.get()); - - Util::run(&testDone); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/FrameMIMETypePNG.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/FrameMIMETypePNG.cpp deleted file mode 100644 index 3588940..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/FrameMIMETypePNG.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 "Test.h" - -#include "PlatformUtilities.h" -#include "PlatformWebView.h" -#include <WebKit2/WebKit2.h> -#include <WebKit2/WKRetainPtr.h> - -namespace TestWebKitAPI { - -static bool testDone; - -static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - WKRetainPtr<WKStringRef> wkMIME(AdoptWK, WKFrameCopyMIMEType(frame)); - TEST_ASSERT(WKStringIsEmpty(wkMIME.get())); -} - -static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - WKRetainPtr<WKStringRef> wkMIME(AdoptWK, WKFrameCopyMIMEType(frame)); - TEST_ASSERT(WKStringIsEqualToUTF8CString(wkMIME.get(), "image/png")); -} - -static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - WKRetainPtr<WKStringRef> wkMIME(AdoptWK, WKFrameCopyMIMEType(frame)); - TEST_ASSERT(WKStringIsEqualToUTF8CString(wkMIME.get(), "image/png")); - - testDone = true; -} - -TEST(WebKit2, FrameMIMETypePNG) -{ - WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); - WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); - PlatformWebView webView(pageNamespace.get()); - - WKPageLoaderClient loaderClient; - memset(&loaderClient, 0, sizeof(loaderClient)); - - loaderClient.version = 0; - loaderClient.clientInfo = 0; - loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame; - loaderClient.didCommitLoadForFrame = didCommitLoadForFrame; - loaderClient.didFinishLoadForFrame = didFinishLoadForFrame; - WKPageSetPageLoaderClient(webView.page(), &loaderClient); - - WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("icon", "png")); - WKPageLoadURL(webView.page(), url.get()); - - Util::run(&testDone); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/InjectedBundleBasic.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/InjectedBundleBasic.cpp deleted file mode 100644 index 1f4cce6..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/InjectedBundleBasic.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 "Test.h" - -#include "PlatformUtilities.h" -#include "PlatformWebView.h" -#include <WebKit2/WebKit2.h> -#include <WebKit2/WKRetainPtr.h> - -namespace TestWebKitAPI { - -static bool done; -static bool loadDone; -static bool messageReceived; - -void didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo) -{ - messageReceived = true; - if (loadDone) - done = true; -} - -static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - loadDone = true; - if (messageReceived) - done = true; -} - -TEST(WebKit2, InjectedBundleBasic) -{ - WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("InjectedBundleBasicTest")); - WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); - - WKContextInjectedBundleClient injectedBundleClient; - memset(&injectedBundleClient, 0, sizeof(injectedBundleClient)); - injectedBundleClient.version = 0; - injectedBundleClient.clientInfo = 0; - injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle; - WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient); - - PlatformWebView webView(pageNamespace.get()); - - WKPageLoaderClient loaderClient; - memset(&loaderClient, 0, sizeof(loaderClient)); - loaderClient.version = 0; - loaderClient.clientInfo = 0; - loaderClient.didFinishLoadForFrame = didFinishLoadForFrame; - WKPageSetPageLoaderClient(webView.page(), &loaderClient); - - WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html")); - WKPageLoadURL(webView.page(), url.get()); - - Util::run(&done); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/InjectedBundleBasic_Bundle.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/InjectedBundleBasic_Bundle.cpp deleted file mode 100644 index 67c062b..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/InjectedBundleBasic_Bundle.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 "InjectedBundleTest.h" -#include <WebKit2/WebKit2.h> -#include <WebKit2/WKRetainPtr.h> - -namespace TestWebKitAPI { - -class InjectedBundleBasicTest : public InjectedBundleTest { -public: - InjectedBundleBasicTest(const std::string& identifier) - : InjectedBundleTest(identifier) - { - } - - virtual void didCreatePage(WKBundleRef bundle, WKBundlePageRef page) - { - WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithUTF8CString("DoneMessageName")); - WKRetainPtr<WKStringRef> doneMessageBody(AdoptWK, WKStringCreateWithUTF8CString("DoneMessageBody")); - WKBundlePostMessage(bundle, doneMessageName.get(), doneMessageBody.get()); - } -}; - -static InjectedBundleTest::Register<InjectedBundleBasicTest> registrar("InjectedBundleBasicTest"); - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp deleted file mode 100644 index c3af543..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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 "Test.h" - -#include "PlatformUtilities.h" -#include "PlatformWebView.h" -#include <WebKit2/WebKit2.h> -#include <WebKit2/WKRetainPtr.h> - -namespace TestWebKitAPI { - -static bool test1Done; - -struct State { - State() - : didDecidePolicyForNavigationAction(false) - , didStartProvisionalLoadForFrame(false) - , didCommitLoadForFrame(false) - { - } - - bool didDecidePolicyForNavigationAction; - bool didStartProvisionalLoadForFrame; - bool didCommitLoadForFrame; -}; - -static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - State* state = reinterpret_cast<State*>(const_cast<void*>(clientInfo)); - TEST_ASSERT(state->didDecidePolicyForNavigationAction); - TEST_ASSERT(!state->didCommitLoadForFrame); - - // The commited URL should be null. - TEST_ASSERT(!WKFrameCopyURL(frame)); - - TEST_ASSERT(!state->didStartProvisionalLoadForFrame); - - - state->didStartProvisionalLoadForFrame = true; -} - -static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - State* state = reinterpret_cast<State*>(const_cast<void*>(clientInfo)); - TEST_ASSERT(state->didDecidePolicyForNavigationAction); - TEST_ASSERT(state->didStartProvisionalLoadForFrame); - - // The provisional URL should be null. - TEST_ASSERT(!WKFrameCopyProvisionalURL(frame)); - - state->didCommitLoadForFrame = true; -} - -static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - State* state = reinterpret_cast<State*>(const_cast<void*>(clientInfo)); - TEST_ASSERT(state->didDecidePolicyForNavigationAction); - TEST_ASSERT(state->didStartProvisionalLoadForFrame); - TEST_ASSERT(state->didCommitLoadForFrame); - - // The provisional URL should be null. - TEST_ASSERT(!WKFrameCopyProvisionalURL(frame)); - - test1Done = true; -} - -static void decidePolicyForNavigationAction(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void* clientInfo) -{ - State* state = reinterpret_cast<State*>(const_cast<void*>(clientInfo)); - TEST_ASSERT(!state->didStartProvisionalLoadForFrame); - TEST_ASSERT(!state->didCommitLoadForFrame); - - state->didDecidePolicyForNavigationAction = true; - - WKFramePolicyListenerUse(listener); -} - -static void decidePolicyForNewWindowAction(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void* clientInfo) -{ - WKFramePolicyListenerUse(listener); -} - -static void decidePolicyForMIMEType(WKPageRef page, WKStringRef MIMEType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void* clientInfo) -{ - WKFramePolicyListenerUse(listener); -} - -TEST(WebKit2, PageLoadBasic) -{ - State state; - - WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); - WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); - - PlatformWebView webView(pageNamespace.get()); - - WKPageLoaderClient loaderClient; - memset(&loaderClient, 0, sizeof(loaderClient)); - - loaderClient.version = 0; - loaderClient.clientInfo = &state; - loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame; - loaderClient.didCommitLoadForFrame = didCommitLoadForFrame; - loaderClient.didFinishLoadForFrame = didFinishLoadForFrame; - WKPageSetPageLoaderClient(webView.page(), &loaderClient); - - WKPagePolicyClient policyClient; - memset(&policyClient, 0, sizeof(policyClient)); - - policyClient.version = 0; - policyClient.clientInfo = &state; - policyClient.decidePolicyForNavigationAction = decidePolicyForNavigationAction; - policyClient.decidePolicyForNewWindowAction = decidePolicyForNewWindowAction; - policyClient.decidePolicyForMIMEType = decidePolicyForMIMEType; - WKPageSetPagePolicyClient(webView.page(), &policyClient); - - WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html")); - WKPageLoadURL(webView.page(), url.get()); - - Util::run(&test1Done); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/PreventEmptyUserAgent.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/PreventEmptyUserAgent.cpp deleted file mode 100644 index af3ed12..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/PreventEmptyUserAgent.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 "Test.h" - -#include "PlatformUtilities.h" -#include "PlatformWebView.h" -#include <WebKit2/WKRetainPtr.h> -#include <WebKit2/WebKit2.h> - -namespace TestWebKitAPI { - -static bool testDone; - -static void didRunJavaScript(WKStringRef resultString, WKErrorRef error, void* context) -{ - TEST_ASSERT(context == reinterpret_cast<void*>(0x1234578)); - - // Make sure that the result of navigator.userAgent isn't empty, even if we set the custom - // user agent to the empty string. - TEST_ASSERT(!WKStringIsEmpty(resultString)); - - testDone = true; -} - -TEST(WebKit2, PreventEmptyUserAgent) -{ - WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); - WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); - PlatformWebView webView(pageNamespace.get()); - - WKPageSetCustomUserAgent(webView.page(), WKStringCreateWithUTF8CString("")); - WKRetainPtr<WKStringRef> javaScriptString(AdoptWK, WKStringCreateWithUTF8CString("navigator.userAgent")); - WKPageRunJavaScriptInMainFrame(webView.page(), javaScriptString.get(), reinterpret_cast<void*>(0x1234578), didRunJavaScript); - - Util::run(&testDone); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/SpacebarScrolling.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/SpacebarScrolling.cpp deleted file mode 100644 index a88db9f..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/SpacebarScrolling.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * 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 "Test.h" - -#include "PlatformUtilities.h" -#include "PlatformWebView.h" -#include <WebKit2/WKRetainPtr.h> - -namespace TestWebKitAPI { - -struct JavaScriptCallbackContext { - JavaScriptCallbackContext(const char* expectedString) : didFinish(false), expectedString(expectedString), didMatchExpectedString(false) { } - - bool didFinish; - const char* expectedString; - bool didMatchExpectedString; -}; - -static bool didFinishLoad; -static bool didNotHandleKeyDownEvent; - -static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*) -{ - didFinishLoad = true; -} - -static void didNotHandleKeyEventCallback(WKPageRef, WKNativeEventPtr event, const void*) -{ - if (Util::isKeyDown(event)) - didNotHandleKeyDownEvent = true; -} - -static void javaScriptCallback(WKStringRef string, WKErrorRef error, void* ctx) -{ - JavaScriptCallbackContext* context = static_cast<JavaScriptCallbackContext*>(ctx); - - context->didFinish = true; - context->didMatchExpectedString = WKStringIsEqualToUTF8CString(string, context->expectedString); - - TEST_ASSERT(!error); -} - -static WKRetainPtr<WKStringRef> wk(const char* utf8String) -{ - return WKRetainPtr<WKStringRef>(AdoptWK, WKStringCreateWithUTF8CString(utf8String)); -} - -static bool runJSTest(WKPageRef page, const char* script, const char* expectedResult) -{ - JavaScriptCallbackContext context(expectedResult); - WKPageRunJavaScriptInMainFrame(page, wk(script).get(), &context, javaScriptCallback); - Util::run(&context.didFinish); - return context.didMatchExpectedString; -} - -TEST(WebKit2, SpacebarScrolling) -{ - WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); - WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); - - PlatformWebView webView(pageNamespace.get()); - - WKPageLoaderClient loaderClient; - memset(&loaderClient, 0, sizeof(loaderClient)); - - loaderClient.version = 0; - loaderClient.didFinishLoadForFrame = didFinishLoadForFrame; - WKPageSetPageLoaderClient(webView.page(), &loaderClient); - - WKPageUIClient uiClient; - memset(&uiClient, 0, sizeof(uiClient)); - - uiClient.didNotHandleKeyEvent = didNotHandleKeyEventCallback; - WKPageSetPageUIClient(webView.page(), &uiClient); - - WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("spacebar-scrolling", "html")); - WKPageLoadURL(webView.page(), url.get()); - Util::run(&didFinishLoad); - - TEST_ASSERT(runJSTest(webView.page(), "isDocumentScrolled()", "false")); - TEST_ASSERT(runJSTest(webView.page(), "textFieldContainsSpace()", "false")); - - webView.simulateSpacebarKeyPress(); - - TEST_ASSERT(runJSTest(webView.page(), "isDocumentScrolled()", "false")); - TEST_ASSERT(runJSTest(webView.page(), "textFieldContainsSpace()", "true")); - - // On Mac, a key down event represents both a raw key down and a key press. On Windows, a key - // down event only represents a raw key down. We expect the key press to be handled (because it - // inserts text into the text field). But the raw key down should not be handled. -#if PLATFORM(MAC) - TEST_ASSERT(!didNotHandleKeyDownEvent); -#elif PLATFORM(WIN) - TEST_ASSERT(didNotHandleKeyDownEvent); -#endif - - TEST_ASSERT(runJSTest(webView.page(), "blurTextField()", "undefined")); - - didNotHandleKeyDownEvent = false; - webView.simulateSpacebarKeyPress(); - - TEST_ASSERT(runJSTest(webView.page(), "isDocumentScrolled()", "true")); - TEST_ASSERT(runJSTest(webView.page(), "textFieldContainsSpace()", "true")); -#if PLATFORM(MAC) - TEST_ASSERT(!didNotHandleKeyDownEvent); -#elif PLATFORM(WIN) - TEST_ASSERT(didNotHandleKeyDownEvent); -#endif -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/WKPreferences.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/WKPreferences.cpp deleted file mode 100644 index d4cd4b7..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/WKPreferences.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 "Test.h" - -#include <WebKit2/WKPreferences.h> -#include <WebKit2/WKPreferencesPrivate.h> -#include <WebKit2/WKRetainPtr.h> -#include <WebKit2/WKString.h> -#include <wtf/Platform.h> - -namespace TestWebKitAPI { - -TEST(WebKit2, WKPreferencesBasic) -{ - WKPreferencesRef preference = WKPreferencesCreate(); - - TEST_ASSERT(WKGetTypeID(preference) == WKPreferencesGetTypeID()); - - WKRelease(preference); -} - -TEST(WebKit2, WKPreferencesDefaults) -{ -#if PLATFORM(WIN) - static const char* expectedStandardFontFamily = "Times New Roman"; - static const char* expectedFixedFontFamily = "Courier New"; - static const char* expectedSerifFontFamily = "Times New Roman"; - static const char* expectedSansSerifFontFamily = "Arial"; - static const char* expectedCursiveFontFamily = "Comic Sans MS"; - static const char* expectedFantasyFontFamily = "Comic Sans MS"; -#elif PLATFORM(MAC) - static const char* expectedStandardFontFamily = "Times"; - static const char* expectedFixedFontFamily = "Courier"; - static const char* expectedSerifFontFamily = "Times"; - static const char* expectedSansSerifFontFamily = "Helvetica"; - static const char* expectedCursiveFontFamily = "Apple Chancery"; - static const char* expectedFantasyFontFamily = "Papyrus"; -#endif - - WKPreferencesRef preference = WKPreferencesCreate(); - - TEST_ASSERT(WKPreferencesGetJavaScriptEnabled(preference) == true); - TEST_ASSERT(WKPreferencesGetLoadsImagesAutomatically(preference) == true); - TEST_ASSERT(WKPreferencesGetOfflineWebApplicationCacheEnabled(preference) == false); - TEST_ASSERT(WKPreferencesGetLocalStorageEnabled(preference) == true); - TEST_ASSERT(WKPreferencesGetXSSAuditorEnabled(preference) == true); - TEST_ASSERT(WKPreferencesGetFrameFlatteningEnabled(preference) == false); - TEST_ASSERT(WKPreferencesGetPluginsEnabled(preference) == true); - TEST_ASSERT(WKPreferencesGetJavaEnabled(preference) == true); - WKRetainPtr<WKStringRef> standardFontFamily(AdoptWK, WKPreferencesCopyStandardFontFamily(preference)); - TEST_ASSERT(WKStringIsEqualToUTF8CString(standardFontFamily.get(), expectedStandardFontFamily)); - WKRetainPtr<WKStringRef> fixedFontFamily(AdoptWK, WKPreferencesCopyFixedFontFamily(preference)); - TEST_ASSERT(WKStringIsEqualToUTF8CString(fixedFontFamily.get(), expectedFixedFontFamily)); - WKRetainPtr<WKStringRef> serifFontFamily(AdoptWK, WKPreferencesCopySerifFontFamily(preference)); - TEST_ASSERT(WKStringIsEqualToUTF8CString(serifFontFamily.get(), expectedSerifFontFamily)); - WKRetainPtr<WKStringRef> sansSerifFontFamily(AdoptWK, WKPreferencesCopySansSerifFontFamily(preference)); - TEST_ASSERT(WKStringIsEqualToUTF8CString(sansSerifFontFamily.get(), expectedSansSerifFontFamily)); - WKRetainPtr<WKStringRef> cursiveFontFamily(AdoptWK, WKPreferencesCopyCursiveFontFamily(preference)); - TEST_ASSERT(WKStringIsEqualToUTF8CString(cursiveFontFamily.get(), expectedCursiveFontFamily)); - WKRetainPtr<WKStringRef> fantasyFontFamily(AdoptWK, WKPreferencesCopyFantasyFontFamily(preference)); - TEST_ASSERT(WKStringIsEqualToUTF8CString(fantasyFontFamily.get(), expectedFantasyFontFamily)); - TEST_ASSERT(WKPreferencesGetMinimumFontSize(preference) == 0); - TEST_ASSERT(WKPreferencesGetPrivateBrowsingEnabled(preference) == false); - TEST_ASSERT(WKPreferencesGetDeveloperExtrasEnabled(preference) == false); - TEST_ASSERT(WKPreferencesGetTextAreasAreResizable(preference) == true); - TEST_ASSERT(WKPreferencesGetFontSmoothingLevel(preference) == kWKFontSmoothingLevelMedium); - TEST_ASSERT(WKPreferencesGetAcceleratedCompositingEnabled(preference) == true); - TEST_ASSERT(WKPreferencesGetCompositingBordersVisible(preference) == false); - TEST_ASSERT(WKPreferencesGetCompositingRepaintCountersVisible(preference) == false); - TEST_ASSERT(WKPreferencesGetNeedsSiteSpecificQuirks(preference) == false); - - WKRelease(preference); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/WKString.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/WKString.cpp deleted file mode 100644 index b0b133d..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/WKString.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 "Test.h" - -#include <WebKit2/WKString.h> - -namespace TestWebKitAPI { - -TEST(WebKit2, WKString) -{ - WKStringRef string = WKStringCreateWithUTF8CString("hello"); - TEST_ASSERT(!WKStringIsEmpty(string)); - TEST_ASSERT(WKStringIsEqual(string, string)); - TEST_ASSERT(WKStringIsEqualToUTF8CString(string, "hello")); - TEST_ASSERT(WKStringGetMaximumUTF8CStringSize(string) == 16); - - size_t maxSize = WKStringGetMaximumUTF8CStringSize(string); - char* buffer = new char[maxSize]; - - size_t actualSize = WKStringGetUTF8CString(string, buffer, maxSize); - TEST_ASSERT(actualSize == 6); - TEST_ASSERT(strcmp(buffer, "hello") == 0); - - delete[] buffer; - - WKRelease(string); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/WKStringJSString.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/WKStringJSString.cpp deleted file mode 100644 index 0d6eca3..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/WKStringJSString.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 "Test.h" - -#include <WebKit2/WKString.h> -#include <WebKit2/WKStringPrivate.h> -#include <JavaScriptCore/JSStringRef.h> - -namespace TestWebKitAPI { - -TEST(WebKit2, WKStringJSString) -{ - WKStringRef wkString = WKStringCreateWithUTF8CString("hello"); - JSStringRef jsString = JSStringCreateWithUTF8CString("hello"); - - WKStringRef convertedJSString = WKStringCreateWithJSString(jsString); - TEST_ASSERT(WKStringIsEqual(wkString, convertedJSString)); - - JSStringRef convertedWKString = WKStringCopyJSString(wkString); - TEST_ASSERT(JSStringIsEqual(jsString, convertedWKString)); - - WKRelease(wkString); - WKRelease(convertedJSString); - - JSStringRelease(jsString); - JSStringRelease(convertedWKString); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/find.html b/WebKitTools/TestWebKitAPI/Tests/WebKit2/find.html deleted file mode 100644 index d965911..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/find.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - Test search. Hello Hello Hello! -</body> -</html> diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/icon.png b/WebKitTools/TestWebKitAPI/Tests/WebKit2/icon.png Binary files differdeleted file mode 100644 index 79e4598..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/icon.png +++ /dev/null diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/simple.html b/WebKitTools/TestWebKitAPI/Tests/WebKit2/simple.html deleted file mode 100644 index 12cf873..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/simple.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - Simple HTML file. -</body> -</html> diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/spacebar-scrolling.html b/WebKitTools/TestWebKitAPI/Tests/WebKit2/spacebar-scrolling.html deleted file mode 100644 index 8da08b3..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/spacebar-scrolling.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<script> - function textFieldContainsSpace() - { - return document.querySelector("input").value === " "; - } - - function blurTextField() - { - document.querySelector("input").blur(); - } - - function isDocumentScrolled() - { - return scrollY !== 0; - } - - function loaded() - { - document.querySelector("input").focus(); - } - - addEventListener("load", loaded); -</script> -<input> -<div style="height: 3000px;"></div> diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/win/AltKeyGeneratesWMSysCommand.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/win/AltKeyGeneratesWMSysCommand.cpp deleted file mode 100644 index c463cf0..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/win/AltKeyGeneratesWMSysCommand.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 "Test.h" - -#include "PlatformUtilities.h" -#include "PlatformWebView.h" -#include "WindowMessageObserver.h" -#include <WebKit2/WKRetainPtr.h> - -namespace TestWebKitAPI { - -class WMSysCommandObserver : public WindowMessageObserver { -public: - WMSysCommandObserver() : m_windowDidReceiveWMSysCommand(false) { } - - bool windowDidReceiveWMSysCommand() const { return m_windowDidReceiveWMSysCommand; } - -private: - virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM) - { - if (message == WM_SYSCOMMAND) - m_windowDidReceiveWMSysCommand = true; - } - - bool m_windowDidReceiveWMSysCommand; -}; - -static bool didNotHandleWMSysKeyUp; - -static void didNotHandleKeyEventCallback(WKPageRef, WKNativeEventPtr event, const void*) -{ - if (event->message != WM_SYSKEYUP) - return; - - didNotHandleWMSysKeyUp = true; -} - -TEST(WebKit2, AltKeyGeneratesWMSysCommand) -{ - WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); - WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); - - PlatformWebView webView(pageNamespace.get()); - - WKPageUIClient uiClient; - memset(&uiClient, 0, sizeof(uiClient)); - - uiClient.didNotHandleKeyEvent = didNotHandleKeyEventCallback; - WKPageSetPageUIClient(webView.page(), &uiClient); - - WMSysCommandObserver observer; - webView.setParentWindowMessageObserver(&observer); - - webView.simulateAltKeyPress(); - - Util::run(&didNotHandleWMSysKeyUp); - - webView.setParentWindowMessageObserver(0); - - // The WM_SYSKEYUP message should have generated a WM_SYSCOMMAND message that was sent to the - // WKView's parent window. - TEST_ASSERT(observer.windowDidReceiveWMSysCommand()); -} - -} // namespace TestWebKitAPI diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/win/WMCloseCallsUIClientClose.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/win/WMCloseCallsUIClientClose.cpp deleted file mode 100644 index a019f08..0000000 --- a/WebKitTools/TestWebKitAPI/Tests/WebKit2/win/WMCloseCallsUIClientClose.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 "Test.h" - -#include "PlatformUtilities.h" -#include "PlatformWebView.h" -#include <WebKit2/WKRetainPtr.h> - -namespace TestWebKitAPI { - -static bool didReceiveClose; - -static void close(WKPageRef, const void*) -{ - didReceiveClose = true; -} - -TEST(WebKit2, WMCloseCallsUIClientClose) -{ - WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); - WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); - - PlatformWebView webView(pageNamespace.get()); - - WKPageUIClient uiClient; - memset(&uiClient, 0, sizeof(uiClient)); - - uiClient.close = close; - WKPageSetPageUIClient(webView.page(), &uiClient); - - ::SendMessageW(WKViewGetWindow(webView.platformView()), WM_CLOSE, 0, 0); - - Util::run(&didReceiveClose); -} - -} // namespace TestWebKitAPI |