Changeset 256381 in webkit


Ignore:
Timestamp:
Feb 11, 2020 3:32:10 PM (4 years ago)
Author:
youenn@apple.com
Message:

Parent service worker controller should be used for child iframe as per https://w3c.github.io/ServiceWorker/#control-and-use-window-client
https://bugs.webkit.org/show_bug.cgi?id=207506

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

  • web-platform-tests/service-workers/service-worker/local-url-inherit-controller.https-expected.txt:

Source/WebCore:

Instead of checking document URL protocol, implement the rules as per spec, in particular:

  • If http/https, do not reuse controller
  • If iframe has a unique origin, do not reuse controller
  • If iframe does not have same origin as parent, do not reuse controller.

Covered by rebased test.

  • loader/DocumentLoader.cpp:

(WebCore::isInheritingControllerFromParent):
(WebCore::DocumentLoader::commitData):
(WebCore::isLocalURL): Deleted.

LayoutTests:

  • http/tests/workers/service/serviceworkerclients-claim.https-expected.txt:

Rebased test since now the frame is doing a fetch that is no longer intercepted by the service worker,
and is thus failing due to CORS.

  • http/tests/workers/service/serviceworkerclients-claim.https.html:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r256379 r256381  
     12020-02-11  Youenn Fablet  <youenn@apple.com>
     2
     3        Parent service worker controller should be used for child iframe as per https://w3c.github.io/ServiceWorker/#control-and-use-window-client
     4        https://bugs.webkit.org/show_bug.cgi?id=207506
     5
     6        Reviewed by Darin Adler.
     7
     8        * http/tests/workers/service/serviceworkerclients-claim.https-expected.txt:
     9        Rebased test since now the frame is doing a fetch that is no longer intercepted by the service worker,
     10        and is thus failing due to CORS.
     11        * http/tests/workers/service/serviceworkerclients-claim.https.html:
     12
    1132020-02-11  Jason Lawrence  <lawrence.j@apple.com>
    214
  • trunk/LayoutTests/http/tests/workers/service/serviceworkerclients-claim.https-expected.txt

    r226361 r256381  
     1CONSOLE MESSAGE: Origin null is not allowed by Access-Control-Allow-Origin.
     2CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:8443/pinkelephant due to access control checks.
     3CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: Origin null is not allowed by Access-Control-Allow-Origin.
    14
    25
  • trunk/LayoutTests/http/tests/workers/service/serviceworkerclients-claim.https.html

    r226361 r256381  
    6161    var promise = new Promise((resolve, reject) => {
    6262        window.addEventListener("message", (event) => {
    63             resolve(event.data);
     63            reject("Received a message from iframe:" + event.data);
    6464        }, false);
    65         setTimeout(() => {  reject("Did not receive any message from iframe"); }, 5000);
     65        setTimeout(resolve, 100);
    6666    });
    6767    var frame = await withFrame("data:text/html," + htmlString);
    68     var result = await promise;
    69     assert_equals(result, "PASS");
     68    return promise;
    7069}, "Test data URL frame");
    7170
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r256207 r256381  
     12020-02-11  Youenn Fablet  <youenn@apple.com>
     2
     3        Parent service worker controller should be used for child iframe as per https://w3c.github.io/ServiceWorker/#control-and-use-window-client
     4        https://bugs.webkit.org/show_bug.cgi?id=207506
     5
     6        Reviewed by Darin Adler.
     7
     8        * web-platform-tests/service-workers/service-worker/local-url-inherit-controller.https-expected.txt:
     9
    1102020-02-07  Ryosuke Niwa  <rniwa@webkit.org>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/local-url-inherit-controller.https-expected.txt

    r238592 r256381  
    44FAIL Same-origin blob URL worker should inherit service worker controller. assert_equals: blob URL worker should inherit controller expected (string) "https://localhost:9443/service-workers/service-worker/resources/local-url-inherit-controller-worker.js" but got (object) null
    55PASS Same-origin blob URL worker should intercept fetch().
    6 FAIL Data URL iframe should not intercept fetch(). assert_equals: data URL iframe should not intercept fetch expected "" but got "intercepted"
     6PASS Data URL iframe should not intercept fetch().
    77FAIL Data URL worker should not inherit service worker controller. promise_test: Unhandled rejection with value: object "SecurityError: The operation is insecure."
    88FAIL Data URL worker should not intercept fetch(). promise_test: Unhandled rejection with value: object "SecurityError: The operation is insecure."
  • trunk/Source/WebCore/ChangeLog

    r256380 r256381  
     12020-02-11  Youenn Fablet  <youenn@apple.com>
     2
     3        Parent service worker controller should be used for child iframe as per https://w3c.github.io/ServiceWorker/#control-and-use-window-client
     4        https://bugs.webkit.org/show_bug.cgi?id=207506
     5
     6        Reviewed by Darin Adler.
     7
     8        Instead of checking document URL protocol, implement the rules as per spec, in particular:
     9        - If http/https, do not reuse controller
     10        - If iframe has a unique origin, do not reuse controller
     11        - If iframe does not have same origin as parent, do not reuse controller.
     12
     13        Covered by rebased test.
     14
     15        * loader/DocumentLoader.cpp:
     16        (WebCore::isInheritingControllerFromParent):
     17        (WebCore::DocumentLoader::commitData):
     18        (WebCore::isLocalURL): Deleted.
     19
    1202020-02-11  Zalan Bujtas  <zalan@apple.com>
    221
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r255961 r256381  
    10581058
    10591059#if ENABLE(SERVICE_WORKER)
    1060 static inline bool isLocalURL(const URL& url)
    1061 {
    1062     // https://fetch.spec.whatwg.org/#is-local
    1063     auto protocol = url.protocol().toStringWithoutCopying();
    1064     return equalLettersIgnoringASCIICase(protocol, "data") || equalLettersIgnoringASCIICase(protocol, "blob") || equalLettersIgnoringASCIICase(protocol, "about");
     1060// https://w3c.github.io/ServiceWorker/#control-and-use-window-client
     1061static inline bool shouldUseActiveServiceWorkerFromParent(const Document& document, const Document& parent)
     1062{
     1063    return !document.url().protocolIsInHTTPFamily() && !document.securityOrigin().isUnique() && parent.securityOrigin().canAccess(document.securityOrigin());
    10651064}
    10661065#endif
     
    10931092                m_frame->document()->setActiveServiceWorker(ServiceWorker::getOrCreate(*m_frame->document(), WTFMove(m_serviceWorkerRegistrationData->activeWorker.value())));
    10941093                m_serviceWorkerRegistrationData = { };
    1095             } else if (isLocalURL(m_frame->document()->url())) {
    1096                 if (auto* parent = m_frame->document()->parentDocument())
     1094            } else if (auto* parent = m_frame->document()->parentDocument()) {
     1095                if (shouldUseActiveServiceWorkerFromParent(*m_frame->document(), *parent))
    10971096                    m_frame->document()->setActiveServiceWorker(parent->activeServiceWorker());
    10981097            }
Note: See TracChangeset for help on using the changeset viewer.