Diff
Modified: trunk/Source/WebCore/ChangeLog (206921 => 206922)
--- trunk/Source/WebCore/ChangeLog 2016-10-07 17:44:51 UTC (rev 206921)
+++ trunk/Source/WebCore/ChangeLog 2016-10-07 18:55:09 UTC (rev 206922)
@@ -1,3 +1,26 @@
+2016-10-07 Andreas Kling <[email protected]>
+
+ [WK2] didRemoveFrameFromHierarchy callback doesn't fire for subframes when evicting from PageCache.
+ <https://webkit.org/b/163098>
+ <rdar://problem/28663488>
+
+ Reviewed by Antti Koivisto.
+
+ Fix a bug where WK2 didRemoveFrameFromHierarchy callbacks wouldn't fire for subframes that were getting
+ kicked out of PageCache. The problem was happening because CachedFrame would disconnect the Frame from
+ its Page just before calling FrameLoader::detachViewsAndDocumentLoader() where the callbacks are fired.
+ Without a Page, the WebFrame on WK2 side can't find its WebPage, and so it can't fire its callbacks.
+
+ The fix is just to switch the order of those two lines.
+
+ This bug was causing frequent DOM and window object leaks in some clients *cough* Safari *cough* that
+ were relying on didRemoveFrameFromHierarchy to release their isolated worlds.
+
+ Test: WebKit2.DidRemoveFrameFromHiearchyInPageCache
+
+ * history/CachedFrame.cpp:
+ (WebCore::CachedFrame::destroy):
+
2016-10-07 Nan Wang <[email protected]>
AX: AXRoleDescription for details and summary elements
Modified: trunk/Source/WebCore/history/CachedFrame.cpp (206921 => 206922)
--- trunk/Source/WebCore/history/CachedFrame.cpp 2016-10-07 17:44:51 UTC (rev 206921)
+++ trunk/Source/WebCore/history/CachedFrame.cpp 2016-10-07 18:55:09 UTC (rev 206922)
@@ -248,8 +248,8 @@
m_document->domWindow()->willDestroyCachedFrame();
if (!m_isMainFrame) {
+ m_view->frame().loader().detachViewsAndDocumentLoader();
m_view->frame().detachFromPage();
- m_view->frame().loader().detachViewsAndDocumentLoader();
}
for (int i = m_childFrames.size() - 1; i >= 0; --i)
Modified: trunk/Tools/ChangeLog (206921 => 206922)
--- trunk/Tools/ChangeLog 2016-10-07 17:44:51 UTC (rev 206921)
+++ trunk/Tools/ChangeLog 2016-10-07 18:55:09 UTC (rev 206922)
@@ -1,3 +1,28 @@
+2016-10-07 Andreas Kling <[email protected]>
+
+ [WK2] didRemoveFrameFromHierarchy callback doesn't fire for subframes when evicting from PageCache.
+ <https://webkit.org/b/163098>
+ <rdar://problem/28663488>
+
+ Reviewed by Antti Koivisto.
+
+ Add an API test that puts a 10-subframe page into the page cache, then loads other pages
+ until the first page gets kicked out. The test succeeds if we receive didRemoveFrameFromHierarchy
+ callbacks for all the subframes.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2/DidRemoveFrameFromHiearchyInPageCache.cpp: Added.
+ (TestWebKitAPI::didFinishLoadForFrame):
+ (TestWebKitAPI::setPageLoaderClient):
+ (TestWebKitAPI::didReceivePageMessageFromInjectedBundle):
+ (TestWebKitAPI::setInjectedBundleClient):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKit2/DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp: Added.
+ (TestWebKitAPI::didRemoveFrameFromHierarchyCallback):
+ (TestWebKitAPI::DidRemoveFrameFromHiearchyInPageCacheTest::DidRemoveFrameFromHiearchyInPageCacheTest):
+ (TestWebKitAPI::DidRemoveFrameFromHiearchyInPageCacheTest::didCreatePage):
+ * TestWebKitAPI/Tests/WebKit2/many-iframes.html: Added.
+
2016-10-07 Emanuele Aina <[email protected]>
Replace bug URL placeholders independently of the short desc one
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (206921 => 206922)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-10-07 17:44:51 UTC (rev 206921)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-10-07 18:55:09 UTC (rev 206922)
@@ -434,6 +434,9 @@
A1DF74321C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */; };
A57A34F216AF6B2B00C2501F /* PageVisibilityStateWithWindowChanges.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A57A34F116AF69E200C2501F /* PageVisibilityStateWithWindowChanges.html */; };
A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */; };
+ AD57AC201DA7465000FF1BDE /* DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD57AC1E1DA7464D00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp */; };
+ AD57AC211DA7465B00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD57AC1F1DA7464D00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache.cpp */; };
+ AD57AC221DA7466E00FF1BDE /* many-iframes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = AD57AC1D1DA7463800FF1BDE /* many-iframes.html */; };
ADCEBBA61D9AE229002E283A /* Consume.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADCEBBA51D99D4CF002E283A /* Consume.cpp */; };
B55AD1D5179F3B3000AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55AD1D3179F3ABF00AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp */; };
B55F11B71517D03300915916 /* attributedStringCustomFont.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = B55F11B01517A2C400915916 /* attributedStringCustomFont.html */; };
@@ -554,6 +557,7 @@
dstPath = TestWebKitAPI.resources;
dstSubfolderSpec = 7;
files = (
+ AD57AC221DA7466E00FF1BDE /* many-iframes.html in Copy Resources */,
F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */,
F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */,
837A35F11D9A1E7D00663C57 /* DownloadRequestBlobURL.html in Copy Resources */,
@@ -1067,6 +1071,9 @@
A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WindowlessWebViewWithMedia.html; sourceTree = "<group>"; };
A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowlessWebViewWithMedia.mm; sourceTree = "<group>"; };
A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CheckedArithmeticOperations.cpp; sourceTree = "<group>"; };
+ AD57AC1D1DA7463800FF1BDE /* many-iframes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "many-iframes.html"; sourceTree = "<group>"; };
+ AD57AC1E1DA7464D00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp; sourceTree = "<group>"; };
+ AD57AC1F1DA7464D00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DidRemoveFrameFromHiearchyInPageCache.cpp; sourceTree = "<group>"; };
ADCEBBA51D99D4CF002E283A /* Consume.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Consume.cpp; sourceTree = "<group>"; };
B4039F9C15E6D8B3007255D6 /* MathExtras.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathExtras.cpp; sourceTree = "<group>"; };
B55AD1D1179F336600AC1494 /* PreventImageLoadWithAutoResizing.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = PreventImageLoadWithAutoResizing.mm; path = WebKit2ObjC/PreventImageLoadWithAutoResizing.mm; sourceTree = "<group>"; };
@@ -1628,6 +1635,8 @@
BC9096411255616000083756 /* WebKit2 */ = {
isa = PBXGroup;
children = (
+ AD57AC1E1DA7464D00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp */,
+ AD57AC1F1DA7464D00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache.cpp */,
0F139E741A423A4600F590F5 /* cocoa */,
C0C5D3BB14598B6F00A802A6 /* mac */,
BC90977B125571AE00083756 /* Resources */,
@@ -1826,6 +1835,7 @@
93AF4ECF1506F123007FD57E /* lots-of-images.html */,
2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */,
930AD401150698B30067970F /* lots-of-text.html */,
+ AD57AC1D1DA7463800FF1BDE /* many-iframes.html */,
51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */,
7A1458FB1AD5C03500E06772 /* mouse-button-listener.html */,
33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */,
@@ -2427,6 +2437,7 @@
7CCE7F081A411AE600447C4C /* PageLoadDidChangeLocationWithinPageForFrame.cpp in Sources */,
7CCE7EC71A411A7E00447C4C /* PageVisibilityStateWithWindowChanges.mm in Sources */,
7CCE7F091A411AE600447C4C /* ParentFrame.cpp in Sources */,
+ AD57AC211DA7465B00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache.cpp in Sources */,
7C83E0511D0A641800FEBCF3 /* ParsedContentRange.cpp in Sources */,
7CCE7F0A1A411AE600447C4C /* PasteboardNotifications.mm in Sources */,
7C83E0531D0A643A00FEBCF3 /* PendingAPIRequestURL.cpp in Sources */,
@@ -2592,6 +2603,7 @@
BC575BD9126F58E2006F0F12 /* PlatformUtilities.cpp in Sources */,
0F139E791A42457000F590F5 /* PlatformUtilitiesCocoa.mm in Sources */,
BC575BE0126F590D006F0F12 /* PlatformUtilitiesMac.mm in Sources */,
+ AD57AC201DA7465000FF1BDE /* DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp in Sources */,
B55AD1D5179F3B3000AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp in Sources */,
C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */,
51FCF7A11534B2A000104491 /* ShouldGoToBackForwardListItem_Bundle.cpp in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/DidRemoveFrameFromHiearchyInPageCache.cpp (0 => 206922)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/DidRemoveFrameFromHiearchyInPageCache.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/DidRemoveFrameFromHiearchyInPageCache.cpp 2016-10-07 18:55:09 UTC (rev 206922)
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2016 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 "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+
+#include <WebKit/WKString.h>
+
+namespace TestWebKitAPI {
+
+static bool finished = false;
+static int didRemoveFrameFromHierarchyCount;
+
+static void didFinishLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void*)
+{
+ // Only mark finished when the main frame loads
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ finished = true;
+}
+
+static void setPageLoaderClient(WKPageRef page)
+{
+ WKPageLoaderClientV1 loaderClient;
+ memset(&loaderClient, 0, sizeof(loaderClient));
+
+ loaderClient.base.version = 1;
+ loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+
+ WKPageSetPageLoaderClient(page, &loaderClient.base);
+}
+
+static void didReceivePageMessageFromInjectedBundle(WKPageRef, WKStringRef messageName, WKTypeRef, const void*)
+{
+ if (WKStringIsEqualToUTF8CString(messageName, "DidRemoveFrameFromHierarchy"))
+ ++didRemoveFrameFromHierarchyCount;
+}
+
+static void setInjectedBundleClient(WKPageRef page)
+{
+ WKPageInjectedBundleClientV0 injectedBundleClient = {
+ { 0, nullptr },
+ didReceivePageMessageFromInjectedBundle,
+ nullptr,
+ };
+ WKPageSetPageInjectedBundleClient(page, &injectedBundleClient.base);
+}
+
+TEST(WebKit2, DidRemoveFrameFromHiearchyInPageCache)
+{
+ WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("DidRemoveFrameFromHiearchyInPageCache"));
+ // Enable the page cache so we can test the WKBundlePageDidRemoveFrameFromHierarchyCallback API
+ WKContextSetCacheModel(context.get(), kWKCacheModelPrimaryWebBrowser);
+
+ PlatformWebView webView(context.get());
+ setPageLoaderClient(webView.page());
+ setInjectedBundleClient(webView.page());
+
+ finished = false;
+ WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("many-iframes", "html")).get());
+ Util::run(&finished);
+
+ // Perform a couple of loads so "many-iframes" gets kicked out of the PageCache.
+ finished = false;
+ WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple", "html")).get());
+ Util::run(&finished);
+
+ finished = false;
+ WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple2", "html")).get());
+ Util::run(&finished);
+
+ finished = false;
+ WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple3", "html")).get());
+ Util::run(&finished);
+
+ EXPECT_EQ(didRemoveFrameFromHierarchyCount, 10);
+}
+
+} // namespace TestWebKitAPI
+
+#endif
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp (0 => 206922)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp 2016-10-07 18:55:09 UTC (rev 206922)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2016 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 "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "InjectedBundleTest.h"
+
+#include "PlatformUtilities.h"
+#include <WebKit/WKBundlePage.h>
+
+namespace TestWebKitAPI {
+
+class DidRemoveFrameFromHiearchyInPageCacheTest : public InjectedBundleTest {
+public:
+ DidRemoveFrameFromHiearchyInPageCacheTest(const std::string& identifier);
+
+ virtual void didCreatePage(WKBundleRef, WKBundlePageRef);
+};
+
+static InjectedBundleTest::Register<DidRemoveFrameFromHiearchyInPageCacheTest> registrar("DidRemoveFrameFromHiearchyInPageCache");
+
+static unsigned didRemoveFrameFromHierarchyCount;
+
+void didRemoveFrameFromHierarchyCallback(WKBundlePageRef page, WKBundleFrameRef, WKTypeRef*, const void*)
+{
+ didRemoveFrameFromHierarchyCount++;
+
+ WKRetainPtr<WKStringRef> message(AdoptWK, WKStringCreateWithUTF8CString("DidRemoveFrameFromHierarchy"));
+ WKBundlePagePostMessage(page, message.get(), message.get());
+}
+
+DidRemoveFrameFromHiearchyInPageCacheTest::DidRemoveFrameFromHiearchyInPageCacheTest(const std::string& identifier)
+ : InjectedBundleTest(identifier)
+{
+}
+
+void DidRemoveFrameFromHiearchyInPageCacheTest::didCreatePage(WKBundleRef bundle, WKBundlePageRef page)
+{
+ WKBundlePageLoaderClientV8 pageLoaderClient;
+ memset(&pageLoaderClient, 0, sizeof(pageLoaderClient));
+
+ pageLoaderClient.base.version = 8;
+ pageLoaderClient.base.clientInfo = this;
+ pageLoaderClient.didRemoveFrameFromHierarchy = didRemoveFrameFromHierarchyCallback;
+
+ WKBundlePageSetPageLoaderClient(page, &pageLoaderClient.base);
+}
+
+} // namespace TestWebKitAPI
+
+#endif
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/many-iframes.html (0 => 206922)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/many-iframes.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/many-iframes.html 2016-10-07 18:55:09 UTC (rev 206922)
@@ -0,0 +1,15 @@
+<html>
+<body>
+ Simple HTML file with many iframes.
+ <iframe src=""
+ <iframe src=""
+ <iframe src=""
+ <iframe src=""
+ <iframe src=""
+ <iframe src=""
+ <iframe src=""
+ <iframe src=""
+ <iframe src=""
+ <iframe src=""
+</body>
+</html>