Title: [119280] trunk
Revision
119280
Author
[email protected]
Date
2012-06-01 14:26:11 -0700 (Fri, 01 Jun 2012)

Log Message

WebFrame::_stringByEvaluatingJavaScriptFromString methods don't handle nil string
https://bugs.webkit.org/show_bug.cgi?id=88109

Reviewed by Geoffrey Garen.

Source/WebKit/mac: 

Added short circuit return when the NSString to evaluate is nil.

* WebView/WebFrame.mm:
(-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
(-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):

Tools: 

Additional test case.

* TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (119279 => 119280)


--- trunk/Source/WebKit/mac/ChangeLog	2012-06-01 21:04:43 UTC (rev 119279)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-06-01 21:26:11 UTC (rev 119280)
@@ -1,3 +1,16 @@
+2012-06-01  Michael Saboff  <[email protected]>
+
+        WebFrame::_stringByEvaluatingJavaScriptFromString methods don't handle nil string
+        https://bugs.webkit.org/show_bug.cgi?id=88109
+
+        Reviewed by Geoffrey Garen.
+
+        Added short circuit return when the NSString to evaluate is nil.
+
+        * WebView/WebFrame.mm:
+        (-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
+        (-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):
+
 2012-05-31  Hajime Morrita  <[email protected]>
 
         REGRESSION(r117572): editing/spelling/spellcheck-async-remove-frame.html crashes on Mac

Modified: trunk/Source/WebKit/mac/WebView/WebFrame.mm (119279 => 119280)


--- trunk/Source/WebKit/mac/WebView/WebFrame.mm	2012-06-01 21:04:43 UTC (rev 119279)
+++ trunk/Source/WebKit/mac/WebView/WebFrame.mm	2012-06-01 21:26:11 UTC (rev 119280)
@@ -580,6 +580,9 @@
 
 - (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string forceUserGesture:(BOOL)forceUserGesture
 {
+    if (!string)
+        return @"";
+
     ASSERT(_private->coreFrame->document());
     RetainPtr<WebFrame> protect(self); // Executing arbitrary _javascript_ can destroy the frame.
     
@@ -1103,6 +1106,9 @@
 
 - (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string withGlobalObject:(JSObjectRef)globalObjectRef inScriptWorld:(WebScriptWorld *)world
 {
+    if (!string)
+        return @"";
+
     // Start off with some guess at a frame and a global object, we'll try to do better...!
     JSDOMWindow* anyWorldGlobalObject = _private->coreFrame->script()->globalObject(mainThreadNormalWorld());
 

Modified: trunk/Tools/ChangeLog (119279 => 119280)


--- trunk/Tools/ChangeLog	2012-06-01 21:04:43 UTC (rev 119279)
+++ trunk/Tools/ChangeLog	2012-06-01 21:26:11 UTC (rev 119280)
@@ -1,3 +1,15 @@
+2012-06-01  Michael Saboff  <[email protected]>
+
+        WebFrame::_stringByEvaluatingJavaScriptFromString methods don't handle nil string
+        https://bugs.webkit.org/show_bug.cgi?id=88109
+
+        Reviewed by Geoffrey Garen.
+
+        Additional test case.
+
+        * TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm:
+        (TestWebKitAPI::TEST):
+
 2012-06-01  Simon Hausmann  <[email protected]>
 
         [Qt] Use -Werror only in developer builds

Modified: trunk/Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm (119279 => 119280)


--- trunk/Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm	2012-06-01 21:04:43 UTC (rev 119279)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm	2012-06-01 21:26:11 UTC (rev 119280)
@@ -55,6 +55,10 @@
 
     RetainPtr<WebView> webView (AdoptNS, [[WebView alloc] initWithFrame:NSZeroRect frameName:@"" groupName:@""]);
 
+    // Test a nil string
+    NSString *result = [webView.get() stringByEvaluatingJavaScriptFromString:nil];
+    EXPECT_WK_STREQ(@"", result);
+
     for (id _expression_ in expressions.get()) {
         NSString *expectedResult = [expressions.get() objectForKey:_expression_];
         NSString *result = [webView.get() stringByEvaluatingJavaScriptFromString:_expression_];
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to