Title: [122648] trunk
Revision
122648
Author
[email protected]
Date
2012-07-13 17:33:28 -0700 (Fri, 13 Jul 2012)

Log Message

Fix for WebContext::getWebCoreStatistics() causes crash if no m_process
https://bugs.webkit.org/show_bug.cgi?id=91116

.:

Patch by Josh Hawn <[email protected]> on 2012-07-12
Reviewed by Simon Fraser.

* Source/WebKit2/UIProcess/WebContext.cpp:
  WebContext::getWebCoreStatistics():
        Now invalidates callback if no m_process.

Tools:

Patch by Josh Hawn <[email protected]> on 2012-07-13
Reviewed by Simon Fraser.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
    Added new test file.
* TestWebKitAPI/Tests/WebKit2/WebCoreStatisticsWithNoWebProcess.cpp: Added.
(TestWebKitAPI::wkContextGetStatisticsCallback):
    Tests that callback function receives an error.
(TestWebKitAPI::TEST):
    Creates a dummy web context object (no web process).
    Calls WKContextGetStatistics with the web context and test callback.
    The test callback should get an expected error.

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (122647 => 122648)


--- trunk/ChangeLog	2012-07-14 00:15:43 UTC (rev 122647)
+++ trunk/ChangeLog	2012-07-14 00:33:28 UTC (rev 122648)
@@ -1,3 +1,14 @@
+2012-07-12 Josh Hawn <[email protected]>
+
+        Fix for WebContext::getWebCoreStatistics() causes crash if no m_process
+        https://bugs.webkit.org/show_bug.cgi?id=91116
+
+        Reviewed by Simon Fraser.
+
+        * Source/WebKit2/UIProcess/WebContext.cpp:
+          WebContext::getWebCoreStatistics():
+                Now invalidates callback if no m_process.
+
 2012-07-13  Thiago Marcos P. Santos  <[email protected]>
 
         [CMake] Proper handling of ENABLE_API_TESTS build option

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (122647 => 122648)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-07-14 00:15:43 UTC (rev 122647)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-07-14 00:33:28 UTC (rev 122648)
@@ -969,9 +969,12 @@
 #endif
 }
 
-void WebContext::getWebCoreStatistics(PassRefPtr<DictionaryCallback> prpCallback)
+void WebContext::getWebCoreStatistics(PassRefPtr<DictionaryCallback> callback)
 {
-    RefPtr<DictionaryCallback> callback = prpCallback;
+    if (!m_process) {
+        callback->invalidate();
+        return;
+    }
     
     uint64_t callbackID = callback->callbackID();
     m_dictionaryCallbacks.set(callbackID, callback.get());

Modified: trunk/Tools/ChangeLog (122647 => 122648)


--- trunk/Tools/ChangeLog	2012-07-14 00:15:43 UTC (rev 122647)
+++ trunk/Tools/ChangeLog	2012-07-14 00:33:28 UTC (rev 122648)
@@ -1,3 +1,20 @@
+2012-07-13  Josh Hawn  <[email protected]>
+
+        Fix for WebContext::getWebCoreStatistics() causes crash if no m_process
+        https://bugs.webkit.org/show_bug.cgi?id=91116
+
+        Reviewed by Simon Fraser.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+            Added new test file.
+        * TestWebKitAPI/Tests/WebKit2/WebCoreStatisticsWithNoWebProcess.cpp: Added.
+        (TestWebKitAPI::wkContextGetStatisticsCallback):
+            Tests that callback function receives an error.
+        (TestWebKitAPI::TEST):
+            Creates a dummy web context object (no web process).
+            Calls WKContextGetStatistics with the web context and test callback.
+            The test callback should get an expected error.
+
 2012-07-13  Dirk Pranke  <[email protected]>
 
         test-webkitpy: move printing-related code out of the runner

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (122647 => 122648)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2012-07-14 00:15:43 UTC (rev 122647)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2012-07-14 00:33:28 UTC (rev 122648)
@@ -9,6 +9,7 @@
 /* Begin PBXBuildFile section */
 		0BCD833514857CE400EA2003 /* HashMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BCD833414857CE400EA2003 /* HashMap.cpp */; };
 		0BCD856A1485C98B00EA2003 /* TemporaryChange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BCD85691485C98B00EA2003 /* TemporaryChange.cpp */; };
+		0F17BBD615AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F17BBD415AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp */; };
 		0FC6C4CC141027E0005B7F0C /* RedBlackTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC6C4CB141027E0005B7F0C /* RedBlackTree.cpp */; };
 		0FC6C4CF141034AD005B7F0C /* MetaAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC6C4CE141034AD005B7F0C /* MetaAllocator.cpp */; };
 		1A02C84F125D4A8400E3F4BD /* Find.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A02C84E125D4A8400E3F4BD /* Find.cpp */; };
@@ -229,6 +230,7 @@
 /* Begin PBXFileReference section */
 		0BCD833414857CE400EA2003 /* HashMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HashMap.cpp; path = WTF/HashMap.cpp; sourceTree = "<group>"; };
 		0BCD85691485C98B00EA2003 /* TemporaryChange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TemporaryChange.cpp; path = WTF/TemporaryChange.cpp; sourceTree = "<group>"; };
+		0F17BBD415AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreStatisticsWithNoWebProcess.cpp; sourceTree = "<group>"; };
 		0FC6C4CB141027E0005B7F0C /* RedBlackTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RedBlackTree.cpp; path = WTF/RedBlackTree.cpp; sourceTree = "<group>"; };
 		0FC6C4CE141034AD005B7F0C /* MetaAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MetaAllocator.cpp; path = WTF/MetaAllocator.cpp; sourceTree = "<group>"; };
 		1A02C84B125D4A5E00E3F4BD /* find.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = find.html; sourceTree = "<group>"; };
@@ -596,6 +598,7 @@
 				BC7B619A1299FE9E00D174A4 /* WKPreferences.cpp */,
 				BC90995D12567BC100083756 /* WKString.cpp */,
 				BC9099931256ACF100083756 /* WKStringJSString.cpp */,
+				0F17BBD415AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp */,
 			);
 			path = WebKit2;
 			sourceTree = "<group>";
@@ -929,6 +932,7 @@
 				26DF5A5E15A29BAA003689C2 /* CancelLoadFromResourceLoadDelegate.mm in Sources */,
 				F660AA0D15A5F061003A1243 /* GetInjectedBundleInitializationUserDataCallback.cpp in Sources */,
 				F660AA1315A619C9003A1243 /* InjectedBundleInitializationUserDataCallbackWins.cpp in Sources */,
+				0F17BBD615AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/WebCoreStatisticsWithNoWebProcess.cpp (0 => 122648)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/WebCoreStatisticsWithNoWebProcess.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/WebCoreStatisticsWithNoWebProcess.cpp	2012-07-14 00:33:28 UTC (rev 122648)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 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 "config.h"
+#include "PlatformUtilities.h"
+#include "test.h"
+
+namespace TestWebKitAPI {
+
+static bool done;
+
+// Callback for WKContextGetStatistics.
+static void wkContextGetStatisticsCallback(WKDictionaryRef statistics, WKErrorRef error, void* functionContext)
+{
+    EXPECT_NOT_NULL(error);
+    done = true;
+}
+
+TEST(WebKit2, WebCoreStatisticsWithNoWebProcess)
+{
+    WKRetainPtr<WKContextRef> context = adoptWK(WKContextCreate());
+    
+    WKContextGetStatistics(context.get(), 0, wkContextGetStatisticsCallback);
+    
+    Util::run(&done);
+}
+
+} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to