Skip to content

Commit

Permalink
Safari can't open the page when navigating back from a remote HTTP UR…
Browse files Browse the repository at this point in the history
…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
cdumez committed Aug 23, 2023
1 parent 706e894 commit 6c6b1e0
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 17 deletions.
1 change: 1 addition & 0 deletions Source/WebKit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ set(WebKit_SERIALIZATION_IN_FILES
Shared/FrameTreeCreationParameters.serialization.in
Shared/FrameTreeNodeData.serialization.in
Shared/GPUProcessConnectionParameters.serialization.in
Shared/GoToBackForwardItemParameters.serialization.in
Shared/LayerTreeContext.serialization.in
Shared/LocalFrameCreationParameters.serialization.in
Shared/Model.serialization.in
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/DerivedSources-input.xcfilelist
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ $(PROJECT_DIR)/Shared/FrameTreeCreationParameters.serialization.in
$(PROJECT_DIR)/Shared/FrameTreeNodeData.serialization.in
$(PROJECT_DIR)/Shared/GPUProcessConnectionParameters.serialization.in
$(PROJECT_DIR)/Shared/Gamepad/GamepadData.serialization.in
$(PROJECT_DIR)/Shared/GoToBackForwardItemParameters.serialization.in
$(PROJECT_DIR)/Shared/HTTPSUpgrade/HTTPSUpgradeList.txt
$(PROJECT_DIR)/Shared/IPCConnectionTester.messages.in
$(PROJECT_DIR)/Shared/IPCStreamTester.messages.in
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/DerivedSources.make
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ SERIALIZATION_DESCRIPTION_FILES = \
Shared/FrameTreeNodeData.serialization.in \
Shared/Gamepad/GamepadData.serialization.in \
Shared/GPUProcessConnectionParameters.serialization.in \
Shared/GoToBackForwardItemParameters.serialization.in \
Shared/ios/DynamicViewportSizeUpdate.serialization.in \
Shared/ios/InteractionInformationAtPosition.serialization.in \
Shared/ios/WebAutocorrectionContext.serialization.in \
Expand Down
50 changes: 50 additions & 0 deletions Source/WebKit/Shared/GoToBackForwardItemParameters.h
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
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;
};
13 changes: 12 additions & 1 deletion Source/WebKit/UIProcess/ProvisionalPageProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "APIWebsitePolicies.h"
#include "DrawingAreaProxy.h"
#include "FormDataReference.h"
#include "GoToBackForwardItemParameters.h"
#include "HandleMessage.h"
#include "LocalFrameCreationParameters.h"
#include "Logging.h"
Expand Down Expand Up @@ -254,7 +255,17 @@ void ProvisionalPageProxy::goToBackForwardItem(API::Navigation& navigation, WebB
#endif

send(Messages::WebPage::UpdateBackForwardListForReattach(WTFMove(itemStates)));
send(Messages::WebPage::GoToBackForwardItem(navigation.navigationID(), item.itemID(), *navigation.backForwardFrameLoadType(), shouldTreatAsContinuingLoad, WTFMove(websitePoliciesData), m_page->lastNavigationWasAppInitiated(), existingNetworkResourceLoadIdentifierToResume, topPrivatelyControlledDomain));

SandboxExtension::Handle sandboxExtensionHandle;
URL itemURL { item.url() };
m_page->maybeInitializeSandboxExtensionHandle(m_process.get(), itemURL, item.resourceDirectoryURL(), sandboxExtensionHandle);

GoToBackForwardItemParameters parameters { navigation.navigationID(), item.itemID(), *navigation.backForwardFrameLoadType(), shouldTreatAsContinuingLoad, WTFMove(websitePoliciesData), m_page->lastNavigationWasAppInitiated(), existingNetworkResourceLoadIdentifierToResume, topPrivatelyControlledDomain, WTFMove(sandboxExtensionHandle) };
if (!m_process->isLaunching() || !itemURL.protocolIsFile())
send(Messages::WebPage::GoToBackForwardItem(parameters));
else
send(Messages::WebPage::GoToBackForwardItemWaitingForProcessLaunch(parameters, m_page->identifier()));

m_process->startResponsivenessTimer();
}

Expand Down
5 changes: 3 additions & 2 deletions Source/WebKit/UIProcess/WebPageProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include "FrameInfoData.h"
#include "FrameTreeCreationParameters.h"
#include "FrameTreeNodeData.h"
#include "GoToBackForwardItemParameters.h"
#include "LegacyGlobalSettings.h"
#include "LoadParameters.h"
#include "LoadedWebArchive.h"
Expand Down Expand Up @@ -1292,7 +1293,7 @@ RefPtr<API::Navigation> WebPageProxy::launchProcessForReload()
#endif

// We allow stale content when reloading a WebProcess that's been killed or crashed.
send(Messages::WebPage::GoToBackForwardItem(navigation->navigationID(), m_backForwardList->currentItem()->itemID(), FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No, std::nullopt, m_lastNavigationWasAppInitiated, std::nullopt, topPrivatelyControlledDomain));
send(Messages::WebPage::GoToBackForwardItem({ navigation->navigationID(), m_backForwardList->currentItem()->itemID(), FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No, std::nullopt, m_lastNavigationWasAppInitiated, std::nullopt, topPrivatelyControlledDomain, { } }));
m_process->startResponsivenessTimer();

if (shouldForceForegroundPriorityForClientNavigation())
Expand Down Expand Up @@ -2081,7 +2082,7 @@ RefPtr<API::Navigation> WebPageProxy::goToBackForwardItem(WebBackForwardListItem
topPrivatelyControlledDomain = WebCore::topPrivatelyControlledDomain(URL(item.url()).host().toString());
#endif

send(Messages::WebPage::GoToBackForwardItem(navigation ? navigation->navigationID() : 0, item.itemID(), frameLoadType, ShouldTreatAsContinuingLoad::No, std::nullopt, m_lastNavigationWasAppInitiated, std::nullopt, topPrivatelyControlledDomain));
send(Messages::WebPage::GoToBackForwardItem({ navigation ? navigation->navigationID() : 0, item.itemID(), frameLoadType, ShouldTreatAsContinuingLoad::No, std::nullopt, m_lastNavigationWasAppInitiated, std::nullopt, topPrivatelyControlledDomain, { } }));
m_process->startResponsivenessTimer();

return navigation;
Expand Down
23 changes: 23 additions & 0 deletions Source/WebKit/UIProcess/WebProcessProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "AuthenticatorManager.h"
#include "DataReference.h"
#include "DownloadProxyMap.h"
#include "GoToBackForwardItemParameters.h"
#include "LoadParameters.h"
#include "Logging.h"
#include "NetworkProcessConnectionInfo.h"
Expand Down Expand Up @@ -555,6 +556,28 @@ bool WebProcessProxy::shouldSendPendingMessage(const PendingMessage& message)
} else
ASSERT_NOT_REACHED();
return false;
} else if (message.encoder->messageName() == IPC::MessageName::WebPage_GoToBackForwardItemWaitingForProcessLaunch) {
auto buffer = message.encoder->buffer();
auto bufferSize = message.encoder->bufferSize();
auto decoder = IPC::Decoder::create(buffer, bufferSize, { });
ASSERT(decoder);
if (!decoder)
return false;

std::optional<GoToBackForwardItemParameters> parameters;
*decoder >> parameters;
if (!parameters)
return false;
WebPageProxyIdentifier pageID;
if (!decoder->decode(pageID))
return false;

if (auto page = WebProcessProxy::webPage(pageID)) {
if (auto* item = WebBackForwardListItem::itemForID(parameters->backForwardItemID))
page->maybeInitializeSandboxExtensionHandle(static_cast<WebProcessProxy&>(*this), URL { item->url() }, item->resourceDirectoryURL(), parameters->sandboxExtensionHandle);
}
send(Messages::WebPage::GoToBackForwardItem(*parameters), decoder->destinationID());
return false;
}
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions Source/WebKit/WebKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@
46C392292316EC4D008EED9B /* WebPageProxyIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C392282316EC4D008EED9B /* WebPageProxyIdentifier.h */; };
46C5B7CE27AADDD3000C5B47 /* RemoteWorkerFrameLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C5B7CD27AADDBE000C5B47 /* RemoteWorkerFrameLoaderClient.h */; };
46C5B7CF27AADDD6000C5B47 /* RemoteWorkerLibWebRTCProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C5B7CB27AADDBE000C5B47 /* RemoteWorkerLibWebRTCProvider.h */; };
46C71AC92A942E2900E459AF /* GoToBackForwardItemParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C71AC72A942E1800E459AF /* GoToBackForwardItemParameters.h */; };
46C916AA2799D0A2001A4E7C /* WebSharedWorkerServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C916A92799D09D001A4E7C /* WebSharedWorkerServer.h */; };
46CE3B1123D8C8490016A96A /* WebBackForwardListCounts.h in Headers */ = {isa = PBXBuildFile; fileRef = 46CE3B1023D8C83D0016A96A /* WebBackForwardListCounts.h */; };
46D48FCE2799D7E1007D2014 /* WebSharedWorkerServerToContextConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 46D48FCD2799D7DE007D2014 /* WebSharedWorkerServerToContextConnection.h */; };
Expand Down Expand Up @@ -4730,6 +4731,8 @@
46C5B7CB27AADDBE000C5B47 /* RemoteWorkerLibWebRTCProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteWorkerLibWebRTCProvider.h; sourceTree = "<group>"; };
46C5B7CC27AADDBE000C5B47 /* RemoteWorkerFrameLoaderClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteWorkerFrameLoaderClient.cpp; sourceTree = "<group>"; };
46C5B7CD27AADDBE000C5B47 /* RemoteWorkerFrameLoaderClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteWorkerFrameLoaderClient.h; sourceTree = "<group>"; };
46C71AC72A942E1800E459AF /* GoToBackForwardItemParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GoToBackForwardItemParameters.h; sourceTree = "<group>"; };
46C71AC82A942E1800E459AF /* GoToBackForwardItemParameters.serialization.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = GoToBackForwardItemParameters.serialization.in; sourceTree = "<group>"; };
46C916A82799D09D001A4E7C /* WebSharedWorkerServer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebSharedWorkerServer.cpp; sourceTree = "<group>"; };
46C916A92799D09D001A4E7C /* WebSharedWorkerServer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebSharedWorkerServer.h; sourceTree = "<group>"; };
46CE3B1023D8C83D0016A96A /* WebBackForwardListCounts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebBackForwardListCounts.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -7948,6 +7951,8 @@
5C2FEF0E29B665AF0005AB95 /* FrameTreeCreationParameters.serialization.in */,
5C121E8324101F7000486F9B /* FrameTreeNodeData.h */,
5C4AB4B128BD6FED0059E6CD /* FrameTreeNodeData.serialization.in */,
46C71AC72A942E1800E459AF /* GoToBackForwardItemParameters.h */,
46C71AC82A942E1800E459AF /* GoToBackForwardItemParameters.serialization.in */,
46AC532425DED81E003B57EC /* GPUProcessConnectionParameters.h */,
86D196BF29A7890F0083B077 /* GPUProcessConnectionParameters.serialization.in */,
1AC75A1A1B3368270056745B /* HangDetectionDisabler.h */,
Expand Down Expand Up @@ -14339,6 +14344,7 @@
BC06F43A12DBCCFB002D78DE /* GeolocationPermissionRequestProxy.h in Headers */,
F4CF1E9D25E40DCC000F9D73 /* GestureRecognizerConsistencyEnforcer.h in Headers */,
2DA944A41884E4F000ED86DB /* GestureTypes.h in Headers */,
46C71AC92A942E2900E459AF /* GoToBackForwardItemParameters.h in Headers */,
4614F13225DED875007006E7 /* GPUProcessConnectionParameters.h in Headers */,
2DA049B8180CCD0A00AAFA9E /* GraphicsLayerCARemote.h in Headers */,
C0CE72AD1247E78D00BC0EC4 /* HandleMessage.h in Headers */,
Expand Down
33 changes: 21 additions & 12 deletions Source/WebKit/WebProcess/WebPage/WebPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "FormDataReference.h"
#include "FrameTreeNodeData.h"
#include "GeolocationPermissionRequestManager.h"
#include "GoToBackForwardItemParameters.h"
#include "InjectUserScriptImmediately.h"
#include "InjectedBundle.h"
#include "InjectedBundleScriptWorld.h"
Expand Down Expand Up @@ -2085,41 +2086,49 @@ void WebPage::reload(uint64_t navigationID, OptionSet<WebCore::ReloadOption> rel
}
}

void WebPage::goToBackForwardItem(uint64_t navigationID, const BackForwardItemIdentifier& backForwardItemID, FrameLoadType backForwardType, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad, std::optional<WebsitePoliciesData>&& websitePolicies, bool lastNavigationWasAppInitiated, std::optional<NetworkResourceLoadIdentifier> existingNetworkResourceLoadIdentifierToResume, std::optional<String> topPrivatelyControlledDomain)
void WebPage::goToBackForwardItem(GoToBackForwardItemParameters&& parameters)
{
WEBPAGE_RELEASE_LOG(Loading, "goToBackForwardItem: navigationID=%" PRIu64 ", backForwardItemID=%s, shouldTreatAsContinuingLoad=%u, lastNavigationWasAppInitiated=%d, existingNetworkResourceLoadIdentifierToResume=%" PRIu64, navigationID, backForwardItemID.toString().utf8().data(), static_cast<unsigned>(shouldTreatAsContinuingLoad), lastNavigationWasAppInitiated, valueOrDefault(existingNetworkResourceLoadIdentifierToResume).toUInt64());
WEBPAGE_RELEASE_LOG(Loading, "goToBackForwardItem: navigationID=%" PRIu64 ", backForwardItemID=%s, shouldTreatAsContinuingLoad=%u, lastNavigationWasAppInitiated=%d, existingNetworkResourceLoadIdentifierToResume=%" PRIu64, parameters.navigationID, parameters.backForwardItemID.toString().utf8().data(), static_cast<unsigned>(parameters.shouldTreatAsContinuingLoad), parameters.lastNavigationWasAppInitiated, valueOrDefault(parameters.existingNetworkResourceLoadIdentifierToResume).toUInt64());
SendStopResponsivenessTimer stopper;

m_lastNavigationWasAppInitiated = lastNavigationWasAppInitiated;
m_sandboxExtensionTracker.beginLoad(m_mainFrame.ptr(), WTFMove(parameters.sandboxExtensionHandle));

m_lastNavigationWasAppInitiated = parameters.lastNavigationWasAppInitiated;
if (RefPtr localMainFrame = dynamicDowncast<LocalFrame>(corePage()->mainFrame())) {
if (RefPtr documentLoader = localMainFrame->loader().documentLoader())
documentLoader->setLastNavigationWasAppInitiated(lastNavigationWasAppInitiated);
documentLoader->setLastNavigationWasAppInitiated(parameters.lastNavigationWasAppInitiated);
}

WebProcess::singleton().webLoaderStrategy().setExistingNetworkResourceLoadIdentifierToResume(existingNetworkResourceLoadIdentifierToResume);
WebProcess::singleton().webLoaderStrategy().setExistingNetworkResourceLoadIdentifierToResume(parameters.existingNetworkResourceLoadIdentifierToResume);
auto resumingLoadScope = makeScopeExit([] {
WebProcess::singleton().webLoaderStrategy().setExistingNetworkResourceLoadIdentifierToResume(std::nullopt);
});

ASSERT(isBackForwardLoadType(backForwardType));
ASSERT(isBackForwardLoadType(parameters.backForwardType));

HistoryItem* item = WebBackForwardListProxy::itemForID(backForwardItemID);
HistoryItem* item = WebBackForwardListProxy::itemForID(parameters.backForwardItemID);
ASSERT(item);
if (!item)
return;

LOG(Loading, "In WebProcess pid %i, WebPage %" PRIu64 " is navigating to back/forward URL %s", getCurrentProcessID(), m_identifier.toUInt64(), item->url().string().utf8().data());

#if ENABLE(PUBLIC_SUFFIX_LIST)
if (topPrivatelyControlledDomain)
WebCore::setTopPrivatelyControlledDomain(URL(item->url().string()).host().toString(), *topPrivatelyControlledDomain);
if (parameters.topPrivatelyControlledDomain)
WebCore::setTopPrivatelyControlledDomain(URL(item->url().string()).host().toString(), *parameters.topPrivatelyControlledDomain);
#endif

ASSERT(!m_pendingNavigationID);
m_pendingNavigationID = navigationID;
m_pendingWebsitePolicies = WTFMove(websitePolicies);
m_pendingNavigationID = parameters.navigationID;
m_pendingWebsitePolicies = WTFMove(parameters.websitePolicies);

m_page->goToItem(*item, backForwardType, shouldTreatAsContinuingLoad);
m_page->goToItem(*item, parameters.backForwardType, parameters.shouldTreatAsContinuingLoad);
}

// GoToBackForwardItemWaitingForProcessLaunch should never be sent to the WebProcess. It must always be converted to a GoToBackForwardItem message.
void WebPage::goToBackForwardItemWaitingForProcessLaunch(GoToBackForwardItemParameters&&, WebKit::WebPageProxyIdentifier)
{
RELEASE_ASSERT_NOT_REACHED();
}

void WebPage::tryRestoreScrollPosition()
Expand Down
Loading

0 comments on commit 6c6b1e0

Please sign in to comment.