[EFL][WK2]: Fix WKViewClientWebProcessCallbacks WK2 API test
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Apr 2013 16:12:04 +0000 (16:12 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Apr 2013 16:12:04 +0000 (16:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114850

Patch by Sergio Correia <sergio.correia@openbossa.org> on 2013-04-24
Reviewed by Andreas Kling.

Revision r148312 fixed WebPageProxy cleanup and also changed the process
termination semantics when requested by the user so that a client is not
notified of a crash anymore, since there was no crash anyway.

That change broke WKViewClientWebProcessCallbacks WK2 API test, since it
relied on being notified of a crash after calling WKPageTerminate(). As
a result of not being notified of such non-existent crash, the test would
timeout right after making the terminate call.

This patch adds an InjectedBundle to be used for simulating a crash, by
calling abort() upon receiving a "Crash" message, and thus we are able to
keep testing the crash callback.

This patch also re-enables the WKViewClientWebProcessCallbacks test, which
had been disabled in revisions r148858 and r148855, since it was failing.

* TestWebKitAPI/PlatformEfl.cmake:
* TestWebKitAPI/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks_Bundle.cpp: Added.
(TestWebKitAPI):
(WKViewClientWebProcessCallbacksTest):
(TestWebKitAPI::WKViewClientWebProcessCallbacksTest::WKViewClientWebProcessCallbacksTest):
(TestWebKitAPI::WKViewClientWebProcessCallbacksTest::didReceiveMessage):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@149045 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/TestWebKitAPI/PlatformEfl.cmake
Tools/TestWebKitAPI/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks.cpp
Tools/TestWebKitAPI/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks_Bundle.cpp [new file with mode: 0644]

index 0c6bdba..518ef42 100644 (file)
@@ -1,3 +1,35 @@
+2013-04-24  Sergio Correia  <sergio.correia@openbossa.org>
+
+        [EFL][WK2]: Fix WKViewClientWebProcessCallbacks WK2 API test
+        https://bugs.webkit.org/show_bug.cgi?id=114850
+
+        Reviewed by Andreas Kling.
+
+        Revision r148312 fixed WebPageProxy cleanup and also changed the process
+        termination semantics when requested by the user so that a client is not
+        notified of a crash anymore, since there was no crash anyway.
+
+        That change broke WKViewClientWebProcessCallbacks WK2 API test, since it
+        relied on being notified of a crash after calling WKPageTerminate(). As
+        a result of not being notified of such non-existent crash, the test would
+        timeout right after making the terminate call.
+
+        This patch adds an InjectedBundle to be used for simulating a crash, by
+        calling abort() upon receiving a "Crash" message, and thus we are able to
+        keep testing the crash callback.
+
+        This patch also re-enables the WKViewClientWebProcessCallbacks test, which
+        had been disabled in revisions r148858 and r148855, since it was failing.
+
+        * TestWebKitAPI/PlatformEfl.cmake:
+        * TestWebKitAPI/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks.cpp:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks_Bundle.cpp: Added.
+        (TestWebKitAPI):
+        (WKViewClientWebProcessCallbacksTest):
+        (TestWebKitAPI::WKViewClientWebProcessCallbacksTest::WKViewClientWebProcessCallbacksTest):
+        (TestWebKitAPI::WKViewClientWebProcessCallbacksTest::didReceiveMessage):
+
 2013-04-24  Christophe Dumez  <ch.dumez@sisa.samsung.com>
 
         [EFL][WK2] WebKitTestRunner failures due to IconDatabase assertions
index d038a3e..4410385 100644 (file)
@@ -51,6 +51,11 @@ set(test_webcore_BINARIES
     KURL
 )
 
+# In here we list the bundles that are used by our specific WK2 API Tests
+list(APPEND bundle_harness_SOURCES
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks_Bundle.cpp
+)
+
 set(test_webkit2_api_BINARIES
     AboutBlankLoad
     CookieManager
@@ -88,6 +93,7 @@ set(test_webkit2_api_BINARIES
     WKStringJSString
     WKURL
     WillSendSubmitEvent
+    efl/WKViewClientWebProcessCallbacks
 )
 
 # Seccomp filters is an internal API and its symbols
@@ -107,7 +113,6 @@ set(test_webkit2_api_fail_BINARIES
     RestoreSessionStateContainingFormData
     ShouldGoToBackForwardListItem
     WKPageGetScaleFactorNotZero
-    #efl/WKViewClientWebProcessCallbacks
 )
 
 # Tests disabled because of missing features on the test harness:
index 450dcf1..552b38c 100644 (file)
@@ -101,7 +101,7 @@ static void setViewClient(WKViewRef view, const void* clientInfo)
 
 TEST(WebKit2, WKViewClientWebProcessCallbacks)
 {
-    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+    WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("WKViewClientWebProcessCallbacksTest"));
     WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html"));
 
     PlatformWebView view(context.get());
@@ -115,7 +115,7 @@ TEST(WebKit2, WKViewClientWebProcessCallbacks)
     WKPageLoadURL(view.page(), url.get());
     Util::run(&states.didFinishLoad);
 
-    WKPageTerminate(view.page());
+    WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("Crash").get(), 0);
     Util::run(&states.didCrash);
 
     WKPageReload(view.page());
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks_Bundle.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks_Bundle.cpp
new file mode 100644 (file)
index 0000000..83a95c0
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT HOLDERS OR
+ * 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 "config.h"
+#include "InjectedBundleTest.h"
+#include <WebKit2/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+class WKViewClientWebProcessCallbacksTest : public InjectedBundleTest {
+public:
+    WKViewClientWebProcessCallbacksTest(const std::string& identifier);
+
+private:
+    virtual void didReceiveMessage(WKBundleRef, WKStringRef messageName, WKTypeRef messageBody);
+};
+
+static InjectedBundleTest::Register<WKViewClientWebProcessCallbacksTest> registrar("WKViewClientWebProcessCallbacksTest");
+
+WKViewClientWebProcessCallbacksTest::WKViewClientWebProcessCallbacksTest(const std::string& identifier)
+    : InjectedBundleTest(identifier)
+{
+}
+
+void WKViewClientWebProcessCallbacksTest::didReceiveMessage(WKBundleRef, WKStringRef messageName, WKTypeRef)
+{
+    if (!WKStringIsEqualToUTF8CString(messageName, "Crash"))
+        return;
+
+    // Simulating a crash
+    abort();
+}
+
+} // namespace TestWebKitAPI