Changeset 251991 in webkit


Ignore:
Timestamp:
Nov 4, 2019 8:32:36 AM (4 years ago)
Author:
aestes@apple.com
Message:

REGRESSION (r251623): When downloading a QuickLook file, the web view navigates to a "The URL can't be shown" error page instead of staying on the current page
https://bugs.webkit.org/show_bug.cgi?id=203790
<rdar://problem/56795440>

Reviewed by Alex Christensen.

Source/WebCore:

When a PreviewConverter fails updating due to a call to PreviewConverter::failedUpdating(),
we should not dispatch previewConverterDidFailUpdating. LegacyPreviewLoader handles that
callback by calling ResourceLoader::didFail() with a WebKitErrorCannotShowURL error code,
but when downloading or cancelling we must fail with a
WebKitErrorFrameLoadInterruptedByPolicyChange error code instead.

This patch teaches PreviewConverter to distinguish between internal updating errors and
external calls to failedUpdating(), only dispatching previewConverterDidFailUpdating in the
former case.

Updated QuickLook API tests.

  • platform/PreviewConverter.cpp:

(WebCore::PreviewConverter::updateMainResource):
(WebCore::PreviewConverter::failedUpdating):
(WebCore::PreviewConverter::didFailUpdating):

  • platform/PreviewConverter.h:

Tools:

Tested that "download" and "cancel" policy decisions for QuickLook files result in a
provisional navigation failure with error code WebKitErrorFrameLoadInterruptedByPolicyChange.

  • TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm:

(-[QuickLookDelegate navigationError]):
(-[QuickLookDelegate _webView:didFailNavigation:withError:userInfo:]):
(-[QuickLookDelegate webView:didFailProvisionalNavigation:withError:]):
(TEST):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r251989 r251991  
     12019-11-04  Andy Estes  <aestes@apple.com>
     2
     3        REGRESSION (r251623): When downloading a QuickLook file, the web view navigates to a "The URL can't be shown" error page instead of staying on the current page
     4        https://bugs.webkit.org/show_bug.cgi?id=203790
     5        <rdar://problem/56795440>
     6
     7        Reviewed by Alex Christensen.
     8
     9        When a PreviewConverter fails updating due to a call to PreviewConverter::failedUpdating(),
     10        we should not dispatch previewConverterDidFailUpdating. LegacyPreviewLoader handles that
     11        callback by calling ResourceLoader::didFail() with a WebKitErrorCannotShowURL error code,
     12        but when downloading or cancelling we must fail with a
     13        WebKitErrorFrameLoadInterruptedByPolicyChange error code instead.
     14
     15        This patch teaches PreviewConverter to distinguish between internal updating errors and
     16        external calls to failedUpdating(), only dispatching previewConverterDidFailUpdating in the
     17        former case.
     18
     19        Updated QuickLook API tests.
     20
     21        * platform/PreviewConverter.cpp:
     22        (WebCore::PreviewConverter::updateMainResource):
     23        (WebCore::PreviewConverter::failedUpdating):
     24        (WebCore::PreviewConverter::didFailUpdating):
     25        * platform/PreviewConverter.h:
     26
    1272019-11-04  youenn fablet  <youenn@apple.com>
    228
  • trunk/Source/WebCore/platform/PreviewConverter.cpp

    r251623 r251991  
    7979    auto provider = m_provider.get();
    8080    if (!provider) {
    81         failedUpdating();
     81        didFailUpdating();
    8282        return;
    8383    }
     
    8787            appendFromBuffer(*buffer);
    8888        else
    89             failedUpdating();
     89            didFailUpdating();
    9090    });
    9191}
     
    125125    m_state = State::FailedUpdating;
    126126    platformFailedAppending();
    127 
    128     iterateClients([&](auto& client) {
    129         client.previewConverterDidFailUpdating(*this);
    130     });
    131127}
    132128
     
    193189    iterateClients([&](auto& client) {
    194190        client.previewConverterDidFailConverting(*this);
     191    });
     192}
     193
     194void PreviewConverter::didFailUpdating()
     195{
     196    failedUpdating();
     197
     198    iterateClients([&](auto& client) {
     199        client.previewConverterDidFailUpdating(*this);
    195200    });
    196201}
  • trunk/Source/WebCore/platform/PreviewConverter.h

    r251623 r251991  
    9898    void didAddClient(PreviewConverterClient&);
    9999    void didFailConvertingWithError(const ResourceError&);
     100    void didFailUpdating();
    100101    void replayToClient(PreviewConverterClient&);
    101102
  • trunk/Tools/ChangeLog

    r251990 r251991  
     12019-11-04  Andy Estes  <aestes@apple.com>
     2
     3        REGRESSION (r251623): When downloading a QuickLook file, the web view navigates to a "The URL can't be shown" error page instead of staying on the current page
     4        https://bugs.webkit.org/show_bug.cgi?id=203790
     5        <rdar://problem/56795440>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Tested that "download" and "cancel" policy decisions for QuickLook files result in a
     10        provisional navigation failure with error code WebKitErrorFrameLoadInterruptedByPolicyChange.
     11
     12        * TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm:
     13        (-[QuickLookDelegate navigationError]):
     14        (-[QuickLookDelegate _webView:didFailNavigation:withError:userInfo:]):
     15        (-[QuickLookDelegate webView:didFailProvisionalNavigation:withError:]):
     16        (TEST):
     17
    1182019-11-04  Peng Liu  <peng.liu6@apple.com>
    219
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm

    r251765 r251991  
    6464@property (nonatomic, readonly) BOOL didFinishQuickLookLoad;
    6565@property (nonatomic, readonly) BOOL didStartQuickLookLoad;
     66@property (nonatomic, readonly, nullable) NSError *navigationError;
    6667
    6768@end
     
    7273    NSUInteger _expectedFileSize;
    7374    RetainPtr<NSData> _expectedFileData;
     75    RetainPtr<NSError> _navigationError;
    7476    RetainPtr<NSString> _expectedFileName;
    7577    RetainPtr<NSString> _expectedFileType;
     
    114116}
    115117
     118- (nullable NSError *)navigationError
     119{
     120    return _navigationError.get();
     121}
     122
    116123- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
    117124{
     
    160167    EXPECT_FALSE(_didFailNavigation);
    161168    EXPECT_FALSE(_didFinishNavigation);
     169    EXPECT_NULL(_navigationError);
    162170    _didFailNavigation = YES;
     171    _navigationError = error;
    163172    isDone = true;
    164173}
     
    168177    EXPECT_FALSE(_didFailNavigation);
    169178    EXPECT_FALSE(_didFinishNavigation);
     179    EXPECT_NULL(_navigationError);
    170180    _didFailNavigation = YES;
     181    _navigationError = error;
    171182    isDone = true;
    172183}
     
    328339    auto delegate = adoptNS([[QuickLookDelegate alloc] initWithExpectedFileURL:pagesDocumentURL responsePolicy:WKNavigationResponsePolicyCancel]);
    329340    runTestDecideBeforeLoading(delegate.get(), [NSURLRequest requestWithURL:pagesDocumentURL]);
     341    EXPECT_EQ(WebKitErrorFrameLoadInterruptedByPolicyChange, [delegate navigationError].code);
    330342    EXPECT_FALSE([delegate didFinishNavigation]);
    331343    EXPECT_FALSE([delegate didFinishQuickLookLoad]);
     
    338350    auto delegate = adoptNS([[QuickLookDelegate alloc] initWithExpectedFileURL:pagesDocumentURL previewMIMEType:pagesDocumentPreviewMIMEType responsePolicy:WKNavigationResponsePolicyCancel]);
    339351    runTestDecideAfterLoading(delegate.get(), [NSURLRequest requestWithURL:pagesDocumentURL]);
     352    EXPECT_EQ(WebKitErrorFrameLoadInterruptedByPolicyChange, [delegate navigationError].code);
    340353    EXPECT_FALSE([delegate didFinishNavigation]);
    341354    EXPECT_TRUE([delegate didFailNavigation]);
     
    348361    auto delegate = adoptNS([[QuickLookDelegate alloc] initWithExpectedFileURL:pagesDocumentURL responsePolicy:_WKNavigationResponsePolicyBecomeDownload]);
    349362    runTestDecideBeforeLoading(delegate.get(), [NSURLRequest requestWithURL:pagesDocumentURL]);
     363    EXPECT_EQ(WebKitErrorFrameLoadInterruptedByPolicyChange, [delegate navigationError].code);
    350364    EXPECT_FALSE([delegate didFinishNavigation]);
    351365    EXPECT_FALSE([delegate didFinishQuickLookLoad]);
     
    361375    auto delegate = adoptNS([[QuickLookDelegate alloc] initWithExpectedFileURL:pagesDocumentURL previewMIMEType:pagesDocumentPreviewMIMEType responsePolicy:_WKNavigationResponsePolicyBecomeDownload]);
    362376    runTestDecideAfterLoading(delegate.get(), [NSURLRequest requestWithURL:pagesDocumentURL]);
     377    EXPECT_EQ(WebKitErrorFrameLoadInterruptedByPolicyChange, [delegate navigationError].code);
    363378    EXPECT_FALSE([delegate didFinishNavigation]);
    364379    EXPECT_TRUE([delegate didFailNavigation]);
Note: See TracChangeset for help on using the changeset viewer.