Diff
Modified: branches/safari-608.1.5.1-branch/Source/WebKit/ChangeLog (242491 => 242492)
--- branches/safari-608.1.5.1-branch/Source/WebKit/ChangeLog 2019-03-05 19:10:26 UTC (rev 242491)
+++ branches/safari-608.1.5.1-branch/Source/WebKit/ChangeLog 2019-03-05 19:10:30 UTC (rev 242492)
@@ -1,5 +1,45 @@
2019-03-05 Alan Coon <alanc...@apple.com>
+ Cherry-pick r242468. rdar://problem/47820581
+
+ Correctly handle sandbox extensions when the same WKWebView loads multiple file:// URLs.
+ <rdar://problem/47820581> and https://bugs.webkit.org/show_bug.cgi?id=195291
+
+ Reviewed by Tim Horton.
+
+ Source/WebKit:
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::SandboxExtensionTracker::shouldReuseCommittedSandboxExtension): If there is a pendingProvisionalSandboxExtension
+ then its existence should override our willingness to reuse the existing committed extension.
+ (WebKit::shouldReuseCommittedSandboxExtension): Deleted.
+ * WebProcess/WebPage/WebPage.h:
+
+ Tools:
+
+ Loading a file: URL into a WKWebView and then loading another file: url from a completely
+ different directory into that same WKWebView should work.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm: Added.
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242468 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-03-05 Brady Eidson <beid...@apple.com>
+
+ Correctly handle sandbox extensions when the same WKWebView loads multiple file:// URLs.
+ <rdar://problem/47820581> and https://bugs.webkit.org/show_bug.cgi?id=195291
+
+ Reviewed by Tim Horton.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::SandboxExtensionTracker::shouldReuseCommittedSandboxExtension): If there is a pendingProvisionalSandboxExtension
+ then its existence should override our willingness to reuse the existing committed extension.
+ (WebKit::shouldReuseCommittedSandboxExtension): Deleted.
+ * WebProcess/WebPage/WebPage.h:
+
+2019-03-05 Alan Coon <alanc...@apple.com>
+
Cherry-pick r242411. rdar://problem/47820581
Unreviewed, rolling out r242376.
Modified: branches/safari-608.1.5.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (242491 => 242492)
--- branches/safari-608.1.5.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-03-05 19:10:26 UTC (rev 242491)
+++ branches/safari-608.1.5.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-03-05 19:10:30 UTC (rev 242492)
@@ -4387,7 +4387,7 @@
m_pendingProvisionalSandboxExtension = WTFMove(pendingProvisionalSandboxExtension);
}
-static bool shouldReuseCommittedSandboxExtension(WebFrame* frame)
+bool WebPage::SandboxExtensionTracker::shouldReuseCommittedSandboxExtension(WebFrame* frame)
{
ASSERT(frame->isMainFrame());
@@ -4398,6 +4398,9 @@
if (isReload(frameLoadType))
return true;
+ if (m_pendingProvisionalSandboxExtension)
+ return false;
+
DocumentLoader* documentLoader = frameLoader.documentLoader();
DocumentLoader* provisionalDocumentLoader = frameLoader.provisionalDocumentLoader();
if (!documentLoader || !provisionalDocumentLoader)
Modified: branches/safari-608.1.5.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.h (242491 => 242492)
--- branches/safari-608.1.5.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-03-05 19:10:26 UTC (rev 242491)
+++ branches/safari-608.1.5.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-03-05 19:10:30 UTC (rev 242492)
@@ -733,6 +733,7 @@
private:
void setPendingProvisionalSandboxExtension(RefPtr<SandboxExtension>&&);
+ bool shouldReuseCommittedSandboxExtension(WebFrame*);
RefPtr<SandboxExtension> m_pendingProvisionalSandboxExtension;
RefPtr<SandboxExtension> m_provisionalSandboxExtension;
Modified: branches/safari-608.1.5.1-branch/Tools/ChangeLog (242491 => 242492)
--- branches/safari-608.1.5.1-branch/Tools/ChangeLog 2019-03-05 19:10:26 UTC (rev 242491)
+++ branches/safari-608.1.5.1-branch/Tools/ChangeLog 2019-03-05 19:10:30 UTC (rev 242492)
@@ -1,3 +1,43 @@
+2019-03-05 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r242468. rdar://problem/47820581
+
+ Correctly handle sandbox extensions when the same WKWebView loads multiple file:// URLs.
+ <rdar://problem/47820581> and https://bugs.webkit.org/show_bug.cgi?id=195291
+
+ Reviewed by Tim Horton.
+
+ Source/WebKit:
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::SandboxExtensionTracker::shouldReuseCommittedSandboxExtension): If there is a pendingProvisionalSandboxExtension
+ then its existence should override our willingness to reuse the existing committed extension.
+ (WebKit::shouldReuseCommittedSandboxExtension): Deleted.
+ * WebProcess/WebPage/WebPage.h:
+
+ Tools:
+
+ Loading a file: URL into a WKWebView and then loading another file: url from a completely
+ different directory into that same WKWebView should work.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm: Added.
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242468 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-03-05 Brady Eidson <beid...@apple.com>
+
+ Correctly handle sandbox extensions when the same WKWebView loads multiple file:// URLs.
+ <rdar://problem/47820581> and https://bugs.webkit.org/show_bug.cgi?id=195291
+
+ Reviewed by Tim Horton.
+
+ Loading a file: URL into a WKWebView and then loading another file: url from a completely
+ different directory into that same WKWebView should work.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm: Added.
+
2019-02-22 Babak Shafiei <bshaf...@apple.com>
Revert r241606. rdar://problem/47884404
Modified: branches/safari-608.1.5.1-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (242491 => 242492)
--- branches/safari-608.1.5.1-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-03-05 19:10:26 UTC (rev 242491)
+++ branches/safari-608.1.5.1-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-03-05 19:10:30 UTC (rev 242492)
@@ -209,6 +209,7 @@
5120C83E1E67678F0025B250 /* WebsiteDataStoreCustomPaths.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5120C83B1E674E350025B250 /* WebsiteDataStoreCustomPaths.html */; };
512C4C9E20EAA40D004945EA /* ResponsivenessTimerCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 512C4C9D20EAA405004945EA /* ResponsivenessTimerCrash.mm */; };
51393E221523952D005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51393E1D1523944A005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp */; };
+ 51396E1A222E516000A42FCE /* LoadFileURL.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51396E19222E4E8600A42FCE /* LoadFileURL.mm */; };
5142B2731517C8C800C32B19 /* ContextMenuCanCopyURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */; };
514958BE1F7427AC00E87BAD /* WKWebViewAutofillTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 514958BD1F7427AC00E87BAD /* WKWebViewAutofillTests.mm */; };
515BE16F1D428BB100DD7C68 /* StoreBlobToBeDeleted.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 515BE16E1D4288FF00DD7C68 /* StoreBlobToBeDeleted.html */; };
@@ -1568,6 +1569,7 @@
512C4C9D20EAA405004945EA /* ResponsivenessTimerCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResponsivenessTimerCrash.mm; sourceTree = "<group>"; };
51393E1D1523944A005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionBasic_Bundle.cpp; sourceTree = "<group>"; };
51393E1E1523944A005F39C5 /* DOMWindowExtensionBasic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionBasic.cpp; sourceTree = "<group>"; };
+ 51396E19222E4E8600A42FCE /* LoadFileURL.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadFileURL.mm; sourceTree = "<group>"; };
5142B2701517C88B00C32B19 /* ContextMenuCanCopyURL.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenuCanCopyURL.mm; sourceTree = "<group>"; };
5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ContextMenuCanCopyURL.html; sourceTree = "<group>"; };
514958BD1F7427AC00E87BAD /* WKWebViewAutofillTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewAutofillTests.mm; sourceTree = "<group>"; };
@@ -2515,6 +2517,7 @@
37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */,
A125478D1DB18B9400358564 /* LoadDataWithNilMIMEType.mm */,
4612C2B8210A6ABF00B788A6 /* LoadFileThenReload.mm */,
+ 51396E19222E4E8600A42FCE /* LoadFileURL.mm */,
57901FAC1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm */,
5774AA6721FBBF7800AF2A1B /* TestLoadOptimizer.mm */,
51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */,
@@ -4101,6 +4104,7 @@
7CCE7EFF1A411AE600447C4C /* LoadCanceledNoServerRedirectCallback.cpp in Sources */,
A125478F1DB18B9400358564 /* LoadDataWithNilMIMEType.mm in Sources */,
4612C2B9210A6ACE00B788A6 /* LoadFileThenReload.mm in Sources */,
+ 51396E1A222E516000A42FCE /* LoadFileURL.mm in Sources */,
5C838F7F1DB04F900082858F /* LoadInvalidURLRequest.mm in Sources */,
7C83E0C01D0A652700FEBCF3 /* LoadInvalidURLRequest.mm in Sources */,
7CCE7F001A411AE600447C4C /* LoadPageOnCrash.cpp in Sources */,
Added: branches/safari-608.1.5.1-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm (0 => 242492)
--- branches/safari-608.1.5.1-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm (rev 0)
+++ branches/safari-608.1.5.1-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm 2019-03-05 19:10:30 UTC (rev 242492)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2019 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"
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "TestNavigationDelegate.h"
+#import <WebKit/WebKit.h>
+#import <wtf/RetainPtr.h>
+
+
+TEST(WKWebView, LoadTwoFiles)
+{
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+ auto delegate = adoptNS([[TestNavigationDelegate alloc] init]);
+ [webView setNavigationDelegate:delegate.get()];
+
+ NSURL *file = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+ [webView loadFileURL:file allowingReadAccessToURL:file.URLByDeletingLastPathComponent];
+ [delegate waitForDidFinishNavigation];
+
+ // Load a second file: resource that is in a completely different directory from the above
+ file = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+ NSURL *targetURL = [NSURL fileURLWithPath:[@"~/Library/WebKit/TestWebKitAPI/simple2.html" stringByExpandingTildeInPath]];
+ [[NSFileManager defaultManager] createDirectoryAtURL:targetURL.URLByDeletingLastPathComponent withIntermediateDirectories:YES attributes:nil error:nil];
+ [[NSFileManager defaultManager] removeItemAtURL:targetURL error:nil];
+ [[NSFileManager defaultManager] copyItemAtURL:file toURL:targetURL error:nil];
+
+ // If this second load succeeds (e.g. doesn't timeout due to a sandbox violation) the test passes
+ [webView loadFileURL:targetURL allowingReadAccessToURL:targetURL.URLByDeletingLastPathComponent];
+ [delegate waitForDidFinishNavigation];
+}