Diff
Modified: trunk/Source/WebKit2/ChangeLog (176573 => 176574)
--- trunk/Source/WebKit2/ChangeLog 2014-11-29 17:47:35 UTC (rev 176573)
+++ trunk/Source/WebKit2/ChangeLog 2014-11-29 21:12:55 UTC (rev 176574)
@@ -1,3 +1,16 @@
+2014-11-29 Anders Carlsson <[email protected]>
+
+ Crash when calling WKPageClose on the originated page from within createNewPage callback
+ https://bugs.webkit.org/show_bug.cgi?id=139099
+ <rdar://problem/19052564>
+
+ Reviewed by Sam Weinig.
+
+ Null check the namespace ID.
+
+ * UIProcess/Storage/StorageManager.cpp:
+ (WebKit::StorageManager::cloneSessionStorageNamespaceInternal):
+
2014-11-28 Tim Horton <[email protected]>
Stale userData is handed to WKView _actionMenuItemsForHitTestResult under prepareForMenu
Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp (176573 => 176574)
--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp 2014-11-29 17:47:35 UTC (rev 176573)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp 2014-11-29 21:12:55 UTC (rev 176574)
@@ -581,7 +581,12 @@
void StorageManager::cloneSessionStorageNamespaceInternal(uint64_t storageNamespaceID, uint64_t newStorageNamespaceID)
{
SessionStorageNamespace* sessionStorageNamespace = m_sessionStorageNamespaces.get(storageNamespaceID);
- ASSERT(sessionStorageNamespace);
+ if (!sessionStorageNamespace) {
+ // FIXME: We can get into this situation if someone closes the originating page from within a
+ // createNewPage callback. We bail for now, but we should really find a way to keep the session storage alive
+ // so we we'll clone the session storage correctly.
+ return;
+ }
SessionStorageNamespace* newSessionStorageNamespace = m_sessionStorageNamespaces.get(newStorageNamespaceID);
ASSERT(newSessionStorageNamespace);
Modified: trunk/Tools/ChangeLog (176573 => 176574)
--- trunk/Tools/ChangeLog 2014-11-29 17:47:35 UTC (rev 176573)
+++ trunk/Tools/ChangeLog 2014-11-29 21:12:55 UTC (rev 176574)
@@ -1,3 +1,23 @@
+2014-11-29 Anders Carlsson <[email protected]>
+
+ Crash when calling WKPageClose on the originated page from within createNewPage callback
+ https://bugs.webkit.org/show_bug.cgi?id=139099
+ <rdar://problem/19052564>
+
+ Reviewed by Sam Weinig.
+
+ Add a test.
+
+ * TestWebKitAPI/PlatformWebView.h:
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp: Added.
+ (TestWebKitAPI::runJavaScriptAlert):
+ (TestWebKitAPI::createNewPage):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKit2/close-from-within-create-page.html: Added.
+ * TestWebKitAPI/mac/PlatformWebViewMac.mm:
+ (TestWebKitAPI::PlatformWebView::PlatformWebView):
+
2014-11-28 Commit Queue <[email protected]>
Unreviewed, rolling out r176564.
Modified: trunk/Tools/TestWebKitAPI/PlatformWebView.h (176573 => 176574)
--- trunk/Tools/TestWebKitAPI/PlatformWebView.h 2014-11-29 17:47:35 UTC (rev 176573)
+++ trunk/Tools/TestWebKitAPI/PlatformWebView.h 2014-11-29 21:12:55 UTC (rev 176574)
@@ -52,7 +52,8 @@
class PlatformWebView {
public:
- PlatformWebView(WKContextRef, WKPageGroupRef = 0);
+ explicit PlatformWebView(WKContextRef, WKPageGroupRef = 0);
+ explicit PlatformWebView(WKPageRef relatedPage);
~PlatformWebView();
WKPageRef page() const;
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (176573 => 176574)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2014-11-29 17:47:35 UTC (rev 176573)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2014-11-29 21:12:55 UTC (rev 176574)
@@ -18,6 +18,8 @@
14F3B11315E45EAB00210069 /* SaturatedArithmeticOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14F3B11215E45EAB00210069 /* SaturatedArithmeticOperations.cpp */; };
1A02C84F125D4A8400E3F4BD /* Find.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A02C84E125D4A8400E3F4BD /* Find.cpp */; };
1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1A02C84B125D4A5E00E3F4BD /* find.html */; };
+ 1A50AA1E1A2A4E7000F4C345 /* CloseFromWithinCreatePage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A50AA1C1A2A4E7000F4C345 /* CloseFromWithinCreatePage.cpp */; };
+ 1A50AA201A2A51FC00F4C345 /* close-from-within-create-page.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1A50AA1F1A2A4EA500F4C345 /* close-from-within-create-page.html */; };
1A5FEFDD1270E2A3000E2921 /* EvaluateJavaScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5FEFDC1270E2A3000E2921 /* EvaluateJavaScript.cpp */; };
1A63479F183D72A4005B1707 /* all-content-in-one-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 93D3D19B17B1A7B000C7C415 /* all-content-in-one-iframe.html */; };
1A7BFC0C171A0BDB00BC5F64 /* WillSendSubmitEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A7BFC0A171A0BDB00BC5F64 /* WillSendSubmitEvent.mm */; };
@@ -147,9 +149,7 @@
93A7EB3D18FA63A4009E7670 /* URLExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93A7EB3C18FA63A4009E7670 /* URLExtras.mm */; };
93ABA80916DDAB91002DB2FA /* StringHasher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93ABA80816DDAB91002DB2FA /* StringHasher.cpp */; };
93AF4ECE1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93AF4ECD1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp */; };
- 93AF4ED01506F123007FD57E /* lots-of-images.html in Resources */ = {isa = PBXBuildFile; fileRef = 93AF4ECF1506F123007FD57E /* lots-of-images.html */; };
93AF4ED11506F130007FD57E /* lots-of-images.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 93AF4ECF1506F123007FD57E /* lots-of-images.html */; };
- 93D3D19C17B1A7B000C7C415 /* all-content-in-one-iframe.html in Resources */ = {isa = PBXBuildFile; fileRef = 93D3D19B17B1A7B000C7C415 /* all-content-in-one-iframe.html */; };
93D3D19E17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93D3D19D17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp */; };
93F1DB3114DA20760024C362 /* NewFirstVisuallyNonEmptyLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1DB3014DA20760024C362 /* NewFirstVisuallyNonEmptyLayout.cpp */; };
93F1DB3414DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1DB3314DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp */; };
@@ -306,6 +306,7 @@
51E5C7021919C3B200D8B3E1 /* simple2.html in Copy Resources */,
51E5C7031919C3B200D8B3E1 /* simple3.html in Copy Resources */,
290A9BB91735F63800D71BBC /* OpenNewWindow.html in Copy Resources */,
+ 1A50AA201A2A51FC00F4C345 /* close-from-within-create-page.html in Copy Resources */,
290F4275172A221C00939FF0 /* custom-protocol-sync-xhr.html in Copy Resources */,
C2CF975B16CEC71B0054E99D /* JSContextBackForwardCache1.html in Copy Resources */,
C2CF975A16CEC7140054E99D /* JSContextBackForwardCache2.html in Copy Resources */,
@@ -376,6 +377,8 @@
14F3B11215E45EAB00210069 /* SaturatedArithmeticOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SaturatedArithmeticOperations.cpp; sourceTree = "<group>"; };
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>"; };
+ 1A50AA1C1A2A4E7000F4C345 /* CloseFromWithinCreatePage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CloseFromWithinCreatePage.cpp; sourceTree = "<group>"; };
+ 1A50AA1F1A2A4EA500F4C345 /* close-from-within-create-page.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "close-from-within-create-page.html"; 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>"; };
1A7E8B33181208DE00AEB74A /* FragmentNavigation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FragmentNavigation.mm; sourceTree = "<group>"; };
@@ -841,11 +844,11 @@
BC9096411255616000083756 /* WebKit2 */ = {
isa = PBXGroup;
children = (
- 4A410F4B19AF7BD6002EBAB5 /* UserMedia.cpp */,
C0C5D3BB14598B6F00A802A6 /* mac */,
BC90977B125571AE00083756 /* Resources */,
BC246D8C132F115A00B56D7C /* AboutBlankLoad.cpp */,
7C8DDAA91735DE1D00EA5AC0 /* CloseThenTerminate.cpp */,
+ 1A50AA1C1A2A4E7000F4C345 /* CloseFromWithinCreatePage.cpp */,
BC246D98132F1FE100B56D7C /* CanHandleRequest.cpp */,
BC246D97132F1FE100B56D7C /* CanHandleRequest_Bundle.cpp */,
F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */,
@@ -915,6 +918,7 @@
51E5C7041919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp */,
C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */,
1AE72F47173EB214006362F0 /* TerminateTwice.cpp */,
+ 4A410F4B19AF7BD6002EBAB5 /* UserMedia.cpp */,
BC22D31314DC689800FFB1DD /* UserMessage.cpp */,
BC22D31714DC68B800FFB1DD /* UserMessage_Bundle.cpp */,
520BCF4B141EB09E00937EA8 /* WebArchive.cpp */,
@@ -980,6 +984,7 @@
C045F9461385C2F800C0F3CD /* 18-characters.html */,
F6B7BE9617469B7E008A3445 /* associate-form-controls.html */,
76E182DE15475A8300F1FADD /* auto-submitting-form.html */,
+ 1A50AA1F1A2A4EA500F4C345 /* close-from-within-create-page.html */,
290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */,
C5E1AFFD16B22179006CC1F2 /* execCopy.html */,
BC2D004A12A9FEB300E732A3 /* file-with-anchor.html */,
@@ -1248,8 +1253,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 93D3D19C17B1A7B000C7C415 /* all-content-in-one-iframe.html in Resources */,
- 93AF4ED01506F123007FD57E /* lots-of-images.html in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1412,6 +1415,7 @@
0F17BBD615AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp in Sources */,
290F4278172A232C00939FF0 /* CustomProtocolsSyncXHRTest.mm in Sources */,
C08587BF13FE956C001EF4E5 /* WebKitAgnosticTest.mm in Sources */,
+ 1A50AA1E1A2A4E7000F4C345 /* CloseFromWithinCreatePage.cpp in Sources */,
51FBBB4D1513D4E900822738 /* WebViewCanPasteURL.mm in Sources */,
37E38C34169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm in Sources */,
76E182DA1547550100F1FADD /* WillSendSubmitEvent.cpp in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp (0 => 176574)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp 2014-11-29 21:12:55 UTC (rev 176574)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2014 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"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+
+namespace TestWebKitAPI {
+
+static bool testDone;
+static std::unique_ptr<PlatformWebView> openedWebView;
+
+static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
+{
+ // FIXME: Check that the alert text matches the storage.
+ testDone = true;
+}
+
+static WKPageRef createNewPage(WKPageRef page, WKURLRequestRef urlRequest, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo)
+{
+ EXPECT_TRUE(openedWebView == nullptr);
+
+ openedWebView = std::make_unique<PlatformWebView>(page);
+
+ WKPageUIClientV5 uiClient;
+ memset(&uiClient, 0, sizeof(uiClient));
+
+ uiClient.base.version = 5;
+ uiClient.runJavaScriptAlert = runJavaScriptAlert;
+ WKPageSetPageUIClient(openedWebView->page(), &uiClient.base);
+
+ WKPageClose(page);
+
+ WKRetain(openedWebView->page());
+ return openedWebView->page();
+}
+
+TEST(WebKit2, CloseFromWithinCreatePage)
+{
+ WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+
+ PlatformWebView webView(context.get());
+
+ WKPageUIClientV5 uiClient;
+ memset(&uiClient, 0, sizeof(uiClient));
+
+ uiClient.base.version = 5;
+ uiClient.createNewPage = createNewPage;
+ uiClient.runJavaScriptAlert = runJavaScriptAlert;
+ WKPageSetPageUIClient(webView.page(), &uiClient.base);
+
+ WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("close-from-within-create-page", "html"));
+ WKPageLoadURL(webView.page(), url.get());
+
+ Util::run(&testDone);
+
+ openedWebView = nullptr;
+}
+
+}
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/close-from-within-create-page.html (0 => 176574)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/close-from-within-create-page.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/close-from-within-create-page.html 2014-11-29 21:12:55 UTC (rev 176574)
@@ -0,0 +1,16 @@
+<html>
+<script>
+function runTest()
+{
+ if (document.location.search === "?opened-window") {
+ alert(window.sessionStorage['storageKey'])
+ return;
+ }
+
+ window.sessionStorage['storageKey'] = 'value';
+ window.open("close-from-within-create-page.html?opened-window");
+}
+</script>
+<body _onload_="runTest()">
+</body>
+</html>
Modified: trunk/Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm (176573 => 176574)
--- trunk/Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm 2014-11-29 17:47:35 UTC (rev 176573)
+++ trunk/Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm 2014-11-29 21:12:55 UTC (rev 176574)
@@ -60,6 +60,21 @@
[m_window setReleasedWhenClosed:NO];
}
+PlatformWebView::PlatformWebView(WKPageRef relatedPage)
+{
+ NSRect rect = NSMakeRect(0, 0, 800, 600);
+ m_view = [[WKView alloc] initWithFrame:rect contextRef:WKPageGetContext(relatedPage) pageGroupRef:WKPageGetPageGroup(relatedPage) relatedToPage:relatedPage];
+ [m_view setWindowOcclusionDetectionEnabled:NO];
+
+ NSRect windowRect = NSOffsetRect(rect, -10000, [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000);
+ m_window = [[ActiveOffscreenWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
+ [m_window setColorSpace:[[NSScreen mainScreen] colorSpace]];
+ [[m_window contentView] addSubview:m_view];
+ [m_window orderBack:nil];
+ [m_window setAutodisplay:NO];
+ [m_window setReleasedWhenClosed:NO];
+}
+
PlatformWebView::~PlatformWebView()
{
[m_window close];