From 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Thu, 2 Jun 2011 12:07:03 +0100 Subject: Merge WebKit at r84325: Initial merge by git. Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b --- .../TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp | 4 +- .../Tests/WebKit2/CanHandleRequest.cpp | 4 +- .../Tests/WebKit2/CanHandleRequest_Bundle.cpp | 4 +- .../TestWebKitAPI/Tests/WebKit2/CookieManager.cpp | 2 +- .../Tests/WebKit2/HitTestResultNodeHandle.cpp | 2 +- ...PageLoadDidChangeLocationWithinPageForFrame.cpp | 4 +- .../WebKit2/ResponsivenessTimerDoesntFireEarly.cpp | 4 +- .../RestoreSessionStateContainingFormData.cpp | 4 +- ...ndingMessagesToTheWebProcessBeforeItIsValid.cpp | 42 ---------- Tools/TestWebKitAPI/Tests/WebKit2/WKString.cpp | 21 +++++ .../Tests/WebKit2/win/HideFindIndicator.cpp | 2 +- .../Tests/WebKit2/win/ResizeViewWhileHidden.cpp | 2 +- .../win/TranslateMessageGeneratesWMChar.cpp | 91 ++++++++++++++++++++++ 13 files changed, 128 insertions(+), 58 deletions(-) delete mode 100644 Tools/TestWebKitAPI/Tests/WebKit2/SendingMessagesToTheWebProcessBeforeItIsValid.cpp create mode 100644 Tools/TestWebKitAPI/Tests/WebKit2/win/TranslateMessageGeneratesWMChar.cpp (limited to 'Tools/TestWebKitAPI/Tests') diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp index 27180e3..cb00276 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp @@ -43,7 +43,7 @@ static void decidePolicyForResponse(WKPageRef, WKFrameRef, WKURLResponseRef resp TEST(WebKit2, AboutBlankLoad) { - WKRetainPtr context = Util::adoptWK(WKContextCreate()); + WKRetainPtr context = adoptWK(WKContextCreate()); PlatformWebView webView(context.get()); WKPagePolicyClient policyClient; @@ -52,7 +52,7 @@ TEST(WebKit2, AboutBlankLoad) policyClient.decidePolicyForResponse = decidePolicyForResponse; WKPageSetPagePolicyClient(webView.page(), &policyClient); - WKPageLoadURL(webView.page(), Util::adoptWK(WKURLCreateWithUTF8CString("about:blank")).get()); + WKPageLoadURL(webView.page(), adoptWK(WKURLCreateWithUTF8CString("about:blank")).get()); Util::run(&done); } diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/CanHandleRequest.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/CanHandleRequest.cpp index 8460847..dffac9b 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit2/CanHandleRequest.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit2/CanHandleRequest.cpp @@ -55,14 +55,14 @@ static void setInjectedBundleClient(WKContextRef context) TEST(WebKit2, CanHandleRequest) { - WKRetainPtr context = Util::adoptWK(Util::createContextForInjectedBundleTest("CanHandleRequestTest")); + WKRetainPtr context = adoptWK(Util::createContextForInjectedBundleTest("CanHandleRequestTest")); setInjectedBundleClient(context.get()); _WKContextRegisterURLSchemeAsEmptyDocument(context.get(), Util::toWK("emptyscheme").get()); PlatformWebView webView(context.get()); - WKPageLoadURL(webView.page(), Util::adoptWK(Util::createURLForResource("simple", "html")).get()); + WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple", "html")).get()); WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("CheckCanHandleRequest").get(), 0); Util::run(&didReceiveMessage); diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/CanHandleRequest_Bundle.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/CanHandleRequest_Bundle.cpp index a253362..b5d644d 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit2/CanHandleRequest_Bundle.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit2/CanHandleRequest_Bundle.cpp @@ -47,7 +47,7 @@ CanHandleRequestTest::CanHandleRequestTest(const std::string& identifier) static bool canHandleURL(const char* url) { - return WKBundlePageCanHandleRequest(Util::adoptWK(WKURLRequestCreateWithWKURL(Util::adoptWK(WKURLCreateWithUTF8CString(url)).get())).get()); + return WKBundlePageCanHandleRequest(adoptWK(WKURLRequestCreateWithWKURL(adoptWK(WKURLCreateWithUTF8CString(url)).get())).get()); } static bool runTest() @@ -60,7 +60,7 @@ void CanHandleRequestTest::didReceiveMessage(WKBundleRef bundle, WKStringRef mes if (!WKStringIsEqualToUTF8CString(messageName, "CheckCanHandleRequest")) return; - WKBundlePostMessage(bundle, Util::toWK("DidCheckCanHandleRequest").get(), Util::adoptWK(WKBooleanCreate(runTest())).get()); + WKBundlePostMessage(bundle, Util::toWK("DidCheckCanHandleRequest").get(), adoptWK(WKBooleanCreate(runTest())).get()); } } // namespace TestWebKitAPI diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/CookieManager.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/CookieManager.cpp index cc4fc43..a1c366c 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit2/CookieManager.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit2/CookieManager.cpp @@ -80,7 +80,7 @@ TEST(WebKit2, CookieManager) loaderClient.didFinishLoadForFrame = didFinishLoadForFrame; WKPageSetPageLoaderClient(webView.page(), &loaderClient); - WKPageLoadURL(webView.page(), Util::adoptWK(WKURLCreateWithUTF8CString("about:blank")).get()); + WKPageLoadURL(webView.page(), adoptWK(WKURLCreateWithUTF8CString("about:blank")).get()); Util::run(&testDone); } diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/HitTestResultNodeHandle.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/HitTestResultNodeHandle.cpp index 5000a47..3f15c15 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit2/HitTestResultNodeHandle.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit2/HitTestResultNodeHandle.cpp @@ -77,7 +77,7 @@ TEST(WebKit2, HitTestResultNodeHandle) PlatformWebView webView(context.get()); setPageLoaderClient(webView.page()); - WKPageLoadURL(webView.page(), Util::adoptWK(Util::createURLForResource("simple", "html")).get()); + WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple", "html")).get()); Util::run(&didFinishLoad); didFinishLoad = false; diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/PageLoadDidChangeLocationWithinPageForFrame.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/PageLoadDidChangeLocationWithinPageForFrame.cpp index a492a67..ce7324b 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit2/PageLoadDidChangeLocationWithinPageForFrame.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit2/PageLoadDidChangeLocationWithinPageForFrame.cpp @@ -72,12 +72,12 @@ TEST(WebKit2, PageLoadDidChangeLocationWithinPageForFrame) WKPageLoadURL(webView.page(), url.get()); Util::run(&didFinishLoad); - WKRetainPtr initialURL = Util::adoptWK(WKFrameCopyURL(WKPageGetMainFrame(webView.page()))); + WKRetainPtr initialURL = adoptWK(WKFrameCopyURL(WKPageGetMainFrame(webView.page()))); WKPageRunJavaScriptInMainFrame(webView.page(), Util::toWK("clickLink()").get(), 0, nullJavaScriptCallback); Util::run(&didChangeLocationWithinPage); - WKRetainPtr urlAfterAnchorClick = Util::adoptWK(WKFrameCopyURL(WKPageGetMainFrame(webView.page()))); + WKRetainPtr urlAfterAnchorClick = adoptWK(WKFrameCopyURL(WKPageGetMainFrame(webView.page()))); TEST_ASSERT(!WKURLIsEqual(initialURL.get(), urlAfterAnchorClick.get())); } diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly.cpp index ea1013a..d8273a1 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly.cpp @@ -75,13 +75,13 @@ static void setPageLoaderClient(WKPageRef page) TEST(WebKit2, ResponsivenessTimerDoesntFireEarly) { - WKRetainPtr context = Util::adoptWK(Util::createContextForInjectedBundleTest("ResponsivenessTimerDoesntFireEarlyTest")); + WKRetainPtr context = adoptWK(Util::createContextForInjectedBundleTest("ResponsivenessTimerDoesntFireEarlyTest")); setInjectedBundleClient(context.get()); PlatformWebView webView(context.get()); setPageLoaderClient(webView.page()); - WKPageLoadURL(webView.page(), Util::adoptWK(Util::createURLForResource("simple", "html")).get()); + WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple", "html")).get()); Util::run(&didFinishLoad); WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("BrieflyPause").get(), 0); diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp index 7c08735..0970bd2 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp @@ -53,7 +53,7 @@ static WKRetainPtr createSessionStateContainingFormData(WKContextRef PlatformWebView webView(context); setPageLoaderClient(webView.page()); - WKPageLoadURL(webView.page(), Util::adoptWK(Util::createURLForResource("simple-form", "html")).get()); + WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple-form", "html")).get()); Util::run(&didFinishLoad); didFinishLoad = false; @@ -61,7 +61,7 @@ static WKRetainPtr createSessionStateContainingFormData(WKContextRef Util::run(&didFinishLoad); didFinishLoad = false; - return Util::adoptWK(WKPageCopySessionState(webView.page(), 0, 0)); + return adoptWK(WKPageCopySessionState(webView.page(), 0, 0)); } TEST(WebKit2, RestoreSessionStateContainingFormData) diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/SendingMessagesToTheWebProcessBeforeItIsValid.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/SendingMessagesToTheWebProcessBeforeItIsValid.cpp deleted file mode 100644 index d48ba31..0000000 --- a/Tools/TestWebKitAPI/Tests/WebKit2/SendingMessagesToTheWebProcessBeforeItIsValid.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2011 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 -#include - -namespace TestWebKitAPI { - -TEST(WebKit2, SendingMessagesToTheWebProcessBeforeItIsValid) -{ - WKRetainPtr context(AdoptWK, WKContextCreate()); - - // Neither of these calls should cause a crash. - WKContextClearResourceCaches(context.get(), kWKAllResourceCaches); - WKContextClearResourceCaches(context.get(), kWKInMemoryResourceCachesOnly); -} - -} // namespace TestWebKitAPI diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/WKString.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/WKString.cpp index b0b133d..4202417 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit2/WKString.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit2/WKString.cpp @@ -46,6 +46,27 @@ TEST(WebKit2, WKString) delete[] buffer; + maxSize = WKStringGetLength(string); + TEST_ASSERT(maxSize == 5); + + // Allocate a buffer one character larger than we need. + WKChar* uniBuffer = new WKChar[maxSize+1]; + actualSize = WKStringGetCharacters(string, uniBuffer, maxSize); + TEST_ASSERT(actualSize == 5); + + WKChar helloBuffer[] = { 'h', 'e', 'l', 'l', 'o' }; + TEST_ASSERT(!memcmp(uniBuffer, helloBuffer, 10)); + + // Test passing a buffer length < the string length. + actualSize = WKStringGetCharacters(string, uniBuffer, maxSize-1); + TEST_ASSERT(actualSize == 4); + + // Test passing a buffer length > the string length. + actualSize = WKStringGetCharacters(string, uniBuffer, maxSize+1); + TEST_ASSERT(actualSize == 5); + + delete[] uniBuffer; + WKRelease(string); } diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/win/HideFindIndicator.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/win/HideFindIndicator.cpp index 40d4f41..7f0c6fa 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit2/win/HideFindIndicator.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit2/win/HideFindIndicator.cpp @@ -63,7 +63,7 @@ TEST(WebKit2, HideFindIndicator) PlatformWebView webView(context.get()); initialize(webView); - WKRetainPtr url = Util::adoptWK(Util::createURLForResource("find", "html")); + WKRetainPtr url = adoptWK(Util::createURLForResource("find", "html")); WKPageLoadURL(webView.page(), url.get()); Util::run(&didFinishLoad); didFinishLoad = false; diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/win/ResizeViewWhileHidden.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/win/ResizeViewWhileHidden.cpp index 7310e6c..9ebfc2c 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit2/win/ResizeViewWhileHidden.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit2/win/ResizeViewWhileHidden.cpp @@ -55,7 +55,7 @@ static void flushMessages(WKPageRef page) setPageLoaderClient(page); - WKPageLoadURL(page, Util::adoptWK(Util::createURLForResource("simple", "html")).get()); + WKPageLoadURL(page, adoptWK(Util::createURLForResource("simple", "html")).get()); Util::run(&didFinishLoad); didFinishLoad = false; diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/win/TranslateMessageGeneratesWMChar.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/win/TranslateMessageGeneratesWMChar.cpp new file mode 100644 index 0000000..66b1291 --- /dev/null +++ b/Tools/TestWebKitAPI/Tests/WebKit2/win/TranslateMessageGeneratesWMChar.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2011 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 + +namespace TestWebKitAPI { + +static bool didSeeWMChar; +static bool didNotHandleKeyEventCalled; + +static void didNotHandleKeyEventCallback(WKPageRef, WKNativeEventPtr event, const void*) +{ + if (event->message != WM_KEYDOWN) + return; + + // Don't call TranslateMessage() here so a WM_CHAR isn't generated. + didNotHandleKeyEventCalled = true; +} + +static void runAndWatchForWMChar(bool* done) +{ + while (!*done) { + MSG msg; + BOOL result = ::GetMessageW(&msg, 0, 0, 0); + if (!result || result == -1) + break; + + if (msg.message == WM_CHAR) + didSeeWMChar = true; + + if (Util::shouldTranslateMessage(msg)) + ::TranslateMessage(&msg); + + ::DispatchMessage(&msg); + } +} + +TEST(WebKit2, TranslateMessageGeneratesWMChar) +{ + WKRetainPtr context(AdoptWK, WKContextCreate()); + PlatformWebView webView(context.get()); + + webView.simulateAKeyDown(); + + // WebKit should call TranslateMessage() on the WM_KEYDOWN message to generate the WM_CHAR message. + runAndWatchForWMChar(&didSeeWMChar); + + didSeeWMChar = false; + + WKPageUIClient uiClient; + memset(&uiClient, 0, sizeof(uiClient)); + + uiClient.didNotHandleKeyEvent = didNotHandleKeyEventCallback; + WKPageSetPageUIClient(webView.page(), &uiClient); + + webView.simulateAKeyDown(); + + runAndWatchForWMChar(&didNotHandleKeyEventCalled); + + // WebKit should not have called TranslateMessage() on the WM_KEYDOWN message since we installed a didNotHandleKeyEvent callback. + TEST_ASSERT(!didSeeWMChar); +} + +} // namespace TestWebKitAPI -- cgit v1.1