Add form delegate method that's invoked right before sending a submit event to a...
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Apr 2013 22:28:34 +0000 (22:28 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Apr 2013 22:28:34 +0000 (22:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114575

Reviewed by Dan Bernstein.

Source/WebCore:

* WebCore.exp.in:
Export a symbol.

* WebCore.xcodeproj/project.pbxproj:
Make DOMHTMLFormElementInternal.h a private header.

Source/WebKit/mac:

* MigrateHeaders.make:
Copy DOMHTMLFormElementInternal.h over to WebKit.

* WebCoreSupport/WebFrameLoaderClient.mm:
(makeFormFieldValuesDictionary):
New helper function that returns the values of a form in dictionary form.

(WebFrameLoaderClient::dispatchWillSendSubmitEvent):
Call the right delegate method.

(WebFrameLoaderClient::dispatchWillSubmitForm):
Use the helper function.

* WebView/WebDelegateImplementationCaching.h:
* WebView/WebDelegateImplementationCaching.mm:
(CallFormDelegate):
Add another overload.

* WebView/WebFormDelegate.h:
* WebView/WebFormDelegate.m:
(-[WebFormDelegate willSendSubmitEventToForm:inFrame:withValues:]):
Add a default implementation.

Tools:

Add a test.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/WillSendSubmitEvent.mm: Added.
(-[FormDelegate willSendSubmitEventToForm:inFrame:withValues:]):
(TestWebKitAPI):
(TestWebKitAPI::TEST):

* TestWebKitAPI/mac/PlatformUtilitiesMac.mm:
(TestWebKitAPI::Util::toSTD):
Don't crash when a null NSString is passed to toSTD.

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/MigrateHeaders.make
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit/mac/WebView/WebDelegateImplementationCaching.h
Source/WebKit/mac/WebView/WebDelegateImplementationCaching.mm
Source/WebKit/mac/WebView/WebFormDelegate.h
Source/WebKit/mac/WebView/WebFormDelegate.m
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/mac/WillSendSubmitEvent.mm [new file with mode: 0644]
Tools/TestWebKitAPI/mac/PlatformUtilitiesMac.mm

index 45c2e89..e86908f 100644 (file)
@@ -1,3 +1,16 @@
+2013-04-13  Anders Carlsson  <andersca@apple.com>
+
+        Add form delegate method that's invoked right before sending a submit event to a form element
+        https://bugs.webkit.org/show_bug.cgi?id=114575
+
+        Reviewed by Dan Bernstein.
+
+        * WebCore.exp.in:
+        Export a symbol.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Make DOMHTMLFormElementInternal.h a private header.
+
 2013-03-04  Robert Hogan  <robert@webkit.org>
 
         Whitespace between nowrap elements ignored after collapsed trailing space in a text run
index c151efe..04244ab 100644 (file)
@@ -47,6 +47,7 @@ _WebCoreObjCFinalizeOnMainThread
 _WebCoreObjCScheduleDeallocateOnMainThread
 __Z26ReportBlockedObjCExceptionP11NSException
 __Z3kitPN7WebCore11HTMLElementE
+__Z3kitPN7WebCore15HTMLFormElementE
 __Z3kitPN7WebCore16DocumentFragmentE
 __Z3kitPN7WebCore16HTMLInputElementE
 __Z3kitPN7WebCore19CSSStyleDeclarationE
index cf76a08..3850ba9 100644 (file)
                85E711A70AC5D5350053270F /* DOMHTMLElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E711580AC5D5340053270F /* DOMHTMLElementInternal.h */; settings = {ATTRIBUTES = (); }; };
                85E711A80AC5D5350053270F /* DOMHTMLFieldSetElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E711590AC5D5340053270F /* DOMHTMLFieldSetElementInternal.h */; };
                85E711A90AC5D5350053270F /* DOMHTMLFontElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E7115A0AC5D5340053270F /* DOMHTMLFontElementInternal.h */; };
-               85E711AA0AC5D5350053270F /* DOMHTMLFormElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E7115B0AC5D5340053270F /* DOMHTMLFormElementInternal.h */; };
+               85E711AA0AC5D5350053270F /* DOMHTMLFormElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E7115B0AC5D5340053270F /* DOMHTMLFormElementInternal.h */; settings = {ATTRIBUTES = (Private, ); }; };
                85E711AB0AC5D5350053270F /* DOMHTMLFrameElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E7115C0AC5D5340053270F /* DOMHTMLFrameElementInternal.h */; };
                85E711AC0AC5D5350053270F /* DOMHTMLFrameSetElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E7115D0AC5D5340053270F /* DOMHTMLFrameSetElementInternal.h */; };
                85E711AD0AC5D5350053270F /* DOMHTMLHeadElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E7115E0AC5D5350053270F /* DOMHTMLHeadElementInternal.h */; };
index e703385..bae0ae5 100644 (file)
@@ -1,3 +1,33 @@
+2013-04-13  Anders Carlsson  <andersca@apple.com>
+
+        Add form delegate method that's invoked right before sending a submit event to a form element
+        https://bugs.webkit.org/show_bug.cgi?id=114575
+
+        Reviewed by Dan Bernstein.
+
+        * MigrateHeaders.make:
+        Copy DOMHTMLFormElementInternal.h over to WebKit.
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (makeFormFieldValuesDictionary):
+        New helper function that returns the values of a form in dictionary form.
+
+        (WebFrameLoaderClient::dispatchWillSendSubmitEvent):
+        Call the right delegate method.
+
+        (WebFrameLoaderClient::dispatchWillSubmitForm):
+        Use the helper function.
+
+        * WebView/WebDelegateImplementationCaching.h:
+        * WebView/WebDelegateImplementationCaching.mm:
+        (CallFormDelegate):
+        Add another overload.
+
+        * WebView/WebFormDelegate.h:
+        * WebView/WebFormDelegate.m:
+        (-[WebFormDelegate willSendSubmitEventToForm:inFrame:withValues:]):
+        Add a default implementation.
+
 2013-04-10  Benjamin Poulain  <bpoulain@apple.com>
 
         Mass remove all the empty directories
index 3f2262b..673f6b4 100644 (file)
@@ -100,6 +100,7 @@ all : \
     $(PUBLIC_HEADERS_DIR)/DOMHTMLFieldSetElement.h \
     $(PUBLIC_HEADERS_DIR)/DOMHTMLFontElement.h \
     $(PUBLIC_HEADERS_DIR)/DOMHTMLFormElement.h \
+    $(INTERNAL_HEADERS_DIR)/DOMHTMLFormElementInternal.h \
     $(PUBLIC_HEADERS_DIR)/DOMHTMLFrameElement.h \
     $(PUBLIC_HEADERS_DIR)/DOMHTMLFrameSetElement.h \
     $(PUBLIC_HEADERS_DIR)/DOMHTMLHRElement.h \
index 89d7e94..fa355ac 100644 (file)
@@ -123,7 +123,7 @@ private:
 
     virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&) OVERRIDE;
 
-    virtual void dispatchWillSendSubmitEvent(PassRefPtr<WebCore::FormState>) OVERRIDE { }
+    virtual void dispatchWillSendSubmitEvent(PassRefPtr<WebCore::FormState>) OVERRIDE;
     virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, PassRefPtr<WebCore::FormState>) OVERRIDE;
 
     virtual void revertToProvisionalState(WebCore::DocumentLoader*) OVERRIDE;
index fd98e4c..f03a87a 100644 (file)
@@ -34,6 +34,7 @@
 #undef private
 
 #import "DOMElementInternal.h"
+#import "DOMHTMLFormElementInternal.h"
 #import "WebBackForwardList.h"
 #import "WebCachedFramePlatformData.h"
 #import "WebChromeClient.h"
@@ -761,23 +762,38 @@ void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&
     [[webView _policyDelegateForwarder] webView:webView unableToImplementPolicyWithError:error frame:m_webFrame.get()];    
 }
 
-void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<FormState> formState)
+static NSDictionary *makeFormFieldValuesDictionary(FormState* formState)
 {
-    id <WebFormDelegate> formDelegate = [getWebView(m_webFrame.get()) _formDelegate];
-    if (!formDelegate) {
-        (core(m_webFrame.get())->loader()->policyChecker()->*function)(PolicyUse);
-        return;
-    }
-
     const StringPairVector& textFieldValues = formState->textFieldValues();
     size_t size = textFieldValues.size();
     NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithCapacity:size];
     for (size_t i = 0; i < size; ++i)
         [dictionary setObject:textFieldValues[i].second forKey:textFieldValues[i].first];
 
-    CallFormDelegate(getWebView(m_webFrame.get()), @selector(frame:sourceFrame:willSubmitForm:withValues:submissionListener:), m_webFrame.get(), kit(formState->sourceDocument()->frame()), kit(formState->form()), dictionary, setUpPolicyListener(function).get());
+    return [dictionary autorelease];
+}
+
+void WebFrameLoaderClient::dispatchWillSendSubmitEvent(PassRefPtr<WebCore::FormState> formState)
+{
+    id <WebFormDelegate> formDelegate = [getWebView(m_webFrame.get()) _formDelegate];
+    if (!formDelegate)
+        return;
+
+    DOMHTMLFormElement *formElement = kit(formState->form());
+    NSDictionary *values = makeFormFieldValuesDictionary(formState.get());
+    CallFormDelegate(getWebView(m_webFrame.get()), @selector(willSendSubmitEventToForm:inFrame:withValues:), formElement, m_webFrame.get(), values);
+}
+
+void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<FormState> formState)
+{
+    id <WebFormDelegate> formDelegate = [getWebView(m_webFrame.get()) _formDelegate];
+    if (!formDelegate) {
+        (core(m_webFrame.get())->loader()->policyChecker()->*function)(PolicyUse);
+        return;
+    }
 
-    [dictionary release];
+    NSDictionary *values = makeFormFieldValuesDictionary(formState.get());
+    CallFormDelegate(getWebView(m_webFrame.get()), @selector(frame:sourceFrame:willSubmitForm:withValues:submissionListener:), m_webFrame.get(), kit(formState->sourceDocument()->frame()), kit(formState->form()), values, setUpPolicyListener(function).get());
 }
 
 void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader* loader)
index 620917d..e661981 100644 (file)
@@ -111,6 +111,7 @@ WebScriptDebugDelegateImplementationCache* WebViewGetScriptDebugDelegateImplemen
 WebHistoryDelegateImplementationCache* WebViewGetHistoryDelegateImplementations(WebView *webView);
 
 id CallFormDelegate(WebView *, SEL, id, id);
+id CallFormDelegate(WebView *, SEL, id, id, id);
 id CallFormDelegate(WebView *self, SEL selector, id object1, id object2, id object3, id object4, id object5);
 BOOL CallFormDelegateReturningBoolean(BOOL, WebView *, SEL, id, SEL, id);
 
index 6246a1d..7085ac8 100644 (file)
@@ -611,6 +611,19 @@ id CallFormDelegate(WebView *self, SEL selector, id object1, id object2)
     return nil;
 }
 
+id CallFormDelegate(WebView *self, SEL selector, id object1, id object2, id object3)
+{
+    id delegate = self->_private->formDelegate;
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return nil;
+    @try {
+        return wtfObjcMsgSend<id>(delegate, selector, object1, object2, object3);
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+}
+
 id CallFormDelegate(WebView *self, SEL selector, id object1, id object2, id object3, id object4, id object5)
 {
     id delegate = self->_private->formDelegate;
index c7b231a..b7496e9 100644 (file)
@@ -29,6 +29,7 @@
 #import <AppKit/AppKit.h>
 
 @class DOMElement;
+@class DOMHTMLFormElement;
 @class DOMHTMLInputElement;
 @class DOMHTMLTextAreaElement;
 @class WebFrame;
@@ -63,6 +64,8 @@
 - (void)frame:(WebFrame *)frame sourceFrame:(WebFrame *)sourceFrame willSubmitForm:(DOMElement *)form
     withValues:(NSDictionary *)values submissionListener:(id <WebFormSubmissionListener>)listener;
 
+- (void)willSendSubmitEventToForm:(DOMHTMLFormElement *)element inFrame:(WebFrame *)sourceFrame withValues:(NSDictionary *)values;
+
 @end
 
 /*!
index 96bdfa9..8c4cedb 100644 (file)
@@ -80,4 +80,8 @@ static WebFormDelegate *sharedDelegate = nil;
     [listener continue];
 }
 
+- (void)willSendSubmitEventToForm:(DOMHTMLFormElement *)element inFrame:(WebFrame *)sourceFrame withValues:(NSDictionary *)values
+{
+}
+
 @end
index ddcf82c..c303d7f 100644 (file)
@@ -1,3 +1,22 @@
+2013-04-13  Anders Carlsson  <andersca@apple.com>
+
+        Add form delegate method that's invoked right before sending a submit event to a form element
+        https://bugs.webkit.org/show_bug.cgi?id=114575
+
+        Reviewed by Dan Bernstein.
+
+        Add a test.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/mac/WillSendSubmitEvent.mm: Added.
+        (-[FormDelegate willSendSubmitEventToForm:inFrame:withValues:]):
+        (TestWebKitAPI):
+        (TestWebKitAPI::TEST):
+        
+        * TestWebKitAPI/mac/PlatformUtilitiesMac.mm:
+        (TestWebKitAPI::Util::toSTD):
+        Don't crash when a null NSString is passed to toSTD.
+
 2013-04-13  Ryosuke Niwa  <rniwa@webkit.org>
 
         Python test fix attempt after r148360.
index 660868d..1669ae5 100644 (file)
@@ -19,6 +19,7 @@
                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 */; };
+               1A7BFC0C171A0BDB00BC5F64 /* WillSendSubmitEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A7BFC0A171A0BDB00BC5F64 /* WillSendSubmitEvent.mm */; };
                1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C045F9461385C2F800C0F3CD /* 18-characters.html */; };
                1AA9E55914980A9900001A8A /* Functional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA9E55714980A9900001A8A /* Functional.cpp */; };
                1ADBEFAE130C689C00D61D19 /* ForceRepaint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ADBEFAD130C689C00D61D19 /* ForceRepaint.cpp */; };
                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>"; };
+               1A7BFC0A171A0BDB00BC5F64 /* WillSendSubmitEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WillSendSubmitEvent.mm; sourceTree = "<group>"; };
                1AA9E55714980A9900001A8A /* Functional.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Functional.cpp; path = WTF/Functional.cpp; sourceTree = "<group>"; };
                1ADBEFAD130C689C00D61D19 /* ForceRepaint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ForceRepaint.cpp; sourceTree = "<group>"; };
                1ADBEFBC130C6A0100D61D19 /* simple-accelerated-compositing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-accelerated-compositing.html"; sourceTree = "<group>"; };
                                37A6895D148A9B50005100FA /* SubresourceErrorCrash.mm */,
                                E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */,
                                51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */,
+                               C2EB2DD116CAC7AC009B52EE /* WebViewDidCreateJavaScriptContext.mm */,
                                37E38C33169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm */,
+                               1A7BFC0A171A0BDB00BC5F64 /* WillSendSubmitEvent.mm */,
                                A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */,
-                               C2EB2DD116CAC7AC009B52EE /* WebViewDidCreateJavaScriptContext.mm */,
                        );
                        path = mac;
                        sourceTree = "<group>";
                                BC131AA9117131FC00B69727 /* TestsController.cpp in Sources */,
                                E490296814E2E3A4002BEDD1 /* TypingStyleCrash.mm in Sources */,
                                2943BE86161DFEB800999E3D /* UserContentTest.mm in Sources */,
+                               1A7BFC0C171A0BDB00BC5F64 /* WillSendSubmitEvent.mm in Sources */,
                                BC22D31514DC689800FFB1DD /* UserMessage.cpp in Sources */,
                                BC55F5F914AD78EE00484BE1 /* Vector.cpp in Sources */,
                                BC90964C125561BF00083756 /* VectorBasic.cpp in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/mac/WillSendSubmitEvent.mm b/Tools/TestWebKitAPI/Tests/mac/WillSendSubmitEvent.mm
new file mode 100644 (file)
index 0000000..7545941
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#import "config.h"
+#import "PlatformUtilities.h"
+#import "PlatformWebView.h"
+#import "Test.h"
+
+#import <WebKit/WebFormDelegate.h>
+#import <WebKit/WebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+static bool didFinishLoad;
+
+@interface FormDelegate : WebFormDelegate
+@end
+
+@implementation FormDelegate
+
+- (void)willSendSubmitEventToForm:(DOMHTMLFormElement *)element inFrame:(WebFrame *)sourceFrame withValues:(NSDictionary *)values
+{
+    EXPECT_NOT_NULL(element);
+    EXPECT_NOT_NULL(sourceFrame);
+
+    EXPECT_WK_STREQ([values objectForKey:@"textField"], @"text field");
+    EXPECT_WK_STREQ([values objectForKey:@"passwordField"], @"password field");
+
+    // <input type="hidden"> fields are not sent.
+    EXPECT_NULL([values objectForKey:@"hiddenField"]);
+
+    didFinishLoad = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, WillSendSubmitEvent)
+{
+    @autoreleasepool {
+        RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+
+        RetainPtr<FormDelegate> formDelegate = [[FormDelegate alloc] init];
+        [webView _setFormDelegate:formDelegate.get()];
+
+        [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"auto-submitting-form" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+
+        Util::run(&didFinishLoad);
+    }
+}
+
+}
index afa28a7..979f4cd 100644 (file)
@@ -78,6 +78,9 @@ bool isKeyDown(WKNativeEventPtr event)
 
 std::string toSTD(NSString *string)
 {
+    if (!string)
+        return std::string();
+
     size_t bufferSize = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
     OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
     NSUInteger stringLength;