[WK2] Write a test to simulate crashed WebProcess followed by Window resize
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Feb 2013 00:22:08 +0000 (00:22 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Feb 2013 00:22:08 +0000 (00:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109842

Patch by Adenilson Cavalcanti <cavalcantii@gmail.com> on 2013-02-15
Reviewed by Benjamin Poulain.

This new test will kill WebProcess, followed by next resizing the Window. It helps to
identify if the port is testing for WebPageProxy data members state (e.g. DrawingArea, Frames)
before making calls into them.

* TestWebKitAPI/GNUmakefile.am:
* TestWebKitAPI/PlatformEfl.cmake:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/ResizeWindowAfterCrash.cpp: Added.
(TestWebKitAPI):
(TestWebKitAPI::didFinishLoad):
(TestWebKitAPI::didCrash):
(TestWebKitAPI::TEST):

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

Tools/ChangeLog
Tools/TestWebKitAPI/GNUmakefile.am
Tools/TestWebKitAPI/PlatformEfl.cmake
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/ResizeWindowAfterCrash.cpp [new file with mode: 0644]

index 166139f..a86beb9 100644 (file)
@@ -1,3 +1,23 @@
+2013-02-15  Adenilson Cavalcanti  <cavalcantii@gmail.com>
+
+        [WK2] Write a test to simulate crashed WebProcess followed by Window resize
+        https://bugs.webkit.org/show_bug.cgi?id=109842
+
+        Reviewed by Benjamin Poulain.
+
+        This new test will kill WebProcess, followed by next resizing the Window. It helps to
+        identify if the port is testing for WebPageProxy data members state (e.g. DrawingArea, Frames)
+        before making calls into them.
+
+        * TestWebKitAPI/GNUmakefile.am:
+        * TestWebKitAPI/PlatformEfl.cmake:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/ResizeWindowAfterCrash.cpp: Added.
+        (TestWebKitAPI):
+        (TestWebKitAPI::didFinishLoad):
+        (TestWebKitAPI::didCrash):
+        (TestWebKitAPI::TEST):
+
 2013-02-15  Christophe Dumez  <ch.dumez@sisa.samsung.com>
 
         Add CString operators for comparison with const char*
index aa88133..7d765e4 100644 (file)
@@ -153,6 +153,7 @@ Programs_TestWebKitAPI_TestWebKit2_SOURCES = \
        Tools/TestWebKitAPI/Tests/WebKit2/LoadCanceledNoServerRedirectCallback.cpp \
        Tools/TestWebKitAPI/Tests/WebKit2/MouseMoveAfterCrash.cpp \
        Tools/TestWebKitAPI/Tests/WebKit2/ReloadPageAfterCrash.cpp \
+       Tools/TestWebKitAPI/Tests/WebKit2/ResizeWindowAfterCrash.cpp \
        Tools/TestWebKitAPI/Tests/WebKit2/NewFirstVisuallyNonEmptyLayout.cpp \
        Tools/TestWebKitAPI/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutFails.cpp \
        Tools/TestWebKitAPI/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutForImages.cpp \
index d8f5a78..0f467e1 100644 (file)
@@ -70,6 +70,7 @@ set(test_webkit2_api_BINARIES
     LoadCanceledNoServerRedirectCallback
     MouseMoveAfterCrash
     ReloadPageAfterCrash
+    ResizeWindowAfterCrash
     NewFirstVisuallyNonEmptyLayout
     NewFirstVisuallyNonEmptyLayoutFails
     NewFirstVisuallyNonEmptyLayoutForImages
index dc3ba60..3e2bd02 100644 (file)
@@ -88,6 +88,7 @@
                76E182DD1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76E182DC1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp */; };
                76E182DF154767E600F1FADD /* auto-submitting-form.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 76E182DE15475A8300F1FADD /* auto-submitting-form.html */; };
                81B50193140F232300D9EB58 /* StringBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81B50192140F232300D9EB58 /* StringBuilder.cpp */; };
+               8A2C750E16CED9550024F352 /* ResizeWindowAfterCrash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A2C750D16CED9550024F352 /* ResizeWindowAfterCrash.cpp */; };
                8A3AF93B16C9ED2700D248C1 /* ReloadPageAfterCrash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A3AF93A16C9ED2700D248C1 /* ReloadPageAfterCrash.cpp */; };
                930AD402150698D00067970F /* lots-of-text.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 930AD401150698B30067970F /* lots-of-text.html */; };
                9318778915EEC57700A9CCE3 /* NewFirstVisuallyNonEmptyLayoutForImages.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93AF4ECA1506F035007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages.cpp */; };
                76E182DC1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillSendSubmitEvent_Bundle.cpp; sourceTree = "<group>"; };
                76E182DE15475A8300F1FADD /* auto-submitting-form.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "auto-submitting-form.html"; sourceTree = "<group>"; };
                81B50192140F232300D9EB58 /* StringBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringBuilder.cpp; path = WTF/StringBuilder.cpp; sourceTree = "<group>"; };
+               8A2C750D16CED9550024F352 /* ResizeWindowAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResizeWindowAfterCrash.cpp; sourceTree = "<group>"; };
                8A3AF93A16C9ED2700D248C1 /* ReloadPageAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReloadPageAfterCrash.cpp; sourceTree = "<group>"; };
                8DD76FA10486AA7600D96B5E /* TestWebKitAPI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestWebKitAPI; sourceTree = BUILT_PRODUCTS_DIR; };
                930AD401150698B30067970F /* lots-of-text.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "lots-of-text.html"; sourceTree = "<group>"; };
                                333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */,
                                F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */,
                                8A3AF93A16C9ED2700D248C1 /* ReloadPageAfterCrash.cpp */,
+                               8A2C750D16CED9550024F352 /* ResizeWindowAfterCrash.cpp */,
                                C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */,
                                C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */,
                                C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */,
                                F6FDDDD314241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */,
                                0FC6C4CC141027E0005B7F0C /* RedBlackTree.cpp in Sources */,
                                8A3AF93B16C9ED2700D248C1 /* ReloadPageAfterCrash.cpp in Sources */,
+                               8A2C750E16CED9550024F352 /* ResizeWindowAfterCrash.cpp in Sources */,
                                3722C8691461E03E00C45D00 /* RenderedImageFromDOMRange.mm in Sources */,
                                C0BD669D131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp in Sources */,
                                C0ADBE8312FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/ResizeWindowAfterCrash.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/ResizeWindowAfterCrash.cpp
new file mode 100644 (file)
index 0000000..1af639d
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2013 Adenilson Cavalcanti <cavalcantii@gmail.com>
+ *
+ * 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 "config.h"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+#include <WebKit2/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+struct TestStatesData {
+    TestStatesData(WKContextRef context)
+        : webView(context)
+        , firstLoad(false)
+        , resizeAfterCrash(false)
+    {
+    }
+
+    PlatformWebView webView;
+    bool firstLoad;
+    bool resizeAfterCrash;
+};
+
+static void didFinishLoad(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+    TestStatesData* states = const_cast<TestStatesData*>(static_cast<const TestStatesData*>(clientInfo));
+    if (!states->firstLoad) {
+        // Loading a blank page worked, next we will kill WebProcess.
+        states->firstLoad = true;
+        return;
+    }
+
+    EXPECT_FALSE(states->resizeAfterCrash);
+    states->resizeAfterCrash = true;
+}
+
+static void didCrash(WKPageRef page, const void* clientInfo)
+{
+    TestStatesData* states = const_cast<TestStatesData*>(static_cast<const TestStatesData*>(clientInfo));
+    EXPECT_TRUE(states->firstLoad);
+    // Resize should work after WebProcess was terminated, unless
+    // the port's View is accessing nulled WebProcess related data,
+    // which would cause a crash.
+    states->webView.resizeTo(100, 200);
+    states->webView.resizeTo(300, 400);
+
+    WKPageReload(page);
+}
+
+TEST(WebKit2, ResizeWindowAfterCrash)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+    TestStatesData states(context.get());
+
+    WKPageLoaderClient loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+    loaderClient.clientInfo = &states;
+    loaderClient.didFinishLoadForFrame = didFinishLoad;
+    loaderClient.processDidCrash = didCrash;
+    WKPageSetPageLoaderClient(states.webView.page(), &loaderClient);
+
+    WKRetainPtr<WKURLRef> url = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
+    // Load a blank page and next kills WebProcess.
+    WKPageLoadURL(states.webView.page(), url.get());
+    Util::run(&states.firstLoad);
+    WKPageTerminate(states.webView.page());
+
+    // Let's try load a page and see what happens.
+    WKPageLoadURL(states.webView.page(), url.get());
+    Util::run(&states.resizeAfterCrash);
+}
+
+} // namespace TestWebKitAPI