[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 14:50:33 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit d5b765b9fa644ffddf891b07c855c1419a78075c
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 21 21:46:10 2010 +0000

    Crash evaluating JavaScript string that throws an exception
    https://bugs.webkit.org/show_bug.cgi?id=48092
    <rdar://problem/8487657>
    
    Reviewed by Adam Roben.
    
    WebKit2:
    
    * UIProcess/WebProcessProxy.cpp:
    (WebKit::WebProcessProxy::sendMessage):
    m_connection can be null here; just return false if that is the case.
    
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::runJavaScriptInMainFrame):
    If the JSValue returned is null we just send along a null string.
    
    WebKitTools:
    
    Add a test that evaluates a JavaScript string that throws an exception and check that
    the callback is called.
    
    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
    * TestWebKitAPI/Tests/WebKit2/EvaluateJavaScript.cpp: Added.
    (TestWebKitAPI::didRunJavaScript):
    (TestWebKitAPI::WebKit2_EvaluateJavaScript):
    * TestWebKitAPI/win/TestWebKitAPI.vcproj:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70267 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 2102d2b..12dc802 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,19 @@
+2010-10-21  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Adam Roben.
+
+        Crash evaluating JavaScript string that throws an exception
+        https://bugs.webkit.org/show_bug.cgi?id=48092
+        <rdar://problem/8487657>
+
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::sendMessage):
+        m_connection can be null here; just return false if that is the case.
+    
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::runJavaScriptInMainFrame):
+        If the JSValue returned is null we just send along a null string.
+
 2010-10-21  Adam Roben  <aroben at apple.com>
 
         Invalidate the plugin's HWND when NPN_InvalidateRect is called
diff --git a/WebKit2/UIProcess/WebProcessProxy.cpp b/WebKit2/UIProcess/WebProcessProxy.cpp
index 3b3a165..3c81287 100644
--- a/WebKit2/UIProcess/WebProcessProxy.cpp
+++ b/WebKit2/UIProcess/WebProcessProxy.cpp
@@ -105,7 +105,11 @@ bool WebProcessProxy::sendMessage(CoreIPC::MessageID messageID, PassOwnPtr<CoreI
         m_pendingMessages.append(CoreIPC::Connection::OutgoingMessage(messageID, arguments));
         return true;
     }
-    
+
+    // If the web process has exited, m_connection will be null here.
+    if (!m_connection)
+        return false;
+
     return m_connection->sendMessage(messageID, arguments);
 }
 
diff --git a/WebKit2/WebProcess/WebPage/WebPage.cpp b/WebKit2/WebProcess/WebPage/WebPage.cpp
index 6c074bf..f5ebf75 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -682,7 +682,9 @@ void WebPage::runJavaScriptInMainFrame(const String& script, uint64_t callbackID
 
     JSLock lock(SilenceAssertionsOnly);
     JSValue resultValue = m_mainFrame->coreFrame()->script()->executeScript(script, true).jsValue();
-    String resultString = ustringToString(resultValue.toString(m_mainFrame->coreFrame()->script()->globalObject(mainThreadNormalWorld())->globalExec()));
+    String resultString;
+    if (resultValue)
+        resultString = ustringToString(resultValue.toString(m_mainFrame->coreFrame()->script()->globalObject(mainThreadNormalWorld())->globalExec()));
 
     WebProcess::shared().connection()->send(Messages::WebPageProxy::DidRunJavaScriptInMainFrame(resultString, callbackID), m_pageID);
 }
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index e3fb78b..36ccd4e 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,20 @@
+2010-10-21  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Adam Roben.
+
+        Crash evaluating JavaScript string that throws an exception
+        https://bugs.webkit.org/show_bug.cgi?id=48092
+        <rdar://problem/8487657>
+
+        Add a test that evaluates a JavaScript string that throws an exception and check that 
+        the callback is called.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/EvaluateJavaScript.cpp: Added.
+        (TestWebKitAPI::didRunJavaScript):
+        (TestWebKitAPI::WebKit2_EvaluateJavaScript):
+        * TestWebKitAPI/win/TestWebKitAPI.vcproj:
+
 2010-10-21  Adam Roben  <aroben at apple.com>
 
         Test that the plugin's HWND is invalidated when NPN_InvalidateRect is
diff --git a/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
index 0e2fd23..31ef913 100644
--- a/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
+++ b/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
@@ -9,6 +9,7 @@
 /* Begin PBXBuildFile section */
 		1A02C84F125D4A8400E3F4BD /* Find.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A02C84E125D4A8400E3F4BD /* Find.cpp */; };
 		1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1A02C84B125D4A5E00E3F4BD /* find.html */; };
+		1A5FEFDD1270E2A3000E2921 /* EvaluateJavaScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5FEFDC1270E2A3000E2921 /* EvaluateJavaScript.cpp */; };
 		BC131885117114B600B69727 /* PlatformUtilitiesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC131884117114B600B69727 /* PlatformUtilitiesMac.mm */; };
 		BC131A9B1171316900B69727 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC131A9A1171316900B69727 /* main.mm */; };
 		BC131AA9117131FC00B69727 /* TestsController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC131AA8117131FC00B69727 /* TestsController.cpp */; };
@@ -81,6 +82,7 @@
 /* Begin PBXFileReference section */
 		1A02C84B125D4A5E00E3F4BD /* find.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = find.html; sourceTree = "<group>"; };
 		1A02C84E125D4A8400E3F4BD /* Find.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Find.cpp; sourceTree = "<group>"; };
+		1A5FEFDC1270E2A3000E2921 /* EvaluateJavaScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EvaluateJavaScript.cpp; sourceTree = "<group>"; };
 		8DD76FA10486AA7600D96B5E /* TestWebKitAPI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestWebKitAPI; sourceTree = BUILT_PRODUCTS_DIR; };
 		BC131883117114A800B69727 /* PlatformUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformUtilities.h; sourceTree = "<group>"; };
 		BC131884117114B600B69727 /* PlatformUtilitiesMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformUtilitiesMac.mm; sourceTree = "<group>"; };
@@ -223,6 +225,7 @@
 			isa = PBXGroup;
 			children = (
 				BC90977B125571AE00083756 /* Resources */,
+				1A5FEFDC1270E2A3000E2921 /* EvaluateJavaScript.cpp */,
 				1A02C84E125D4A8400E3F4BD /* Find.cpp */,
 				BCBD370F125AA2EB00D2C29F /* FrameMIMETypeHTML.cpp */,
 				BCBD3760125ABCFE00D2C29F /* FrameMIMETypePNG.cpp */,
@@ -373,6 +376,7 @@
 				BC575AAD126E83B9006F0F12 /* InjectedBundleBasic.cpp in Sources */,
 				BC575BC0126F5752006F0F12 /* PlatformUtilities.cpp in Sources */,
 				BCB68040126FBFE100642A61 /* DocumentStartUserScriptAlertCrash.cpp in Sources */,
+				1A5FEFDD1270E2A3000E2921 /* EvaluateJavaScript.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/EvaluateJavaScript.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/EvaluateJavaScript.cpp
new file mode 100644
index 0000000..bbdece3
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/Tests/WebKit2/EvaluateJavaScript.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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/win/TestWebKitAPI.vcproj b/WebKitTools/TestWebKitAPI/win/TestWebKitAPI.vcproj
index cba32cf..d1c4f0f 100644
--- a/WebKitTools/TestWebKitAPI/win/TestWebKitAPI.vcproj
+++ b/WebKitTools/TestWebKitAPI/win/TestWebKitAPI.vcproj
@@ -417,6 +417,10 @@
 				Name="WebKit2"
 				>
 				<File
+					RelativePath="..\Tests\WebKit2\EvaluateJavaScript.cpp"
+					>
+				</File>
+				<File
 					RelativePath="..\Tests\WebKit2\FailedLoad.cpp"
 					>
 				</File>

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list