Changeset 225296 in webkit


Ignore:
Timestamp:
Nov 29, 2017, 2:19:23 PM (8 years ago)
Author:
Chris Dumez
Message:

Start exposing self.registration inside service workers
https://bugs.webkit.org/show_bug.cgi?id=180162

Reviewed by Brady Eidson.

LayoutTests/imported/w3c:

  • web-platform-tests/service-workers/service-worker/redirected-response.https-expected.txt:

Source/WebCore:

Start exposing self.registration inside service workers as per:

This is very initial support:

  • The operations on the registration (such as update) will reject the promise for now.
  • The registration's service workers are not yet populated.

This will be implemented in a follow-up.

Tests: http/tests/workers/service/ServiceWorkerGlobalScope_registration_SameObject.html

http/tests/workers/service/self_registration.html

  • bindings/js/JSServiceWorkerGlobalScopeCustom.cpp:

(WebCore::JSServiceWorkerGlobalScope::visitAdditionalChildren):

  • workers/service/ServiceWorkerContainer.cpp:

(WebCore::ServiceWorkerContainer::addRegistration):

  • workers/service/ServiceWorkerContextData.cpp:

(WebCore::ServiceWorkerContextData::isolatedCopy const):

  • workers/service/ServiceWorkerContextData.h:

(WebCore::ServiceWorkerContextData::encode const):
(WebCore::ServiceWorkerContextData::decode):

  • workers/service/ServiceWorkerGlobalScope.cpp:

(WebCore::ServiceWorkerGlobalScope::ServiceWorkerGlobalScope):

  • workers/service/ServiceWorkerGlobalScope.h:

(WebCore::ServiceWorkerGlobalScope::registration):

  • workers/service/server/SWServer.cpp:

(WebCore::SWServer::updateWorker):
(WebCore::SWServer::installContextData):

  • workers/service/server/SWServer.h:
  • workers/service/server/SWServerJobQueue.cpp:

(WebCore::SWServerJobQueue::scriptFetchFinished):

LayoutTests:

Add layout test coverage.

Skip test that covers self.registration.update() because it now times out. We do not support update()
on registrations inside service workers yet so the test times out waiting for the updatefound event
on the registration.

  • http/tests/workers/service/ServiceWorkerGlobalScope_registration_SameObject-expected.txt: Added.
  • http/tests/workers/service/ServiceWorkerGlobalScope_registration_SameObject.html: Added.
  • http/tests/workers/service/resources/ServiceWorkerGlobalScope_registration_SameObject-worker.js: Added.
  • http/tests/workers/service/resources/self_registration-worker.js: Added.
  • http/tests/workers/service/self_registration-expected.txt: Added.
  • http/tests/workers/service/self_registration.html: Added.
Location:
trunk
Files:
6 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r225281 r225296  
     12017-11-29  Chris Dumez  <cdumez@apple.com>
     2
     3        Start exposing self.registration inside service workers
     4        https://bugs.webkit.org/show_bug.cgi?id=180162
     5
     6        Reviewed by Brady Eidson.
     7
     8        Add layout test coverage.
     9
     10        * TestExpectations:
     11        Skip test that covers self.registration.update() because it now times out. We do not support update()
     12        on registrations inside service workers yet so the test times out waiting for the updatefound event
     13        on the registration.
     14
     15        * http/tests/workers/service/ServiceWorkerGlobalScope_registration_SameObject-expected.txt: Added.
     16        * http/tests/workers/service/ServiceWorkerGlobalScope_registration_SameObject.html: Added.
     17        * http/tests/workers/service/resources/ServiceWorkerGlobalScope_registration_SameObject-worker.js: Added.
     18        * http/tests/workers/service/resources/self_registration-worker.js: Added.
     19        * http/tests/workers/service/self_registration-expected.txt: Added.
     20        * http/tests/workers/service/self_registration.html: Added.
     21
    1222017-11-29  Javier M. Mellid  <jmunhoz@igalia.com>
    223
  • trunk/LayoutTests/TestExpectations

    r225269 r225296  
    147147imported/w3c/web-platform-tests/fetch/api/abort/general-serviceworker.https.html [ Skip ]
    148148imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/extendable-message-event.https.html [ Skip ]
    149 imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/registration-attribute.https.html [ Skip ]
    150149imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/unregister.https.html [ Skip ]
     150imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/update.https.html [ Skip ]
    151151imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall-on-evaluation.https.html [ Skip ]
    152152imported/w3c/web-platform-tests/service-workers/service-worker/detached-context.https.html [ Skip ]
     
    169169imported/w3c/web-platform-tests/service-workers/service-worker/navigation-preload/redirect.https.html [ Skip ]
    170170imported/w3c/web-platform-tests/service-workers/service-worker/navigation-preload/request-headers.https.html [ Skip ]
     171imported/w3c/web-platform-tests/service-workers/service-worker/navigation-redirect.https.html [ Skip ]
    171172imported/w3c/web-platform-tests/service-workers/service-worker/postmessage.https.html [ Skip ]
    172173imported/w3c/web-platform-tests/service-workers/service-worker/postmessage-msgport-to-client.https.html [ Skip ]
     
    195196imported/w3c/web-platform-tests/service-workers/service-worker/multiple-update.https.html [ Pass Failure ]
    196197imported/w3c/web-platform-tests/service-workers/service-worker/performance-timeline.https.html [ Pass Failure ]
    197 imported/w3c/web-platform-tests/service-workers/service-worker/navigation-redirect.https.html [ Pass Failure ]
    198198webkit.org/b/179452 imported/w3c/web-platform-tests/service-workers/service-worker/register-same-scope-different-script-url.https.html [ Pass Failure ]
    199199webkit.org/b/179194 imported/w3c/web-platform-tests/service-workers/service-worker/registration-mime-types.https.html [ Pass Failure ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r225294 r225296  
     12017-11-29  Chris Dumez  <cdumez@apple.com>
     2
     3        Start exposing self.registration inside service workers
     4        https://bugs.webkit.org/show_bug.cgi?id=180162
     5
     6        Reviewed by Brady Eidson.
     7
     8        * web-platform-tests/service-workers/service-worker/redirected-response.https-expected.txt:
     9
    1102017-11-29  Youenn Fablet  <youenn@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/registration-attribute.https-expected.txt

    r224730 r225296  
    11
    2 Harness Error (TIMEOUT), message = null
    32
    4 FAIL Verify registration attributes on ServiceWorkerGlobalScope assert_unreached: unregister and register should not fail: TypeError: null is not an object (evaluating 'self.registration.scope') Reached unreachable code
    5 FAIL Verify registration attributes on ServiceWorkerGlobalScope of the newer worker assert_unreached: unregister and register should not fail: TypeError: null is not an object (evaluating 'self.registration.scope') Reached unreachable code
     3FAIL Verify registration attributes on ServiceWorkerGlobalScope assert_equals: Service Worker should respond to fetch expected "updatefound,install,statechange(installed),statechange(activating),activate,statechange(activated),fetch" but got "{\"error\": {\"message\": \"\", \"code\": 404}}"
     4FAIL Verify registration attributes on ServiceWorkerGlobalScope of the newer worker promise_test: Unhandled rejection with value: object "Error: wait_for_state must be passed a ServiceWorker"
    65
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/unregister.https-expected.txt

    r224724 r225296  
    22Harness Error (TIMEOUT), message = null
    33
    4 FAIL Unregister on script evaluation assert_unreached: unregister and register should not fail: TypeError: null is not an object (evaluating 'self.registration.unregister') Reached unreachable code
    5 TIMEOUT Unregister on installing event Test timed out
     4TIMEOUT Unregister on script evaluation Test timed out
     5NOTRUN Unregister on installing event
    66NOTRUN Unregister on activate event
    77NOTRUN Unregister controlling service worker
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/update.https-expected.txt

    r224724 r225296  
    11
    2 FAIL Update a registration on ServiceWorkerGlobalScope assert_unreached: unregister and register should not fail: TypeError: null is not an object (evaluating 'self.registration.addEventListener') Reached unreachable code
    32
     3Harness Error (TIMEOUT), message = null
     4
     5TIMEOUT Update a registration on ServiceWorkerGlobalScope Test timed out
     6
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/navigation-redirect.https-expected.txt

    r224923 r225296  
    1 CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: TypeError: null is not an object (evaluating 'self.registration.scope')
    2 CONSOLE MESSAGE: line 50: Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'registrations[0].unregister')
     1 
    32
     3Harness Error (TIMEOUT), message = null
    44
    5 FAIL Normal redirect to same-origin scope. assert_unreached: unregister and register should not fail: TypeError: null is not an object (evaluating 'self.registration.scope') Reached unreachable code
    6 FAIL Normal redirect to other-origin scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    7 FAIL SW-fallbacked redirect to same-origin out-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    8 FAIL SW-fallbacked redirect to same-origin same-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    9 FAIL SW-fallbacked redirect to same-origin other-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    10 FAIL SW-fallbacked redirect to other-origin out-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    11 FAIL SW-fallbacked redirect to other-origin in-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    12 FAIL SW-generated redirect to same-origin out-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    13 FAIL SW-generated redirect to same-origin same-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    14 FAIL SW-generated redirect to same-origin other-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    15 FAIL SW-generated redirect to other-origin out-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    16 FAIL SW-generated redirect to other-origin in-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    17 FAIL SW-fetched redirect to same-origin out-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    18 FAIL SW-fetched redirect to same-origin same-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    19 FAIL SW-fetched redirect to same-origin other-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    20 FAIL SW-fetched redirect to other-origin out-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    21 FAIL SW-fetched redirect to other-origin in-scope. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    22 FAIL Redirect to same-origin out-scope with opaque redirect response. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    23 FAIL Redirect to same-origin same-scope with opaque redirect response. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    24 FAIL Redirect to same-origin other-scope with opaque redirect response. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    25 FAIL Redirect to other-origin out-scope with opaque redirect response. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    26 FAIL Redirect to other-origin in-scope with opaque redirect response. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    27 FAIL No location redirect response. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    28 FAIL Redirect to same-origin out-scope with opaque redirect response which is passed through Cache. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    29 FAIL Redirect to same-origin same-scope with opaque redirect response which is passed through Cache. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    30 FAIL Redirect to same-origin other-scope with opaque redirect response which is passed through Cache. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    31 FAIL Redirect to other-origin out-scope with opaque redirect response which is passed through Cache. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    32 FAIL Redirect to other-origin in-scope with opaque redirect response which is passed through Cache. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
    33 FAIL No location redirect response via Cache. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.active')"
     5FAIL Normal redirect to same-origin scope. promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     6FAIL Normal redirect to other-origin scope. promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     7FAIL SW-fallbacked redirect to same-origin out-scope. promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     8FAIL SW-fallbacked redirect to same-origin same-scope. promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     9FAIL SW-fallbacked redirect to same-origin other-scope. promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     10FAIL SW-fallbacked redirect to other-origin out-scope. promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     11FAIL SW-fallbacked redirect to other-origin in-scope. promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     12TIMEOUT SW-generated redirect to same-origin out-scope. Test timed out
     13NOTRUN SW-generated redirect to same-origin same-scope.
     14NOTRUN SW-generated redirect to same-origin other-scope.
     15NOTRUN SW-generated redirect to other-origin out-scope.
     16NOTRUN SW-generated redirect to other-origin in-scope.
     17NOTRUN SW-fetched redirect to same-origin out-scope.
     18NOTRUN SW-fetched redirect to same-origin same-scope.
     19NOTRUN SW-fetched redirect to same-origin other-scope.
     20NOTRUN SW-fetched redirect to other-origin out-scope.
     21NOTRUN SW-fetched redirect to other-origin in-scope.
     22NOTRUN Redirect to same-origin out-scope with opaque redirect response.
     23NOTRUN Redirect to same-origin same-scope with opaque redirect response.
     24NOTRUN Redirect to same-origin other-scope with opaque redirect response.
     25NOTRUN Redirect to other-origin out-scope with opaque redirect response.
     26NOTRUN Redirect to other-origin in-scope with opaque redirect response.
     27NOTRUN No location redirect response.
     28NOTRUN Redirect to same-origin out-scope with opaque redirect response which is passed through Cache.
     29NOTRUN Redirect to same-origin same-scope with opaque redirect response which is passed through Cache.
     30NOTRUN Redirect to same-origin other-scope with opaque redirect response which is passed through Cache.
     31NOTRUN Redirect to other-origin out-scope with opaque redirect response which is passed through Cache.
     32NOTRUN Redirect to other-origin in-scope with opaque redirect response which is passed through Cache.
     33NOTRUN No location redirect response via Cache.
    3434
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/redirected-response.https-expected.txt

    r224723 r225296  
    11
    2 FAIL initialize global state (service worker registration and caches) assert_unreached: unregister and register should not fail: TypeError: null is not an object (evaluating 'self.registration.scope') Reached unreachable code
    3 FAIL mode: "follow", non-intercepted request, no server redirect promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    4 FAIL mode: "follow", non-intercepted request promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    5 FAIL mode: "manual", non-intercepted request promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    6 FAIL mode: "error", non-intercepted request promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    7 FAIL mode: "follow", no mode change, no server redirect promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    8 FAIL mode: "follow", no mode change promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    9 FAIL mode: "error", mode change: "follow" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    10 FAIL mode: "manual", mode change: "follow" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    11 FAIL mode: "follow", mode change: "manual" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    12 FAIL mode: "error", mode change: "manual" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    13 FAIL mode: "manual", no mode change promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    14 FAIL mode: "follow", generated redirect response promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    15 FAIL mode: "error", generated redirect response promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    16 FAIL mode: "manual", generated redirect response promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    17 FAIL Fetch should follow the redirect response 20 times promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    18 FAIL Fetch should not follow the redirect response 21 times. promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'registration.installing')"
    19 FAIL restore global state (service worker registration) undefined is not an object (evaluating 'registration.unregister')
     2FAIL initialize global state (service worker registration and caches) promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     3FAIL mode: "follow", non-intercepted request, no server redirect promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     4FAIL mode: "follow", non-intercepted request promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     5FAIL mode: "manual", non-intercepted request promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     6FAIL mode: "error", non-intercepted request promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     7FAIL mode: "follow", no mode change, no server redirect promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     8FAIL mode: "follow", no mode change promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     9FAIL mode: "error", mode change: "follow" promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     10FAIL mode: "manual", mode change: "follow" promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     11FAIL mode: "follow", mode change: "manual" promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     12FAIL mode: "error", mode change: "manual" promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     13FAIL mode: "manual", no mode change promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     14FAIL mode: "follow", generated redirect response promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     15FAIL mode: "error", generated redirect response promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     16FAIL mode: "manual", generated redirect response promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     17FAIL Fetch should follow the redirect response 20 times promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     18FAIL Fetch should not follow the redirect response 21 times. promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
     19PASS restore global state (service worker registration)
     20PASS restore global state (caches)
    2021
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/register-foreign-fetch-errors.https-expected.txt

    r224663 r225296  
    11
    22PASS foreign fetch registration
    3 FAIL Untitled TypeError: null is not an object (evaluating 'registration.scope')
     3PASS Invalid options
     4PASS Scopes not an array
     5PASS Scopes not a string in array
     6PASS Relative url not under scope
     7PASS Absolute url not under scope
     8PASS Empty scope array
     9FAIL Call after event returned assert_throws: function "function () {
     10                event.registerForeignFetch({scopes: [scope], origins: ['*']});
     11              }" threw object "TypeError: event.registerForeignFetch is not a function. (In 'event.registerForeignFetch({scopes: [scope], origins: ['*']})', 'event.registerForeignFetch' is undefined)" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
     12FAIL Valid scopes with wildcard origin string event.registerForeignFetch is not a function. (In 'event.registerForeignFetch({scopes: [scope], origins: ['*']})', 'event.registerForeignFetch' is undefined)
     13FAIL Absolute urls event.registerForeignFetch is not a function. (In 'event.registerForeignFetch({scopes: [scope, scope + '/foo'], origins: ['*']})', 'event.registerForeignFetch' is undefined)
     14FAIL Relative urls undefined is not a function (near '...event.registerForeignFetch...')
     15PASS No origins specified
     16PASS Origins not a string or array
     17PASS Origins contains something not a string
     18PASS Origin not an absolute URL
     19FAIL Wildcard origin string in array event.registerForeignFetch is not a function. (In 'event.registerForeignFetch({scopes: [scope], origins: ['*']})', 'event.registerForeignFetch' is undefined)
     20PASS Origin string
     21FAIL Origin string in array event.registerForeignFetch is not a function. (In 'event.registerForeignFetch({scopes: [scope], origins: ['https://example.com/']})', 'event.registerForeignFetch' is undefined)
     22FAIL Array with multiple origins event.registerForeignFetch is not a function. (In 'event.registerForeignFetch({
     23            scopes: [scope], origins: ['https://example.com/', 'https://chromium.org']})', 'event.registerForeignFetch' is undefined)
     24PASS Origins includes wildcard and other strings
     25PASS Origins includes other strings and wildcard
    426
  • trunk/Source/WebCore/ChangeLog

    r225294 r225296  
     12017-11-29  Chris Dumez  <cdumez@apple.com>
     2
     3        Start exposing self.registration inside service workers
     4        https://bugs.webkit.org/show_bug.cgi?id=180162
     5
     6        Reviewed by Brady Eidson.
     7
     8        Start exposing self.registration inside service workers as per:
     9        - https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope-interface
     10
     11        This is very initial support:
     12        - The operations on the registration (such as update) will reject the promise for now.
     13        - The registration's service workers are not yet populated.
     14
     15        This will be implemented in a follow-up.
     16
     17        Tests: http/tests/workers/service/ServiceWorkerGlobalScope_registration_SameObject.html
     18               http/tests/workers/service/self_registration.html
     19
     20        * bindings/js/JSServiceWorkerGlobalScopeCustom.cpp:
     21        (WebCore::JSServiceWorkerGlobalScope::visitAdditionalChildren):
     22        * workers/service/ServiceWorkerContainer.cpp:
     23        (WebCore::ServiceWorkerContainer::addRegistration):
     24        * workers/service/ServiceWorkerContextData.cpp:
     25        (WebCore::ServiceWorkerContextData::isolatedCopy const):
     26        * workers/service/ServiceWorkerContextData.h:
     27        (WebCore::ServiceWorkerContextData::encode const):
     28        (WebCore::ServiceWorkerContextData::decode):
     29        * workers/service/ServiceWorkerGlobalScope.cpp:
     30        (WebCore::ServiceWorkerGlobalScope::ServiceWorkerGlobalScope):
     31        * workers/service/ServiceWorkerGlobalScope.h:
     32        (WebCore::ServiceWorkerGlobalScope::registration):
     33        * workers/service/server/SWServer.cpp:
     34        (WebCore::SWServer::updateWorker):
     35        (WebCore::SWServer::installContextData):
     36        * workers/service/server/SWServer.h:
     37        * workers/service/server/SWServerJobQueue.cpp:
     38        (WebCore::SWServerJobQueue::scriptFetchFinished):
     39
    1402017-11-29  Youenn Fablet  <youenn@apple.com>
    241
  • trunk/Source/WebCore/bindings/js/JSServiceWorkerGlobalScopeCustom.cpp

    r225249 r225296  
    3838{
    3939    visitor.addOpaqueRoot(&wrapped().clients());
    40     visitor.addOpaqueRoot(wrapped().registration());
     40    visitor.addOpaqueRoot(&wrapped().registration());
    4141}
    4242
  • trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp

    r225283 r225296  
    423423void ServiceWorkerContainer::addRegistration(ServiceWorkerRegistration& registration)
    424424{
    425     m_swConnection->addServiceWorkerRegistrationInServer(registration.identifier());
     425    ensureSWClientConnection().addServiceWorkerRegistrationInServer(registration.identifier());
    426426    m_registrations.add(registration.identifier(), &registration);
    427427}
  • trunk/Source/WebCore/workers/service/ServiceWorkerContextData.cpp

    r225031 r225296  
    3333ServiceWorkerContextData ServiceWorkerContextData::isolatedCopy() const
    3434{
    35     return { jobDataIdentifier, registrationKey.isolatedCopy(), serviceWorkerIdentifier, script.isolatedCopy(), scriptURL.isolatedCopy(), workerType };
     35    return { jobDataIdentifier, registration.isolatedCopy(), serviceWorkerIdentifier, script.isolatedCopy(), scriptURL.isolatedCopy(), workerType };
    3636}
    3737
  • trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h

    r225031 r225296  
    2828#include "ServiceWorkerIdentifier.h"
    2929#include "ServiceWorkerJobDataIdentifier.h"
    30 #include "ServiceWorkerRegistrationKey.h"
     30#include "ServiceWorkerRegistrationData.h"
    3131#include "URL.h"
    3232#include "WorkerType.h"
     
    3838struct ServiceWorkerContextData {
    3939    ServiceWorkerJobDataIdentifier jobDataIdentifier;
    40     ServiceWorkerRegistrationKey registrationKey;
     40    ServiceWorkerRegistrationData registration;
    4141    ServiceWorkerIdentifier serviceWorkerIdentifier;
    4242    String script;
     
    5353void ServiceWorkerContextData::encode(Encoder& encoder) const
    5454{
    55     encoder << jobDataIdentifier << registrationKey << serviceWorkerIdentifier << script << scriptURL << workerType;
     55    encoder << jobDataIdentifier << registration << serviceWorkerIdentifier << script << scriptURL << workerType;
    5656}
    5757
     
    6464        return std::nullopt;
    6565
    66     auto registrationKey = ServiceWorkerRegistrationKey::decode(decoder);
    67     if (!registrationKey)
     66    std::optional<ServiceWorkerRegistrationData> registration;
     67    decoder >> registration;
     68    if (!registration)
    6869        return std::nullopt;
    6970
     
    8485        return std::nullopt;
    8586   
    86     return {{ WTFMove(*jobDataIdentifier), WTFMove(*registrationKey), WTFMove(*serviceWorkerIdentifier), WTFMove(script), WTFMove(scriptURL), workerType }};
     87    return {{ WTFMove(*jobDataIdentifier), WTFMove(*registration), WTFMove(*serviceWorkerIdentifier), WTFMove(script), WTFMove(scriptURL), workerType }};
    8788}
    8889
  • trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp

    r224801 r225296  
    3131#include "ServiceWorkerClients.h"
    3232#include "ServiceWorkerThread.h"
     33#include "WorkerNavigator.h"
    3334
    3435namespace WebCore {
     
    3738    : WorkerGlobalScope(url, identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID)
    3839    , m_contextData(crossThreadCopy(data))
     40    , m_registration(ServiceWorkerRegistration::getOrCreate(*this, navigator().serviceWorker(), WTFMove(m_contextData.registration)))
    3941    , m_clients(ServiceWorkerClients::create(*this))
    4042{
     
    4244
    4345ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope() = default;
    44 
    45 ServiceWorkerRegistration* ServiceWorkerGlobalScope::registration()
    46 {
    47     // FIXME: implement this.
    48     return nullptr;
    49 }
    5046
    5147void ServiceWorkerGlobalScope::skipWaiting(Ref<DeferredPromise>&&)
  • trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h

    r224801 r225296  
    5050
    5151    ServiceWorkerClients& clients() { return m_clients.get(); }
    52     ServiceWorkerRegistration* registration();
     52    ServiceWorkerRegistration& registration() { return m_registration.get(); }
    5353   
    5454    void skipWaiting(Ref<DeferredPromise>&&);
     
    6262
    6363    ServiceWorkerContextData m_contextData;
     64    Ref<ServiceWorkerRegistration> m_registration;
    6465    Ref<ServiceWorkerClients> m_clients;
    6566};
  • trunk/Source/WebCore/workers/service/server/SWServer.cpp

    r225251 r225296  
    345345}
    346346
    347 void SWServer::updateWorker(Connection&, const ServiceWorkerJobDataIdentifier& jobDataIdentifier, const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type)
     347void SWServer::updateWorker(Connection&, const ServiceWorkerJobDataIdentifier& jobDataIdentifier, SWServerRegistration& registration, const URL& url, const String& script, WorkerType type)
    348348{
    349349    auto serviceWorkerIdentifier = generateServiceWorkerIdentifier();
    350350
    351     ServiceWorkerContextData data = { jobDataIdentifier, registrationKey, serviceWorkerIdentifier, script, url, type };
     351    ServiceWorkerContextData data = { jobDataIdentifier, registration.data(), serviceWorkerIdentifier, script, url, type };
    352352
    353353    // Right now we only ever keep up to one connection to one SW context process.
     
    376376    ASSERT(connection);
    377377
    378     auto* registration = m_registrations.get(data.registrationKey);
     378    auto* registration = m_registrations.get(data.registration.key);
    379379    RELEASE_ASSERT(registration);
    380380
  • trunk/Source/WebCore/workers/service/server/SWServer.h

    r225251 r225296  
    122122    void postTaskReply(CrossThreadTask&&);
    123123
    124     void updateWorker(Connection&, const ServiceWorkerJobDataIdentifier&, const ServiceWorkerRegistrationKey&, const URL&, const String& script, WorkerType);
     124    void updateWorker(Connection&, const ServiceWorkerJobDataIdentifier&, SWServerRegistration&, const URL&, const String& script, WorkerType);
    125125    void terminateWorker(SWServerWorker&);
    126126    void fireInstallEvent(SWServerWorker&);
  • trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp

    r225031 r225296  
    8888
    8989    // FIXME: Support the proper worker type (classic vs module)
    90     m_server.updateWorker(connection, job.identifier(), m_registrationKey, job.scriptURL, result.script, WorkerType::Classic);
     90    m_server.updateWorker(connection, job.identifier(), *registration, job.scriptURL, result.script, WorkerType::Classic);
    9191}
    9292
Note: See TracChangeset for help on using the changeset viewer.