Changeset 229349 in webkit


Ignore:
Timestamp:
Mar 6, 2018 5:15:37 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

didReceiveServerRedirectForProvisionalNavigation is not called in case of document redirection with service worker registration change
https://bugs.webkit.org/show_bug.cgi?id=183299
<rdar://problem/37547029>

Patch by Youenn Fablet <youenn@apple.com> on 2018-03-06
Reviewed by Alex Christensen.

Source/WebCore:

In case of redirection with service worker registration change, we cancel the load and create a new one.
This prevent ResourceLoader::willSendRequestInternal to call the didReceiveServerRedirectForProvisionalNavigation
callback. We thus explictly call this callback after restarting the load with the new service worker step.
We only call this callback if the main resource is there as we do not want to call it if it was blocked by content extension.

Test: http/wpt/service-workers/navigation-redirect-main-frame.https.html

  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::restartLoadingDueToServiceWorkerRegistrationChange):

Tools:

Add support for checking whether this callback is called.
Used in the added layout test.

  • WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::didReceiveServerRedirectForProvisionalNavigation const):
(WTR::TestRunner::clearDidReceiveServerRedirectForProvisionalNavigation):

  • WebKitTestRunner/InjectedBundle/TestRunner.h:
  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::createOtherPage):
(WTR::TestController::resetStateToConsistentValues):
(WTR::TestController::didReceiveServerRedirectForProvisionalNavigation):

  • WebKitTestRunner/TestController.h:

(WTR::TestController::didReceiveServerRedirectForProvisionalNavigation const):
(WTR::TestController::clearDidReceiveServerRedirectForProvisionalNavigation):

  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

  • http/wpt/service-workers/navigation-redirect-main-frame-worker.js: Added.
  • http/wpt/service-workers/navigation-redirect-main-frame.https-expected.txt: Added.
  • http/wpt/service-workers/navigation-redirect-main-frame.https.html: Added.
Location:
trunk
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r229348 r229349  
     12018-03-06  Youenn Fablet  <youenn@apple.com>
     2
     3        didReceiveServerRedirectForProvisionalNavigation is not called in case of document redirection with service worker registration change
     4        https://bugs.webkit.org/show_bug.cgi?id=183299
     5        <rdar://problem/37547029>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * http/wpt/service-workers/navigation-redirect-main-frame-worker.js: Added.
     10        * http/wpt/service-workers/navigation-redirect-main-frame.https-expected.txt: Added.
     11        * http/wpt/service-workers/navigation-redirect-main-frame.https.html: Added.
     12
    1132018-03-06  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r229347 r229349  
     12018-03-06  Youenn Fablet  <youenn@apple.com>
     2
     3        didReceiveServerRedirectForProvisionalNavigation is not called in case of document redirection with service worker registration change
     4        https://bugs.webkit.org/show_bug.cgi?id=183299
     5        <rdar://problem/37547029>
     6
     7        Reviewed by Alex Christensen.
     8
     9        In case of redirection with service worker registration change, we cancel the load and create a new one.
     10        This prevent ResourceLoader::willSendRequestInternal to call the didReceiveServerRedirectForProvisionalNavigation
     11        callback. We thus explictly call this callback after restarting the load with the new service worker step.
     12        We only call this callback if the main resource is there as we do not want to call it if it was blocked by content extension.
     13
     14        Test: http/wpt/service-workers/navigation-redirect-main-frame.https.html
     15
     16        * loader/DocumentLoader.cpp:
     17        (WebCore::DocumentLoader::restartLoadingDueToServiceWorkerRegistrationChange):
     18
    1192018-03-06  Basuke Suzuki  <Basuke.Suzuki@sony.com>
    220
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r229323 r229349  
    696696    clearMainResource();
    697697
     698    ASSERT(!isCommitted());
    698699    m_serviceWorkerRegistrationData = WTFMove(registrationData);
    699700    loadMainResource(WTFMove(request));
     701
     702    if (m_mainResource)
     703        frameLoader()->client().dispatchDidReceiveServerRedirectForProvisionalLoad();
    700704}
    701705#endif
  • trunk/Tools/ChangeLog

    r229341 r229349  
     12018-03-06  Youenn Fablet  <youenn@apple.com>
     2
     3        didReceiveServerRedirectForProvisionalNavigation is not called in case of document redirection with service worker registration change
     4        https://bugs.webkit.org/show_bug.cgi?id=183299
     5        <rdar://problem/37547029>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Add support for checking whether this callback is called.
     10        Used in the added layout test.
     11
     12        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     13        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     14        (WTR::TestRunner::didReceiveServerRedirectForProvisionalNavigation const):
     15        (WTR::TestRunner::clearDidReceiveServerRedirectForProvisionalNavigation):
     16        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     17        * WebKitTestRunner/TestController.cpp:
     18        (WTR::TestController::createOtherPage):
     19        (WTR::TestController::resetStateToConsistentValues):
     20        (WTR::TestController::didReceiveServerRedirectForProvisionalNavigation):
     21        * WebKitTestRunner/TestController.h:
     22        (WTR::TestController::didReceiveServerRedirectForProvisionalNavigation const):
     23        (WTR::TestController::clearDidReceiveServerRedirectForProvisionalNavigation):
     24        * WebKitTestRunner/TestInvocation.cpp:
     25        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     26
    1272018-03-06  Chris Dumez  <cdumez@apple.com>
    228
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r229341 r229349  
    163163    void setDefersLoading(boolean flag);
    164164    void setStopProvisionalFrameLoads();
     165
     166    readonly attribute boolean didReceiveServerRedirectForProvisionalNavigation;
     167    void clearDidReceiveServerRedirectForProvisionalNavigation();
    165168
    166169    // Focus testing.
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r229209 r229349  
    621621}
    622622
     623bool TestRunner::didReceiveServerRedirectForProvisionalNavigation() const
     624{
     625    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("DidReceiveServerRedirectForProvisionalNavigation"));
     626    WKTypeRef returnData = 0;
     627
     628    WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), 0, &returnData);
     629    return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
     630}
     631
     632void TestRunner::clearDidReceiveServerRedirectForProvisionalNavigation()
     633{
     634    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ClearDidReceiveServerRedirectForProvisionalNavigation"));
     635    WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), 0, nullptr);
     636}
     637
    623638void TestRunner::setPageVisibility(JSStringRef state)
    624639{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r229341 r229349  
    215215    bool isPolicyDelegateEnabled() const { return m_policyDelegateEnabled; }
    216216    bool isPolicyDelegatePermissive() const { return m_policyDelegatePermissive; }
     217
     218    bool didReceiveServerRedirectForProvisionalNavigation() const;
     219    void clearDidReceiveServerRedirectForProvisionalNavigation();
    217220
    218221    bool waitToDump() const { return m_waitToDump; }
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r229177 r229349  
    305305        decidePolicyForPluginLoad,
    306306        0, // didStartProvisionalNavigation
    307         0, // didReceiveServerRedirectForProvisionalNavigation
     307        didReceiveServerRedirectForProvisionalNavigation,
    308308        0, // didFailProvisionalNavigation
    309309        0, // didCommitNavigation
     
    579579        decidePolicyForPluginLoad,
    580580        0, // didStartProvisionalNavigation
    581         0, // didReceiveServerRedirectForProvisionalNavigation
     581        didReceiveServerRedirectForProvisionalNavigation,
    582582        0, // didFailProvisionalNavigation
    583583        didCommitNavigation,
     
    864864   
    865865    statisticsResetToConsistentState();
     866
     867    m_didReceiveServerRedirectForProvisionalNavigation = false;
    866868
    867869    // Reset main page back to about:blank
     
    16221624}
    16231625
     1626void TestController::didReceiveServerRedirectForProvisionalNavigation(WKPageRef page, WKNavigationRef navigation, WKTypeRef userData, const void* clientInfo)
     1627{
     1628    static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveServerRedirectForProvisionalNavigation(page, navigation, userData);
     1629}
     1630
    16241631bool TestController::canAuthenticateAgainstProtectionSpace(WKPageRef page, WKProtectionSpaceRef protectionSpace, const void* clientInfo)
    16251632{
     
    17251732{
    17261733    mainWebView()->focus();
     1734}
     1735
     1736void TestController::didReceiveServerRedirectForProvisionalNavigation(WKPageRef page, WKNavigationRef navigation, WKTypeRef userData)
     1737{
     1738    m_didReceiveServerRedirectForProvisionalNavigation = true;
     1739    return;
    17271740}
    17281741
  • trunk/Tools/WebKitTestRunner/TestController.h

    r229177 r229349  
    209209    uint64_t domCacheSize(WKStringRef origin);
    210210
     211    bool didReceiveServerRedirectForProvisionalNavigation() const { return m_didReceiveServerRedirectForProvisionalNavigation; }
     212    void clearDidReceiveServerRedirectForProvisionalNavigation() { m_didReceiveServerRedirectForProvisionalNavigation = false; }
     213
    211214private:
    212215    WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(WKContextConfigurationRef);
     
    313316    static void unavailablePluginButtonClicked(WKPageRef, WKPluginUnavailabilityReason, WKDictionaryRef, const void*);
    314317
     318    static void didReceiveServerRedirectForProvisionalNavigation(WKPageRef, WKNavigationRef, WKTypeRef, const void*);
     319    void didReceiveServerRedirectForProvisionalNavigation(WKPageRef, WKNavigationRef, WKTypeRef);
     320
    315321    static bool canAuthenticateAgainstProtectionSpace(WKPageRef, WKProtectionSpaceRef, const void*);
    316322    bool canAuthenticateAgainstProtectionSpace(WKPageRef, WKProtectionSpaceRef);
     
    419425    bool m_shouldDecideResponsePolicyAfterDelay { false };
    420426
     427    bool m_didReceiveServerRedirectForProvisionalNavigation { false };
     428
    421429    WKRetainPtr<WKArrayRef> m_openPanelFileURLs;
    422430
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r229177 r229349  
    803803    }
    804804
     805    if (WKStringIsEqualToUTF8CString(messageName, "DidReceiveServerRedirectForProvisionalNavigation")) {
     806        WKRetainPtr<WKBooleanRef> result(AdoptWK, WKBooleanCreate(TestController::singleton().didReceiveServerRedirectForProvisionalNavigation()));
     807        return result;
     808    }
     809
     810    if (WKStringIsEqualToUTF8CString(messageName, "ClearDidReceiveServerRedirectForProvisionalNavigation")) {
     811        TestController::singleton().clearDidReceiveServerRedirectForProvisionalNavigation();
     812        return nullptr;
     813    }
     814
    805815    if (WKStringIsEqualToUTF8CString(messageName, "SecureEventInputIsEnabled")) {
    806816#if PLATFORM(MAC) && !PLATFORM(IOS)
Note: See TracChangeset for help on using the changeset viewer.