Flesh out WKBrowsingContextLoadDelegate a bit
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2011 22:35:52 +0000 (22:35 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2011 22:35:52 +0000 (22:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70846

Source/WebKit2:

Add didReceiveServerRedirectForProvisionalLoad, didFailProvisionalLoad
and didFailLoad.

Reviewed by Anders Carlsson.

Test: WKBrowsingContextLoadDelegateTest

* UIProcess/API/mac/WKBrowsingContextController.mm:
(didReceiveServerRedirectForProvisionalLoadForFrame):
(didFailProvisionalLoadWithErrorForFrame):
(didFailLoadWithErrorForFrame):
(setUpPageLoaderClient):
* UIProcess/API/mac/WKBrowsingContextLoadDelegate.h:

Tools:

Reviewed by Anders Carlsson.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2ObjC: Added.
* TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm: Added.
(WKBrowsingContextLoadDelegateTest::WKBrowsingContextLoadDelegateTest):
(WKBrowsingContextLoadDelegateTest::SetUp):
(WKBrowsingContextLoadDelegateTest::TearDown):
(-[SimpleLoadDelegate browsingContextControllerDidFinishLoad:]):
(TEST_F):
Add basic testing for WKBrowsingContextLoadDelegate.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm
Source/WebKit2/UIProcess/API/mac/WKBrowsingContextLoadDelegate.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm [new file with mode: 0644]

index 3c7b09c1fca07ec41fa77ebadc7cbea15969f1da..daf3323e4b120fa06a762c2ee7ba248fab903cf8 100644 (file)
@@ -1,3 +1,22 @@
+2011-10-25  Sam Weinig  <sam@webkit.org>
+
+        Flesh out WKBrowsingContextLoadDelegate a bit
+        https://bugs.webkit.org/show_bug.cgi?id=70846
+
+        Add didReceiveServerRedirectForProvisionalLoad, didFailProvisionalLoad
+        and didFailLoad.
+
+        Reviewed by Anders Carlsson.
+
+        Test: WKBrowsingContextLoadDelegateTest
+
+        * UIProcess/API/mac/WKBrowsingContextController.mm:
+        (didReceiveServerRedirectForProvisionalLoadForFrame):
+        (didFailProvisionalLoadWithErrorForFrame):
+        (didFailLoadWithErrorForFrame):
+        (setUpPageLoaderClient):
+        * UIProcess/API/mac/WKBrowsingContextLoadDelegate.h:
+
 2011-10-25  Anders Carlsson  <andersca@apple.com>
 
         Assertion failure when zooming a PDF in an iframe
 2011-10-25  Anders Carlsson  <andersca@apple.com>
 
         Assertion failure when zooming a PDF in an iframe
index 8e6ca76920f9bd7d5602e3ee404e061ce5a276d5..e2306a0baa7ab77e84998c71d8f89188dff459bb 100644 (file)
@@ -27,6 +27,7 @@
 #import "WKBrowsingContextController.h"
 #import "WKBrowsingContextControllerInternal.h"
 
 #import "WKBrowsingContextController.h"
 #import "WKBrowsingContextControllerInternal.h"
 
+#import "WKErrorCF.h"
 #import "WKFrame.h"
 #import "WKPage.h"
 #import "WKRetainPtr.h"
 #import "WKFrame.h"
 #import "WKPage.h"
 #import "WKRetainPtr.h"
@@ -34,6 +35,7 @@
 #import "WKURLCF.h"
 #import "WKURLRequest.h"
 #import "WKURLRequestNS.h"
 #import "WKURLCF.h"
 #import "WKURLRequest.h"
 #import "WKURLRequestNS.h"
+#import <wtf/RetainPtr.h>
 
 #import "WKBrowsingContextLoadDelegate.h"
 
 
 #import "WKBrowsingContextLoadDelegate.h"
 
@@ -203,7 +205,30 @@ static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WK
         return;
 
     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
         return;
 
     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
-    [browsingContext.loadDelegate browsingContextControllerDidStartProvisionalLoad:browsingContext];
+    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidStartProvisionalLoad:)])
+        [browsingContext.loadDelegate browsingContextControllerDidStartProvisionalLoad:browsingContext];
+}
+
+static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+    if (!WKFrameIsMainFrame(frame))
+        return;
+
+    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
+    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:)])
+        [browsingContext.loadDelegate browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:browsingContext];
+}
+
+static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
+{
+    if (!WKFrameIsMainFrame(frame))
+        return;
+
+    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
+    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFailProvisionalLoad:withError:)]) {
+        RetainPtr<CFErrorRef> cfError(AdoptCF, WKErrorCopyCFError(kCFAllocatorDefault, error));
+        [browsingContext.loadDelegate browsingContextControllerDidFailProvisionalLoad:browsingContext withError:(NSError *)cfError.get()];
+    }
 }
 
 static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
 }
 
 static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
@@ -212,7 +237,8 @@ static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef us
         return;
 
     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
         return;
 
     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
-    [browsingContext.loadDelegate browsingContextControllerDidCommitLoad:browsingContext];
+    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidCommitLoad:)])
+        [browsingContext.loadDelegate browsingContextControllerDidCommitLoad:browsingContext];
 }
 
 static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
 }
 
 static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
@@ -221,19 +247,35 @@ static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef us
         return;
 
     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
         return;
 
     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
-    [browsingContext.loadDelegate browsingContextControllerDidFinishLoad:browsingContext];
+    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFinishLoad:)])
+        [browsingContext.loadDelegate browsingContextControllerDidFinishLoad:browsingContext];
+}
+
+static void didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
+{
+    if (!WKFrameIsMainFrame(frame))
+        return;
+
+    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
+    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFailLoad:withError:)]) {
+        RetainPtr<CFErrorRef> cfError(AdoptCF, WKErrorCopyCFError(kCFAllocatorDefault, error));
+        [browsingContext.loadDelegate browsingContextControllerDidFailLoad:browsingContext withError:(NSError *)cfError.get()];
+    }
 }
 
 static void setUpPageLoaderClient(WKBrowsingContextController *browsingContext, WKPageRef pageRef)
 {
     WKPageLoaderClient loaderClient;
     memset(&loaderClient, 0, sizeof(loaderClient));
 }
 
 static void setUpPageLoaderClient(WKBrowsingContextController *browsingContext, WKPageRef pageRef)
 {
     WKPageLoaderClient loaderClient;
     memset(&loaderClient, 0, sizeof(loaderClient));
-    
+
     loaderClient.version = kWKPageLoaderClientCurrentVersion;
     loaderClient.clientInfo = browsingContext;
     loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
     loaderClient.version = kWKPageLoaderClientCurrentVersion;
     loaderClient.clientInfo = browsingContext;
     loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
+    loaderClient.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame;
+    loaderClient.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame;
     loaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
     loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
     loaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
     loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+    loaderClient.didFailLoadWithErrorForFrame = didFailLoadWithErrorForFrame;
 
     WKPageSetPageLoaderClient(pageRef, &loaderClient);
 }
 
     WKPageSetPageLoaderClient(pageRef, &loaderClient);
 }
index 13649ee5f88f7e4036d561d86fa3c293941bcb6e..3cd3a51d92da32a59b0b89ebd61a5deaa8c9209f 100644 (file)
 /* Sent when the provisional load begins. */
 - (void)browsingContextControllerDidStartProvisionalLoad:(WKBrowsingContextController *)sender;
 
 /* Sent when the provisional load begins. */
 - (void)browsingContextControllerDidStartProvisionalLoad:(WKBrowsingContextController *)sender;
 
+/* Sent if a server-side redirect was recieved. */
+- (void)browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:(WKBrowsingContextController *)sender;
+
+/* Sent if the provional load fails. */
+- (void)browsingContextControllerDidFailProvisionalLoad:(WKBrowsingContextController *)sender withError:(NSError *)error;
+
 /* Sent when the load gets committed. */
 - (void)browsingContextControllerDidCommitLoad:(WKBrowsingContextController *)sender;
 
 /* Sent when the load completes. */
 - (void)browsingContextControllerDidFinishLoad:(WKBrowsingContextController *)sender;
 
 /* Sent when the load gets committed. */
 - (void)browsingContextControllerDidCommitLoad:(WKBrowsingContextController *)sender;
 
 /* Sent when the load completes. */
 - (void)browsingContextControllerDidFinishLoad:(WKBrowsingContextController *)sender;
 
+/* Sent if the commited load fails. */
+- (void)browsingContextControllerDidFailLoad:(WKBrowsingContextController *)sender withError:(NSError *)error;
+
 @end
 @end
index c52cb890de10bf4c42ae8c7b8660abf6e5e38865..c078a9b480a6b3f1ed10e14ac6ee6b3efe86e73a 100644 (file)
                BCBAACF41452324F0053F82F /* WKBrowsingContextGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAACEE145232430053F82F /* WKBrowsingContextGroup.h */; settings = {ATTRIBUTES = (Public, ); }; };
                BCBAACF51452324F0053F82F /* WKBrowsingContextGroup.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCBAACEF145232440053F82F /* WKBrowsingContextGroup.mm */; };
                BCBAACF61452324F0053F82F /* WKBrowsingContextGroupInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAACF0145232480053F82F /* WKBrowsingContextGroupInternal.h */; };
                BCBAACF41452324F0053F82F /* WKBrowsingContextGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAACEE145232430053F82F /* WKBrowsingContextGroup.h */; settings = {ATTRIBUTES = (Public, ); }; };
                BCBAACF51452324F0053F82F /* WKBrowsingContextGroup.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCBAACEF145232440053F82F /* WKBrowsingContextGroup.mm */; };
                BCBAACF61452324F0053F82F /* WKBrowsingContextGroupInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAACF0145232480053F82F /* WKBrowsingContextGroupInternal.h */; };
-               BCBAAD0B14560A430053F82F /* WKBrowsingContextLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAAD0A14560A430053F82F /* WKBrowsingContextLoadDelegate.h */; };
+               BCBAAD0B14560A430053F82F /* WKBrowsingContextLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAAD0A14560A430053F82F /* WKBrowsingContextLoadDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
                BCBCB0CB1215E32100DE59CA /* ImmutableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBCB0CA1215E32100DE59CA /* ImmutableDictionary.h */; };
                BCBCB0CD1215E33A00DE59CA /* ImmutableDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCBCB0CC1215E33A00DE59CA /* ImmutableDictionary.cpp */; };
                BCBD3914125BB1A800D2C29F /* WebPageProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCBD3912125BB1A800D2C29F /* WebPageProxyMessageReceiver.cpp */; };
                BCBCB0CB1215E32100DE59CA /* ImmutableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBCB0CA1215E32100DE59CA /* ImmutableDictionary.h */; };
                BCBCB0CD1215E33A00DE59CA /* ImmutableDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCBCB0CC1215E33A00DE59CA /* ImmutableDictionary.cpp */; };
                BCBD3914125BB1A800D2C29F /* WebPageProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCBD3912125BB1A800D2C29F /* WebPageProxyMessageReceiver.cpp */; };
index 2e4f1ec217a05ce90c059c15b86e35c704be28ab..edc03f4c0242b313481263bb3987a3767a677c3e 100644 (file)
@@ -1,3 +1,20 @@
+2011-10-25  Sam Weinig  <sam@webkit.org>
+
+        Flesh out WKBrowsingContextLoadDelegate a bit
+        https://bugs.webkit.org/show_bug.cgi?id=70846
+
+        Reviewed by Anders Carlsson.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2ObjC: Added.
+        * TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm: Added.
+        (WKBrowsingContextLoadDelegateTest::WKBrowsingContextLoadDelegateTest):
+        (WKBrowsingContextLoadDelegateTest::SetUp):
+        (WKBrowsingContextLoadDelegateTest::TearDown):
+        (-[SimpleLoadDelegate browsingContextControllerDidFinishLoad:]):
+        (TEST_F):
+        Add basic testing for WKBrowsingContextLoadDelegate.
+
 2011-10-25  Alexey Proskuryakov  <ap@apple.com>
 
         make-script-test-wrappers should not look outside fast/js
 2011-10-25  Alexey Proskuryakov  <ap@apple.com>
 
         make-script-test-wrappers should not look outside fast/js
index 80fe5bb892594058024864f0a1bb490220f79929..9d67209e511c363c93a74440764a038ab8594ed4 100644 (file)
@@ -43,6 +43,7 @@
                BC246D9C132F1FF000B56D7C /* CanHandleRequest_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC246D97132F1FE100B56D7C /* CanHandleRequest_Bundle.cpp */; };
                BC2D004912A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */; };
                BC2D006412AA04CE00E732A3 /* file-with-anchor.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = BC2D004A12A9FEB300E732A3 /* file-with-anchor.html */; };
                BC246D9C132F1FF000B56D7C /* CanHandleRequest_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC246D97132F1FE100B56D7C /* CanHandleRequest_Bundle.cpp */; };
                BC2D004912A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */; };
                BC2D006412AA04CE00E732A3 /* file-with-anchor.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = BC2D004A12A9FEB300E732A3 /* file-with-anchor.html */; };
+               BC3C4C7214575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */; };
                BC575A90126E74D3006F0F12 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCB9E9F011235BDE00A137E0 /* Cocoa.framework */; };
                BC575A91126E74D3006F0F12 /* WebKit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCA61DB411700EFD00460D1E /* WebKit2.framework */; };
                BC575A92126E74D3006F0F12 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC90964D1255620C00083756 /* JavaScriptCore.framework */; };
                BC575A90126E74D3006F0F12 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCB9E9F011235BDE00A137E0 /* Cocoa.framework */; };
                BC575A91126E74D3006F0F12 /* WebKit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCA61DB411700EFD00460D1E /* WebKit2.framework */; };
                BC575A92126E74D3006F0F12 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC90964D1255620C00083756 /* JavaScriptCore.framework */; };
                BC246D98132F1FE100B56D7C /* CanHandleRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanHandleRequest.cpp; sourceTree = "<group>"; };
                BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageLoadDidChangeLocationWithinPageForFrame.cpp; sourceTree = "<group>"; };
                BC2D004A12A9FEB300E732A3 /* file-with-anchor.html */ = {isa = PBXFileReference; explicitFileType = text.html; fileEncoding = 4; path = "file-with-anchor.html"; sourceTree = "<group>"; };
                BC246D98132F1FE100B56D7C /* CanHandleRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanHandleRequest.cpp; sourceTree = "<group>"; };
                BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageLoadDidChangeLocationWithinPageForFrame.cpp; sourceTree = "<group>"; };
                BC2D004A12A9FEB300E732A3 /* file-with-anchor.html */ = {isa = PBXFileReference; explicitFileType = text.html; fileEncoding = 4; path = "file-with-anchor.html"; sourceTree = "<group>"; };
+               BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKBrowsingContextLoadDelegateTest.mm; path = WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm; sourceTree = "<group>"; };
                BC575946126E7351006F0F12 /* InjectedBundleMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMain.cpp; sourceTree = "<group>"; };
                BC575980126E74AF006F0F12 /* InjectedBundleTestWebKitAPI.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InjectedBundleTestWebKitAPI.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
                BC575981126E74AF006F0F12 /* InjectedBundle-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "InjectedBundle-Info.plist"; sourceTree = "<group>"; };
                BC575946126E7351006F0F12 /* InjectedBundleMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMain.cpp; sourceTree = "<group>"; };
                BC575980126E74AF006F0F12 /* InjectedBundleTestWebKitAPI.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InjectedBundleTestWebKitAPI.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
                BC575981126E74AF006F0F12 /* InjectedBundle-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "InjectedBundle-Info.plist"; sourceTree = "<group>"; };
                        name = Products;
                        sourceTree = "<group>";
                };
                        name = Products;
                        sourceTree = "<group>";
                };
+               BC3C4C6F14575B1D0025FB62 /* WebKit2 Objective-C */ = {
+                       isa = PBXGroup;
+                       children = (
+                               BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */,
+                       );
+                       name = "WebKit2 Objective-C";
+                       sourceTree = "<group>";
+               };
                BC575944126E733C006F0F12 /* InjectedBundle */ = {
                        isa = PBXGroup;
                        children = (
                BC575944126E733C006F0F12 /* InjectedBundle */ = {
                        isa = PBXGroup;
                        children = (
                                C08587F913FEC39B001EF4E5 /* TestWebKitAPI */,
                                C07E6CAD13FD67650038B22B /* mac */,
                                BC9096411255616000083756 /* WebKit2 */,
                                C08587F913FEC39B001EF4E5 /* TestWebKitAPI */,
                                C07E6CAD13FD67650038B22B /* mac */,
                                BC9096411255616000083756 /* WebKit2 */,
+                               BC3C4C6F14575B1D0025FB62 /* WebKit2 Objective-C */,
                                BC9096461255618900083756 /* WTF */,
                        );
                        path = Tests;
                                BC9096461255618900083756 /* WTF */,
                        );
                        path = Tests;
                                F6FDDDD314241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */,
                                C0991C51143C7D68007998F2 /* RetainPtrHashing.cpp in Sources */,
                                52CB47411448FB9300873995 /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp in Sources */,
                                F6FDDDD314241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */,
                                C0991C51143C7D68007998F2 /* RetainPtrHashing.cpp in Sources */,
                                52CB47411448FB9300873995 /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp in Sources */,
+                               BC3C4C7214575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm b/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm
new file mode 100644 (file)
index 0000000..bdee733
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2011 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 "Test.h"
+
+#import <WebKit2/WKBrowsingContextController.h>
+#import <WebKit2/WKBrowsingContextGroup.h>
+#import <WebKit2/WKBrowsingContextLoadDelegate.h>
+#import <WebKit2/WKProcessGroup.h>
+#import <WebKit2/WKRetainPtr.h>
+#import <WebKit2/WKView.h>
+
+#import "PlatformUtilities.h"
+
+class WKBrowsingContextLoadDelegateTest : public ::testing::Test { 
+public:
+    WKProcessGroup *processGroup;
+    WKBrowsingContextGroup *browsingContextGroup;
+    WKView *view;
+
+    WKBrowsingContextLoadDelegateTest()
+        : processGroup(nil)
+        , browsingContextGroup(nil)
+        , view(nil)
+    {
+    }
+
+    virtual void SetUp()
+    {
+        processGroup = [[WKProcessGroup alloc] init];
+        browsingContextGroup = [[WKBrowsingContextGroup alloc] initWithIdentifier:@"TestIdentifier"];
+        view = [[WKView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) processGroup:processGroup browsingContextGroup:browsingContextGroup];
+    }
+
+    virtual void TearDown()
+    {
+        [view release];
+        [browsingContextGroup release];
+        [processGroup release];
+    }
+};
+
+static bool simpleLoadDone;
+
+@interface SimpleLoadDelegate : NSObject <WKBrowsingContextLoadDelegate>
+@end
+
+@implementation SimpleLoadDelegate
+
+- (void)browsingContextControllerDidFinishLoad:(WKBrowsingContextController *)sender
+{
+    simpleLoadDone = true;
+}
+
+@end
+
+TEST_F(WKBrowsingContextLoadDelegateTest, Empty)
+{
+    // Just make sure the setup/tear down works.
+}
+
+TEST_F(WKBrowsingContextLoadDelegateTest, SimpleLoad)
+{
+    // Add the load delegate.
+    SimpleLoadDelegate *simpleLoadDelegate = [[SimpleLoadDelegate alloc] init];
+    view.browsingContextController.loadDelegate = simpleLoadDelegate;
+
+    // Load the file.
+    NSURL *nsURL = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html"];
+    [view.browsingContextController loadFileURL:nsURL restrictToFilesWithin:nil];
+
+    // Wait for the load.
+    TestWebKitAPI::Util::run(&simpleLoadDone);
+
+    // Tear down the delegate.
+    view.browsingContextController.loadDelegate = nil;
+    [simpleLoadDelegate release];
+}