-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Safari can't open the page when navigating back from a remote HTTP UR…
…L to a local html file https://bugs.webkit.org/show_bug.cgi?id=260504 rdar://103697846 Reviewed by Brent Fulgham. When calling loadFile on a WKWebView, we create a sandbox extension in the UIProcess and send it to the WebProcess. In turn the WebProcess uses this to create a temporary extension for the network process. Without this, sandboxed apps such as Safari would be unable to load such local files. When doing a back/forward navigation to a history item for a file URL, we often get lucky and load the page from the back/forward cache. However, if the page was evicted from the cache (or wasn't cached in the first place), we end up using a fresh new process for the navigation. However, we were not issuing a sandbox extension and the load would fail. To address the issue, we now create a sandbox extension in ProvisionalPageProxy::goToBackForwardItem(), whenever we process-swap on back/forward navigation to a file URL. Note that Cocoa ports are only able to create sandbox extensions once the process has finished launching (and we have its PID). As a result, the call to maybeInitializeSandboxExtensionHandle() may fail when calling ProvisionalPageProxy::goToBackForwardItem() if the process is still launching. In this case, the sandbox extension gets created later on, when the process has finished launching and we're sending the queued IPC. This is the exact same approach that we were using for WebPage::LoadRequest, but I am now applying it to WebPage::GoToBackForwardItem IPC too. If the process is not done launching, we send a WebPage::GoToBackForwardItemWaitingForProcessLaunch IPC instead, which gets handled in WebProcessProxy::shouldSendPendingMessage(), similarly to WebPage::LoadRequestWaitingForProcessLaunch. At this point, we create the sandbox extensions and convert the IPC message into a regular WebPage::GoToBackForwardItem one. To simplify the code, I moved all the parameters for the WebPage::GoToBackForwardItem IPC to a new GoToBackForwardItemParameters structure with its generated IPC coders. I also added the new sandbox extension handle to this structure. * Source/WebKit/CMakeLists.txt: * Source/WebKit/DerivedSources-input.xcfilelist: * Source/WebKit/DerivedSources.make: * Source/WebKit/Shared/GoToBackForwardItemParameters.h: Added. * Source/WebKit/Shared/GoToBackForwardItemParameters.serialization.in: Added. * Source/WebKit/UIProcess/ProvisionalPageProxy.cpp: (WebKit::ProvisionalPageProxy::goToBackForwardItem): * Source/WebKit/UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::launchProcessForReload): (WebKit::WebPageProxy::goToBackForwardItem): * Source/WebKit/UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::shouldSendPendingMessage): * Source/WebKit/WebKit.xcodeproj/project.pbxproj: * Source/WebKit/WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::goToBackForwardItem): (WebKit::WebPage::goToBackForwardItemWaitingForProcessLaunch): * Source/WebKit/WebProcess/WebPage/WebPage.h: * Source/WebKit/WebProcess/WebPage/WebPage.messages.in: Canonical link: https://commits.webkit.org/267199@main
- Loading branch information
Showing
12 changed files
with
156 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2023 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "NetworkResourceLoadIdentifier.h" | ||
#include "SandboxExtension.h" | ||
#include "WebsitePoliciesData.h" | ||
#include <WebCore/BackForwardItemIdentifier.h> | ||
#include <WebCore/FrameLoaderTypes.h> | ||
#include <WebCore/ShouldTreatAsContinuingLoad.h> | ||
#include <wtf/text/WTFString.h> | ||
|
||
namespace WebKit { | ||
|
||
struct GoToBackForwardItemParameters { | ||
uint64_t navigationID; | ||
WebCore::BackForwardItemIdentifier backForwardItemID; | ||
WebCore::FrameLoadType backForwardType; | ||
WebCore::ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad; | ||
std::optional<WebsitePoliciesData> websitePolicies; | ||
bool lastNavigationWasAppInitiated; | ||
std::optional<NetworkResourceLoadIdentifier> existingNetworkResourceLoadIdentifierToResume; | ||
std::optional<String> topPrivatelyControlledDomain; | ||
SandboxExtension::Handle sandboxExtensionHandle; | ||
}; | ||
|
||
} // namespace WebKit |
33 changes: 33 additions & 0 deletions
33
Source/WebKit/Shared/GoToBackForwardItemParameters.serialization.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (C) 2023 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. | ||
|
||
struct WebKit::GoToBackForwardItemParameters { | ||
uint64_t navigationID; | ||
WebCore::BackForwardItemIdentifier backForwardItemID; | ||
WebCore::FrameLoadType backForwardType; | ||
WebCore::ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad; | ||
std::optional<WebKit::WebsitePoliciesData> websitePolicies; | ||
bool lastNavigationWasAppInitiated; | ||
std::optional<WebKit::NetworkResourceLoadIdentifier> existingNetworkResourceLoadIdentifierToResume; | ||
std::optional<String> topPrivatelyControlledDomain; | ||
WebKit::SandboxExtension::Handle sandboxExtensionHandle; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.