⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 252442 in webkit


Ignore:
Timestamp:
Nov 13, 2019, 5:59:52 PM (7 years ago)
Author:
pvollan@apple.com
Message:

REGRESSION: WKWebView navigation fails when navigating from about:blank
https://bugs.webkit.org/show_bug.cgi?id=203852
Source/WebKit:

<rdar://problem/56973112>

Reviewed by Brent Fulgham.

Previously, WebPageProxy::loadFile would unconditionally create a sandbox extension for the resource directory URL. Currently,
this method is calling WebPageProxy::maybeInitializeSandboxExtension to create a sandbox extension if needed. The sandbox
extension for the resource URL is not created if the WebContent process already has assumed access to the resource URL, which
is the case when loading the same file for the second time. The sandbox extension still needs to be issued in this case, since
the WebContent process is revoking its extension when the load is done. This patch restore the original behaviour by adding a
flag to WebPageProxy::maybeInitializeSandboxExtension to indicate whether the method should check if the process already has
assumed access.

API test: WKWebView.LoadRelativeFileURL

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle):
(WebKit::WebPageProxy::loadRequestWithNavigationShared):
(WebKit::WebPageProxy::loadFile):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::shouldSendPendingMessage):

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::loadRequestWaitingForProcessLaunch):
(WebKit::WebPage::loadRequestWaitingForPID): Deleted.

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:

Tools:

Reviewed by Brent Fulgham.

  • TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm:

(TEST):

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r252435 r252442  
     12019-11-13  Per Arne Vollan  <pvollan@apple.com>
     2
     3        REGRESSION: WKWebView navigation fails when navigating from about:blank
     4        https://bugs.webkit.org/show_bug.cgi?id=203852
     5        <rdar://problem/56973112>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Previously, WebPageProxy::loadFile would unconditionally create a sandbox extension for the resource directory URL. Currently,
     10        this method is calling WebPageProxy::maybeInitializeSandboxExtension to create a sandbox extension if needed. The sandbox
     11        extension for the resource URL is not created if the WebContent process already has assumed access to the resource URL, which
     12        is the case when loading the same file for the second time. The sandbox extension still needs to be issued in this case, since
     13        the WebContent process is revoking its extension when the load is done. This patch restore the original behaviour by adding a
     14        flag to WebPageProxy::maybeInitializeSandboxExtension to indicate whether the method should check if the process already has
     15        assumed access.
     16
     17        API test: WKWebView.LoadRelativeFileURL
     18
     19        * UIProcess/WebPageProxy.cpp:
     20        (WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle):
     21        (WebKit::WebPageProxy::loadRequestWithNavigationShared):
     22        (WebKit::WebPageProxy::loadFile):
     23        * UIProcess/WebPageProxy.h:
     24        * UIProcess/WebProcessProxy.cpp:
     25        (WebKit::WebProcessProxy::shouldSendPendingMessage):
     26        * WebProcess/WebPage/WebPage.cpp:
     27        (WebKit::WebPage::loadRequestWaitingForProcessLaunch):
     28        (WebKit::WebPage::loadRequestWaitingForPID): Deleted.
     29        * WebProcess/WebPage/WebPage.h:
     30        * WebProcess/WebPage/WebPage.messages.in:
     31
    1322019-11-13  Myles C. Maxfield  <mmaxfield@apple.com>
    233
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r252303 r252442  
    10831083}
    10841084
    1085 void WebPageProxy::maybeInitializeSandboxExtensionHandle(WebProcessProxy& process, const URL& url, const URL& resourceDirectoryURL, SandboxExtension::Handle& sandboxExtensionHandle)
     1085void WebPageProxy::maybeInitializeSandboxExtensionHandle(WebProcessProxy& process, const URL& url, const URL& resourceDirectoryURL, SandboxExtension::Handle& sandboxExtensionHandle, bool checkAssumedReadAccessToResourceURL)
    10861086{
    10871087    if (!url.isLocalFile())
     
    10961096
    10971097    if (!resourceDirectoryURL.isEmpty()) {
    1098         if (process.hasAssumedReadAccessToURL(resourceDirectoryURL))
     1098        if (checkAssumedReadAccessToResourceURL && process.hasAssumedReadAccessToURL(resourceDirectoryURL))
    10991099            return;
    11001100
     
    12271227        process->send(Messages::WebPage::LoadRequest(loadParameters), webPageID);
    12281228    else
    1229         process->send(Messages::WebPage::LoadRequestWaitingForPID(loadParameters, m_pageLoadState.resourceDirectoryURL(), m_identifier), webPageID);
     1229        process->send(Messages::WebPage::LoadRequestWaitingForProcessLaunch(loadParameters, m_pageLoadState.resourceDirectoryURL(), m_identifier, true), webPageID);
    12301230#else
    12311231    process->send(Messages::WebPage::LoadRequest(loadParameters), webPageID);
     
    12741274    loadParameters.shouldOpenExternalURLsPolicy = ShouldOpenExternalURLsPolicy::ShouldNotAllow;
    12751275    loadParameters.userData = UserData(process().transformObjectsToHandles(userData).get());
    1276     maybeInitializeSandboxExtensionHandle(m_process, fileURL, resourceDirectoryURL, loadParameters.sandboxExtensionHandle);
     1276    const bool checkAssumedReadAccessToResourceURL = false;
     1277    maybeInitializeSandboxExtensionHandle(m_process, fileURL, resourceDirectoryURL, loadParameters.sandboxExtensionHandle, checkAssumedReadAccessToResourceURL);
    12771278    addPlatformLoadParameters(loadParameters);
    12781279
    12791280#if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_AUDIT_TOKEN)
    12801281    if (m_process->isLaunching())
    1281         m_process->send(Messages::WebPage::LoadRequestWaitingForPID(loadParameters, resourceDirectoryURL, m_identifier), m_webPageID);
     1282        m_process->send(Messages::WebPage::LoadRequestWaitingForProcessLaunch(loadParameters, resourceDirectoryURL, m_identifier, checkAssumedReadAccessToResourceURL), m_webPageID);
    12821283    else
    12831284        m_process->send(Messages::WebPage::LoadRequest(loadParameters), m_webPageID);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r252303 r252442  
    16101610#endif
    16111611
    1612     void maybeInitializeSandboxExtensionHandle(WebProcessProxy&, const URL&, const URL& resourceDirectoryURL, SandboxExtension::Handle&);
     1612    void maybeInitializeSandboxExtensionHandle(WebProcessProxy&, const URL&, const URL& resourceDirectoryURL, SandboxExtension::Handle&, bool checkAssumedReadAccessToResourceURL = true);
    16131613
    16141614#if ENABLE(WEB_AUTHN)
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp

    r252418 r252442  
    315315{
    316316#if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_AUDIT_TOKEN)
    317     if (message.encoder->messageName() == "LoadRequestWaitingForPID") {
     317    if (message.encoder->messageName() == "LoadRequestWaitingForProcessLaunch") {
    318318        auto buffer = message.encoder->buffer();
    319319        auto bufferSize = message.encoder->bufferSize();
     
    322322        URL resourceDirectoryURL;
    323323        WebPageProxyIdentifier pageID;
    324         if (decoder->decode(loadParameters) && decoder->decode(resourceDirectoryURL) && decoder->decode(pageID)) {
     324        bool checkAssumedReadAccessToResourceURL;
     325        if (decoder->decode(loadParameters) && decoder->decode(resourceDirectoryURL) && decoder->decode(pageID) && decoder->decode(checkAssumedReadAccessToResourceURL)) {
    325326            if (auto* page = WebProcessProxy::webPage(pageID)) {
    326                 page->maybeInitializeSandboxExtensionHandle(static_cast<WebProcessProxy&>(*this), loadParameters.request.url(), resourceDirectoryURL, loadParameters.sandboxExtensionHandle);
     327                page->maybeInitializeSandboxExtensionHandle(static_cast<WebProcessProxy&>(*this), loadParameters.request.url(), resourceDirectoryURL, loadParameters.sandboxExtensionHandle, checkAssumedReadAccessToResourceURL);
    327328                send(Messages::WebPage::LoadRequest(loadParameters), decoder->destinationID());
    328329            }
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r252303 r252442  
    15561556}
    15571557
    1558 // LoadRequestWaitingForPID should never be sent to the WebProcess. It must always be converted to a LoadRequest message.
    1559 NO_RETURN void WebPage::loadRequestWaitingForPID(LoadParameters&&, URL&&, WebPageProxyIdentifier)
     1558// LoadRequestWaitingForProcessLaunch should never be sent to the WebProcess. It must always be converted to a LoadRequest message.
     1559NO_RETURN void WebPage::loadRequestWaitingForProcessLaunch(LoadParameters&&, URL&&, WebPageProxyIdentifier, bool)
    15601560{
    15611561    RELEASE_ASSERT_NOT_REACHED();
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r252303 r252442  
    13361336    void platformDidReceiveLoadParameters(const LoadParameters&);
    13371337    void loadRequest(LoadParameters&&);
    1338     NO_RETURN void loadRequestWaitingForPID(LoadParameters&&, URL&&, WebPageProxyIdentifier);
     1338    NO_RETURN void loadRequestWaitingForProcessLaunch(LoadParameters&&, URL&&, WebPageProxyIdentifier, bool);
    13391339    void loadData(LoadParameters&&);
    13401340    void loadAlternateHTML(LoadParameters&&);
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r252303 r252442  
    166166    LoadDataInFrame(IPC::DataReference data, String MIMEType, String encodingName, URL baseURL, WebCore::FrameIdentifier frameID)
    167167    LoadRequest(struct WebKit::LoadParameters loadParameters)
    168     LoadRequestWaitingForPID(struct WebKit::LoadParameters loadParameters, URL resourceDirectoryURL, WebKit::WebPageProxyIdentifier pageID)
     168    LoadRequestWaitingForProcessLaunch(struct WebKit::LoadParameters loadParameters, URL resourceDirectoryURL, WebKit::WebPageProxyIdentifier pageID, bool checkAssumedReadAccessToResourceURL)
    169169    LoadData(struct WebKit::LoadParameters loadParameters)
    170170    LoadAlternateHTML(struct WebKit::LoadParameters loadParameters)
  • trunk/Tools/ChangeLog

    r252441 r252442  
     12019-11-13  Per Arne Vollan  <pvollan@apple.com>
     2
     3        REGRESSION: WKWebView navigation fails when navigating from about:blank
     4        https://bugs.webkit.org/show_bug.cgi?id=203852
     5
     6        Reviewed by Brent Fulgham.
     7
     8        * TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm:
     9        (TEST):
     10
    1112019-11-13  Fujii Hironori  <Hironori.Fujii@sony.com>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm

    r250673 r252442  
    2929#import "Test.h"
    3030#import "TestNavigationDelegate.h"
     31#import <WebKit/WKProcessPoolPrivate.h>
    3132#import <WebKit/WebKit.h>
    3233#import <WebKit/WebViewPrivate.h>
     34#import <WebKit/_WKProcessPoolConfiguration.h>
    3335#import <wtf/RetainPtr.h>
    3436
     
    9395    EXPECT_WK_STREQ([webView _resourceDirectoryURL].path, fileURL.URLByDeletingLastPathComponent.path);
    9496}
     97
     98TEST(WKWebView, RepeatLoadFileURL)
     99{
     100    auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
     101    processPoolConfiguration.get().processSwapsOnNavigation = NO;
     102    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
     103
     104    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     105    [webViewConfiguration setProcessPool:processPool.get()];
     106
     107    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     108
     109    auto delegate = adoptNS([[TestNavigationDelegate alloc] init]);
     110    [webView setNavigationDelegate:delegate.get()];
     111   
     112    NSString *path = [NSBundle.mainBundle pathForResource:@"simple" ofType:@"html" inDirectory:@"TestWebKitAPI.resources"];
     113    NSURL *baseURL = [NSURL fileURLWithPath:path.stringByDeletingLastPathComponent];
     114    NSURL *fileURL = [NSURL fileURLWithPath:path.lastPathComponent relativeToURL:baseURL];
     115    EXPECT_NOT_NULL([webView loadFileURL:fileURL allowingReadAccessToURL:fileURL.URLByDeletingLastPathComponent]);
     116    [delegate waitForDidFinishNavigation];
     117    NSURL *aboutBlankURL = [NSURL URLWithString:@"about:blank"];
     118    [webView loadRequest:[NSURLRequest requestWithURL:aboutBlankURL]];
     119    [delegate waitForDidFinishNavigation];
     120    EXPECT_NOT_NULL([webView loadFileURL:fileURL allowingReadAccessToURL:fileURL.URLByDeletingLastPathComponent]);
     121    [delegate waitForDidFinishNavigation];
     122}
Note: See TracChangeset for help on using the changeset viewer.