https://bugs.webkit.org/show_bug.cgi?id=106261
Reviewed by Simon Fraser.
Source/WebKit/mac:
Test: TestWebKitAPI/Tests/mac/WebViewDidRemoveFrameFromHierarchy.mm.
Added -[WebFrameLoadDelegate webView:didRemoveFrameFromHierarchy:].
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::detachedFromParent2): Added a call to the new frame load delegate
method.
* WebView/WebDelegateImplementationCaching.h:
(WebFrameLoadDelegateImplementationCache): Added the new method to the cache.
* WebView/WebFrameLoadDelegatePrivate.h: Declared the new delegate method.
* WebView/WebView.mm:
(-[WebView _cacheFrameLoadDelegateImplementations]): Added the new method to the cache.
Tools:
Added a test for -[WebFrameLoadDelegate webView:didRemoveFrameFromHierarchy:].
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/WebViewDidRemoveFrameFromHierarchy.mm: Added.
(-[DidRemoveFrameFromHierarchyFrameLoadDelegate webView:didFinishLoadForFrame:]):
(-[DidRemoveFrameFromHierarchyFrameLoadDelegate webView:didRemoveFrameFromHierarchy:]):
(TestWebKitAPI):
(TestWebKitAPI::TEST):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139000
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-01-07 Dan Bernstein <mitz@apple.com>
+
+ [mac] WebKit1 clients can’t tell when a frame has been removed from the hierarchy
+ https://bugs.webkit.org/show_bug.cgi?id=106261
+
+ Reviewed by Simon Fraser.
+
+ Test: TestWebKitAPI/Tests/mac/WebViewDidRemoveFrameFromHierarchy.mm.
+
+ Added -[WebFrameLoadDelegate webView:didRemoveFrameFromHierarchy:].
+
+ * WebCoreSupport/WebFrameLoaderClient.mm:
+ (WebFrameLoaderClient::detachedFromParent2): Added a call to the new frame load delegate
+ method.
+ * WebView/WebDelegateImplementationCaching.h:
+ (WebFrameLoadDelegateImplementationCache): Added the new method to the cache.
+ * WebView/WebFrameLoadDelegatePrivate.h: Declared the new delegate method.
+ * WebView/WebView.mm:
+ (-[WebView _cacheFrameLoadDelegateImplementations]): Added the new method to the cache.
+
2013-01-07 Mike West <mkwst@chromium.org>
Make the IFRAME_SEAMLESS flag runtime-enabled.
WebView *webView = getWebView(m_webFrame.get());
[webView removePluginInstanceViewsFor:(m_webFrame.get())];
[m_webFrame->_private->webFrameView _setWebFrame:nil]; // needed for now to be compatible w/ old behavior
+
+ WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
+ if (implementations->didRemoveFrameFromHierarchyFunc)
+ CallFrameLoadDelegate(implementations->didRemoveFrameFromHierarchyFunc, webView, @selector(webView:didRemoveFrameFromHierarchy:), m_webFrame.get());
}
void WebFrameLoaderClient::detachedFromParent3()
IMP didDisplayInsecureContentFunc;
IMP didRunInsecureContentFunc;
IMP didDetectXSSFunc;
+ IMP didRemoveFrameFromHierarchyFunc;
};
struct WebScriptDebugDelegateImplementationCache {
- (void)webView:(WebView *)webView didPushStateWithinPageForFrame:(WebFrame *)frame;
- (void)webView:(WebView *)webView didReplaceStateWithinPageForFrame:(WebFrame *)frame;
- (void)webView:(WebView *)webView didPopStateWithinPageForFrame:(WebFrame *)frame;
+- (void)webView:(WebView *)webView didRemoveFrameFromHierarchy:(WebFrame *)frame;
@end
cache->didDisplayInsecureContentFunc = getMethod(delegate, @selector(webViewDidDisplayInsecureContent:));
cache->didRunInsecureContentFunc = getMethod(delegate, @selector(webView:didRunInsecureContent:));
cache->didDetectXSSFunc = getMethod(delegate, @selector(webView:didDetectXSS:));
+ cache->didRemoveFrameFromHierarchyFunc = getMethod(delegate, @selector(webView:didRemoveFrameFromHierarchy:));
// It would be nice to get rid of this code and transition all clients to using didLayout instead of
// didFirstLayoutInFrame and didFirstVisuallyNonEmptyLayoutInFrame. In the meantime, this is required
+2013-01-07 Dan Bernstein <mitz@apple.com>
+
+ [mac] WebKit1 clients can’t tell when a frame has been removed from the hierarchy
+ https://bugs.webkit.org/show_bug.cgi?id=106261
+
+ Reviewed by Simon Fraser.
+
+ Added a test for -[WebFrameLoadDelegate webView:didRemoveFrameFromHierarchy:].
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/mac/WebViewDidRemoveFrameFromHierarchy.mm: Added.
+ (-[DidRemoveFrameFromHierarchyFrameLoadDelegate webView:didFinishLoadForFrame:]):
+ (-[DidRemoveFrameFromHierarchyFrameLoadDelegate webView:didRemoveFrameFromHierarchy:]):
+ (TestWebKitAPI):
+ (TestWebKitAPI::TEST):
+
2013-01-07 Ojan Vafai <ojan@chromium.org>
Add the Apple MountainLion bots to garden-o-matic.
37DC6791140D7D7600ABCCDB /* DOMRangeOfString.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */; };
37E1064C1697681800B78BD0 /* DOMHTMLTableCellElementCellAbove.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 37E1064B169767F700B78BD0 /* DOMHTMLTableCellElementCellAbove.html */; };
37E1064D16976C8500B78BD0 /* DOMHTMLTableCellCellAbove.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37E1064A1697676400B78BD0 /* DOMHTMLTableCellCellAbove.mm */; };
+ 37E38C34169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37E38C33169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm */; };
440A1D3914A0103A008A66F2 /* KURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 440A1D3814A0103A008A66F2 /* KURL.cpp */; };
4BB4160216815B2600824238 /* JSWrapperForNodeInWebFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4160116815B2600824238 /* JSWrapperForNodeInWebFrame.mm */; };
4BB4160416815F9100824238 /* ElementAtPointInWebFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4160316815F9100824238 /* ElementAtPointInWebFrame.mm */; };
37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DOMRangeOfString.html; sourceTree = "<group>"; };
37E1064A1697676400B78BD0 /* DOMHTMLTableCellCellAbove.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLTableCellCellAbove.mm; sourceTree = "<group>"; };
37E1064B169767F700B78BD0 /* DOMHTMLTableCellElementCellAbove.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DOMHTMLTableCellElementCellAbove.html; sourceTree = "<group>"; };
+ 37E38C33169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewDidRemoveFrameFromHierarchy.mm; sourceTree = "<group>"; };
440A1D3814A0103A008A66F2 /* KURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KURL.cpp; sourceTree = "<group>"; };
44A622C114A0E2B60048515B /* WTFStringUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFStringUtilities.h; sourceTree = "<group>"; };
4BB4160116815B2600824238 /* JSWrapperForNodeInWebFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JSWrapperForNodeInWebFrame.mm; sourceTree = "<group>"; };
37A6895D148A9B50005100FA /* SubresourceErrorCrash.mm */,
E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */,
51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */,
+ 37E38C33169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm */,
A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */,
00CD9F6215BE312C002DA2CE /* BackForwardList.mm */,
);
4BB4160416815F9100824238 /* ElementAtPointInWebFrame.mm in Sources */,
3751AF7C169518F800764319 /* DOMNodeFromJSObject.mm in Sources */,
37E1064D16976C8500B78BD0 /* DOMHTMLTableCellCellAbove.mm in Sources */,
+ 37E38C34169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- /dev/null
+/*
+ * 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 <WebKit/WebFrameLoadDelegatePrivate.h>
+#import <wtf/RetainPtr.h>
+
+@interface DidRemoveFrameFromHierarchyFrameLoadDelegate : NSObject
+@end
+
+static bool didFinishLoad;
+static bool didRemoveFrame;
+
+@implementation DidRemoveFrameFromHierarchyFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+ didFinishLoad = true;
+}
+
+- (void)webView:(WebView *)sender didRemoveFrameFromHierarchy:(WebFrame *)frame
+{
+ didRemoveFrame = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, DidRemoveFrameFromHierarchy)
+{
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<DidRemoveFrameFromHierarchyFrameLoadDelegate> frameLoadDelegate = adoptNS([[DidRemoveFrameFromHierarchyFrameLoadDelegate alloc] init]);
+
+ webView.get().frameLoadDelegate = frameLoadDelegate.get();
+ WebFrame *mainFrame = webView.get().mainFrame;
+
+ NSString *bodyWithIFrameString = @"<body><iframe id='iframe'></iframe></body>";
+ NSURL *aboutBlankURL = [NSURL URLWithString:@"about:blank"];
+
+ [mainFrame loadHTMLString:bodyWithIFrameString baseURL:aboutBlankURL];
+ Util::run(&didFinishLoad);
+
+ EXPECT_FALSE(didRemoveFrame);
+ [webView.get() stringByEvaluatingJavaScriptFromString:@"document.body.removeChild(document.getElementById('iframe'))"];
+ EXPECT_TRUE(didRemoveFrame);
+
+ didFinishLoad = false;
+ didRemoveFrame = false;
+
+ [mainFrame loadHTMLString:bodyWithIFrameString baseURL:aboutBlankURL];
+ Util::run(&didFinishLoad);
+
+ // The delegate method is not called when the frame is removed due to navigation in an ancestor frame.
+ EXPECT_FALSE(didRemoveFrame);
+ [mainFrame loadHTMLString:@"<body></body>" baseURL:aboutBlankURL];
+ EXPECT_FALSE(didRemoveFrame);
+}
+
+} // namespace TestWebKitAPI