From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- testing/web-platform/tests/service-workers/OWNERS | 1 + .../tests/service-workers/cache-storage/OWNERS | 2 + .../cache-storage/common.https.html | 52 + .../cache-storage/resources/blank.html | 2 + .../cache-storage/resources/common-worker.js | 15 + .../resources/credentials-iframe.html | 38 + .../cache-storage/resources/credentials-worker.js | 59 ++ .../cache-storage/resources/fetch-status.py | 2 + .../cache-storage/resources/iframe.html | 18 + .../cache-storage/resources/simple.txt | 1 + .../cache-storage/resources/test-helpers.js | 237 +++++ .../cache-storage/resources/testharness-helpers.js | 33 + .../cache-storage/script-tests/cache-add.js | 238 +++++ .../cache-storage/script-tests/cache-delete.js | 96 ++ .../cache-storage/script-tests/cache-match.js | 193 ++++ .../cache-storage/script-tests/cache-matchAll.js | 154 +++ .../cache-storage/script-tests/cache-put.js | 305 ++++++ .../script-tests/cache-storage-keys.js | 36 + .../script-tests/cache-storage-match.js | 124 +++ .../cache-storage/script-tests/cache-storage.js | 197 ++++ .../serviceworker/cache-add.https.html | 10 + .../serviceworker/cache-delete.https.html | 10 + .../serviceworker/cache-match.https.html | 10 + .../serviceworker/cache-matchAll.https.html | 10 + .../serviceworker/cache-put.https.html | 10 + .../serviceworker/cache-storage-keys.https.html | 10 + .../serviceworker/cache-storage-match.https.html | 10 + .../serviceworker/cache-storage.https.html | 10 + .../cache-storage/serviceworker/credentials.html | 46 + .../cache-storage/window/cache-add.https.html | 9 + .../cache-storage/window/cache-delete.https.html | 9 + .../cache-storage/window/cache-match.https.html | 9 + .../cache-storage/window/cache-matchAll.https.html | 9 + .../cache-storage/window/cache-put.https.html | 9 + .../window/cache-storage-keys.https.html | 9 + .../window/cache-storage-match.https.html | 9 + .../cache-storage/window/cache-storage.https.html | 9 + .../window/sandboxed-iframes.https.html | 67 ++ .../cache-storage/worker/cache-add.https.html | 9 + .../cache-storage/worker/cache-delete.https.html | 9 + .../cache-storage/worker/cache-match.https.html | 9 + .../cache-storage/worker/cache-matchAll.https.html | 9 + .../cache-storage/worker/cache-put.https.html | 9 + .../worker/cache-storage-keys.https.html | 9 + .../worker/cache-storage-match.https.html | 9 + .../cache-storage/worker/cache-storage.https.html | 9 + .../registration-attribute.https.html | 37 + .../resources/registration-attribute-worker.js | 132 +++ .../resources/unregister-controlling-worker.html | 0 .../resources/unregister-worker.js | 23 + .../resources/update-worker.js | 25 + .../resources/update-worker.py | 14 + .../ServiceWorkerGlobalScope/unregister.https.html | 127 +++ .../ServiceWorkerGlobalScope/update.https.html | 45 + ...ate-event-after-install-state-change.https.html | 32 + .../activation-after-registration.https.html | 29 + .../service-worker/activation.https.html | 179 ++++ .../service-worker/active.https.html | 55 + .../appcache-ordering-main.https.html | 91 ++ .../claim-not-using-registration.https.html | 123 +++ .../claim-using-registration.https.html | 100 ++ .../service-worker/client-navigate.https.html | 117 +++ .../clients-get-cross-origin.https.html | 42 + .../service-worker/clients-get.https.html | 70 ++ .../clients-matchall-client-types.https.html | 78 ++ ...lients-matchall-include-uncontrolled.https.html | 93 ++ .../service-worker/clients-matchall.https.html | 45 + .../controller-on-disconnect.https.html | 40 + .../service-worker/controller-on-load.https.html | 45 + .../service-worker/controller-on-reload.https.html | 54 + .../extendable-event-async-waituntil.https.html | 30 + .../extendable-event-waituntil.https.html | 125 +++ .../fetch-canvas-tainting-cache.https.html | 38 + .../fetch-canvas-tainting.https.html | 38 + .../service-worker/fetch-cors-xhr.https.html | 38 + .../service-worker/fetch-csp.https.html | 32 + ...h-event-after-navigation-within-page.https.html | 65 ++ .../fetch-event-async-respond-with.https.html | 34 + .../fetch-event-network-error.https.html | 42 + .../service-worker/fetch-event-redirect.https.html | 1102 ++++++++++++++++++++ ...event-respond-with-stops-propagation.https.html | 35 + .../service-worker/fetch-event.https.html | 575 ++++++++++ .../service-worker/fetch-frame-resource.https.html | 221 ++++ .../fetch-header-visibility.https.html | 52 + .../fetch-mixed-content-to-inscope.https.html | 27 + .../fetch-mixed-content-to-outscope.https.html | 27 + .../fetch-request-css-base-url.https.html | 56 + .../fetch-request-css-images.https.html | 176 ++++ .../fetch-request-fallback.https.html | 113 ++ .../fetch-request-no-freshness-headers.https.html | 53 + .../fetch-request-redirect.https.html | 372 +++++++ .../fetch-request-resources.https.html | 189 ++++ .../service-worker/fetch-request-xhr.https.html | 33 + .../service-worker/fetch-response-xhr.https.html | 37 + .../fetch-waits-for-activate.https.html | 63 ++ .../service-worker/getregistration.https.html | 87 ++ .../service-worker/getregistrations.https.html | 191 ++++ .../service-worker/indexeddb.https.html | 35 + .../service-worker/install-event-type.https.html | 30 + .../service-worker/installing.https.html | 37 + .../service-worker/interfaces.https.html | 56 + .../service-worker/invalid-blobtype.https.html | 30 + .../service-worker/invalid-header.https.html | 30 + .../service-worker/multiple-register.https.html | 116 +++ .../service-worker/multiple-update.https.html | 92 ++ .../service-worker/navigate-window.https.html | 141 +++ .../service-worker/navigation-redirect.https.html | 449 ++++++++ .../onactivate-script-error.https.html | 75 ++ .../oninstall-script-error.https.html | 67 ++ .../service-worker/performance-timeline.https.html | 11 + .../postmessage-msgport-to-client.https.html | 51 + .../postmessage-to-client.https.html | 49 + .../service-worker/postmessage.https.html | 60 ++ .../service-worker/ready.https.html | 172 +++ .../service-worker/referer.https.html | 30 + .../register-closed-window.https.html | 35 + .../register-default-scope.https.html | 66 ++ ...ster-same-scope-different-script-url.https.html | 240 +++++ ...ister-wait-forever-in-install-worker.https.html | 56 + .../registration-end-to-end.https.html | 96 ++ .../service-worker/registration-events.https.html | 37 + .../service-worker/registration-iframe.https.html | 108 ++ ...gistration-service-worker-attributes.https.html | 70 ++ .../service-worker/registration.https.html | 368 +++++++ .../service-worker/rejections.https.html | 21 + .../service-worker/request-end-to-end.https.html | 61 ++ .../service-worker/resource-timing.https.html | 58 ++ .../service-worker/resources/404.py | 5 + .../resources/appcache-ordering.install.html | 26 + .../resources/appcache-ordering.is-appcached.html | 13 + .../resources/appcache-ordering.is-appcached.js | 1 + .../resources/appcache-ordering.manifest | 7 + .../service-worker/resources/blank.html | 2 + .../service-worker/resources/claim-worker.js | 14 + .../resources/client-navigate-frame.html | 12 + .../resources/client-navigate-worker.js | 71 ++ .../resources/client-navigated-frame.html | 3 + .../resources/clients-get-frame.html | 12 + .../resources/clients-get-other-origin.html | 64 ++ .../service-worker/resources/clients-get-worker.js | 53 + .../clients-matchall-client-types-iframe.html | 8 + .../clients-matchall-client-types-shared-worker.js | 4 + .../resources/clients-matchall-worker.js | 24 + .../resources/dummy-shared-worker-interceptor.js | 7 + .../resources/dummy-worker-interceptor.js | 21 + .../resources/dummy-worker-script.py | 9 + .../service-worker/resources/dummy.html | 2 + .../service-worker/resources/dummy.txt | 1 + .../service-worker/resources/empty-worker.js | 1 + .../service-worker/resources/empty.js | 0 .../service-worker/resources/end-to-end-worker.js | 7 + .../service-worker/resources/events-worker.js | 12 + .../resources/extendable-event-async-waituntil.js | 20 + .../resources/extendable-event-waituntil.js | 75 ++ .../resources/fail-on-fetch-worker.js | 5 + .../resources/fetch-access-control-login.html | 16 + .../resources/fetch-access-control.py | 69 ++ .../resources/fetch-canvas-tainting-iframe.html | 294 ++++++ .../resources/fetch-cors-xhr-iframe.html | 210 ++++ .../service-worker/resources/fetch-csp-iframe.html | 72 ++ .../resources/fetch-csp-iframe.html.sub.headers | 1 + ...-event-after-navigation-within-page-iframe.html | 22 + .../fetch-event-async-respond-with-worker.js | 19 + ...etch-event-network-error-controllee-iframe.html | 59 ++ .../resources/fetch-event-network-error-worker.js | 46 + .../resources/fetch-event-redirect-iframe.html | 25 + ...-event-respond-with-stops-propagation-worker.js | 15 + .../resources/fetch-event-test-worker.js | 151 +++ .../resources/fetch-header-visibility-iframe.html | 66 ++ ...ch-mixed-content-iframe-inscope-to-inscope.html | 71 ++ ...h-mixed-content-iframe-inscope-to-outscope.html | 80 ++ .../resources/fetch-mixed-content-iframe.html | 71 ++ .../fetch-request-css-base-url-iframe.html | 1 + .../resources/fetch-request-css-base-url-style.css | 1 + .../resources/fetch-request-css-base-url-worker.js | 27 + .../resources/fetch-request-fallback-iframe.html | 15 + .../resources/fetch-request-fallback-worker.js | 13 + .../fetch-request-no-freshness-headers-iframe.html | 1 + .../fetch-request-no-freshness-headers-worker.js | 18 + .../resources/fetch-request-redirect-iframe.html | 35 + .../fetch-request-resources-iframe.https.html | 67 ++ .../resources/fetch-request-resources-worker.js | 24 + .../resources/fetch-request-xhr-iframe.https.html | 179 ++++ .../resources/fetch-request-xhr-worker.js | 22 + .../resources/fetch-response-xhr-iframe.https.html | 35 + .../resources/fetch-response-xhr-worker.js | 12 + .../resources/fetch-rewrite-worker.js | 149 +++ .../resources/fetch-waits-for-activate-worker.js | 17 + .../resources/frame-for-getregistrations.html | 19 + .../service-worker/resources/get-host-info.sub.js | 26 + .../service-worker/resources/indexeddb-worker.js | 26 + .../resources/install-event-type-worker.js | 8 + .../resources/interfaces-worker.sub.js | 107 ++ .../service-worker/resources/interfaces.js | 15 + .../resources/invalid-blobtype-iframe.https.html | 29 + .../resources/invalid-blobtype-worker.js | 10 + .../invalid-chunked-encoding-with-flush.py | 11 + .../resources/invalid-chunked-encoding.py | 2 + .../resources/invalid-header-iframe.https.html | 26 + .../resources/invalid-header-worker.js | 12 + .../service-worker/resources/load_worker.js | 29 + .../service-worker/resources/loaded.html | 9 + .../service-worker/resources/malformed-worker.py | 10 + .../service-worker/resources/mime-type-worker.py | 4 + .../service-worker/resources/mint-new-worker.py | 25 + .../resources/navigate-window-worker.js | 21 + .../navigation-redirect-other-origin.html | 66 ++ .../resources/navigation-redirect-out-scope.py | 15 + .../resources/navigation-redirect-scope1.py | 15 + .../resources/navigation-redirect-scope2.py | 15 + .../resources/navigation-redirect-worker.js | 75 ++ ...ctivate-throw-error-from-nested-event-worker.js | 13 + .../onactivate-throw-error-then-cancel-worker.js | 3 + ...vate-throw-error-then-prevent-default-worker.js | 7 + ...tivate-throw-error-with-empty-onerror-worker.js | 2 + .../resources/onactivate-throw-error-worker.js | 7 + ...install-throw-error-from-nested-event-worker.js | 12 + .../oninstall-throw-error-then-cancel-worker.js | 3 + ...tall-throw-error-then-prevent-default-worker.js | 7 + ...nstall-throw-error-with-empty-onerror-worker.js | 2 + .../resources/oninstall-throw-error-worker.js | 7 + .../service-worker/resources/other.html | 3 + .../resources/override_assert_object_equals.js | 58 ++ .../resources/performance-timeline-worker.js | 58 ++ .../postmessage-msgport-to-client-worker.js | 20 + .../resources/postmessage-to-client-worker.js | 10 + .../service-worker/resources/postmessage-worker.js | 19 + .../service-worker/resources/redirect.py | 25 + .../service-worker/resources/referer-iframe.html | 39 + .../resources/register-closed-window-iframe.html | 16 + .../resources/registration-worker.js | 1 + .../resources/reject-install-worker.js | 3 + .../resources/request-end-to-end-worker.js | 32 + .../service-worker/resources/request-headers.py | 6 + .../resources/resource-timing-iframe.html | 4 + .../resources/resource-timing-worker.js | 5 + .../resources/service-worker-csp-worker.py | 153 +++ .../resources/shared-worker-controlled.js | 8 + .../resources/shared-worker-import.js | 1 + .../service-worker/resources/silence.oga | Bin 0 -> 12983 bytes .../resources/simple-intercept-worker.js | 5 + .../service-worker/resources/simple.html | 3 + .../service-worker/resources/simple.txt | 1 + .../resources/skip-waiting-installed-worker.js | 24 + .../resources/skip-waiting-worker.js | 21 + .../service-worker/resources/square.png | Bin 0 -> 18299 bytes .../service-worker/resources/success.py | 8 + .../service-worker/resources/test-helpers.sub.js | 227 ++++ .../resources/testharness-helpers.js | 163 +++ .../resources/unregister-controller-page.html | 16 + .../resources/update-nocookie-worker.py | 15 + .../resources/update-recovery-worker.py | 25 + .../service-worker/resources/update-worker.py | 46 + .../update/update-after-oneday.https.html | 8 + .../resources/wait-forever-in-install-worker.js | 12 + .../service-worker/resources/websocket.js | 7 + .../worker-interception-iframe.https.html | 39 + .../resources/worker-load-interceptor.js | 13 + .../service-worker/resources/worker-testharness.js | 49 + .../service-worker/resources/xhr.js | 6 + .../service-worker-csp-connect.https.html | 10 + .../service-worker-csp-default.https.html | 10 + .../service-worker-csp-script.https.html | 10 + .../serviceworkerobject-scripturl.https.html | 26 + .../shared-worker-controlled.https.html | 77 ++ .../skip-waiting-installed.https.html | 67 ++ .../skip-waiting-using-registration.https.html | 60 ++ .../skip-waiting-without-client.https.html | 13 + ...p-waiting-without-using-registration.https.html | 42 + .../service-worker/skip-waiting.https.html | 54 + .../service-worker/state.https.html | 69 ++ .../service-worker/synced-state.https.html | 64 ++ .../service-worker/uncontrolled-page.https.html | 39 + .../unregister-controller.https.html | 108 ++ .../unregister-then-register-new-script.https.html | 159 +++ .../unregister-then-register.https.html | 129 +++ .../service-worker/unregister.https.html | 40 + .../update-after-navigation-fetch-event.https.html | 34 + .../service-worker/update-after-oneday.https.html | 50 + .../service-worker/update-recovery.https.html | 71 ++ .../service-worker/update.https.html | 123 +++ .../service-worker/waiting.https.html | 44 + .../service-worker/websocket.https.html | 46 + .../service-worker/worker-interception.https.html | 155 +++ .../service-workers/service-worker/xhr.https.html | 35 + .../tests/service-workers/specgen.json | 658 ++++++++++++ .../stub-3.1-service-worker-obj.html | 63 ++ .../stub-3.1.1-service-worker-scope.html | 46 + .../stub-3.1.2-service-worker-url.html | 43 + .../stub-3.1.3-service-worker-state.html | 76 ++ .../stub-3.1.4-service-worker-on-state-change.html | 35 + .../stub-3.2-navigator-service-worker.html | 84 ++ ...-3.2.1-navigator-service-worker-installing.html | 43 + ...avigator-service-worker-oncontrollerchange.html | 45 + ...2.11-navigator-service-worker-onreloadpage.html | 41 + ...ub-3.2.12-navigator-service-worker-onerror.html | 37 + ...tub-3.2.2-navigator-service-worker-waiting.html | 34 + ...stub-3.2.3-navigator-service-worker-active.html | 40 + ...-3.2.4-navigator-service-worker-controller.html | 37 + .../stub-3.2.5-navigator-service-worker-ready.html | 67 ++ ...stub-3.2.6-navigator-service-worker-getAll.html | 30 + ...ub-3.2.7-navigator-service-worker-register.html | 32 + ...-3.2.8-navigator-service-worker-unregister.html | 31 + ...2.9-navigator-service-worker-onupdatefound.html | 42 + .../stub-4.1-service-worker-global-scope.html | 75 ++ ...b-4.1.1-service-worker-global-scope-caches.html | 36 + ...-4.1.2-service-worker-global-scope-clients.html | 33 + ...ub-4.1.3-service-worker-global-scope-scope.html | 36 + ...ub-4.1.4-service-worker-global-scope-fetch.html | 55 + ...b-4.1.5-service-worker-global-scope-update.html | 36 + ...1.6-service-worker-global-scope-unregister.html | 31 + ....1.7-service-worker-global-scope-onmessage.html | 45 + .../tests/service-workers/stub-4.2-client.html | 61 ++ .../stub-4.3-service-worker-clients.html | 48 + .../stub-4.3.1-get-serviced-method.html | 34 + .../stub-4.3.2-reloadall-method.html | 37 + .../service-workers/stub-4.4-request-objects.html | 72 ++ .../service-workers/stub-4.5-response-objects.html | 75 ++ .../tests/service-workers/stub-4.5.2-response.html | 36 + .../stub-4.5.4-opaque-response.html | 36 + .../service-workers/stub-4.6-cache-objects.html | 37 + .../stub-4.6.1-cache-lifetimes.html | 38 + .../tests/service-workers/stub-4.6.2-cache.html | 64 ++ .../service-workers/stub-4.6.3-cache-storage.html | 62 ++ .../stub-4.7.1-install-phase-event.html | 51 + .../stub-4.7.1.1-wait-until-method.html | 39 + .../service-workers/stub-4.7.2-install-event.html | 35 + .../stub-4.7.2.1-install-event-section.html | 47 + .../stub-4.7.2.2-replace-method.html | 38 + .../service-workers/stub-4.7.3-activate-event.html | 41 + .../stub-4.7.4.1-fetch-event-section.html | 71 ++ .../stub-4.7.4.2-respond-with-method.html | 46 + .../stub-4.7.4.3-default-method.html | 52 + .../stub-4.7.4.4-is-reload-attribute.html | 32 + .../stub-5.1-origin-relativity.html | 35 + .../stub-5.2-cross-origin-resources.html | 48 + .../tests/service-workers/tools/blink-import.py | 204 ++++ 337 files changed, 19208 insertions(+) create mode 100644 testing/web-platform/tests/service-workers/OWNERS create mode 100644 testing/web-platform/tests/service-workers/cache-storage/OWNERS create mode 100644 testing/web-platform/tests/service-workers/cache-storage/common.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/resources/blank.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/resources/common-worker.js create mode 100644 testing/web-platform/tests/service-workers/cache-storage/resources/credentials-iframe.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/resources/credentials-worker.js create mode 100644 testing/web-platform/tests/service-workers/cache-storage/resources/fetch-status.py create mode 100644 testing/web-platform/tests/service-workers/cache-storage/resources/iframe.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/resources/simple.txt create mode 100644 testing/web-platform/tests/service-workers/cache-storage/resources/test-helpers.js create mode 100644 testing/web-platform/tests/service-workers/cache-storage/resources/testharness-helpers.js create mode 100644 testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-add.js create mode 100644 testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-delete.js create mode 100644 testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-match.js create mode 100644 testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-matchAll.js create mode 100644 testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js create mode 100644 testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-keys.js create mode 100644 testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-match.js create mode 100644 testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage.js create mode 100644 testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-add.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-delete.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-match.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-matchAll.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-put.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-keys.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-match.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/serviceworker/credentials.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/window/cache-add.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/window/cache-delete.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/window/cache-match.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/window/cache-matchAll.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/window/cache-put.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-keys.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-match.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/window/cache-storage.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/window/sandboxed-iframes.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/worker/cache-add.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/worker/cache-delete.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/worker/cache-match.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/worker/cache-matchAll.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/worker/cache-put.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-keys.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-match.https.html create mode 100644 testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/registration-attribute.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/registration-attribute-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/unregister-controlling-worker.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/unregister-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/update-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/update-worker.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/unregister.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/update.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/activate-event-after-install-state-change.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/activation-after-registration.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/activation.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/active.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/appcache-ordering-main.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/claim-not-using-registration.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/claim-using-registration.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/client-navigate.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/clients-get-cross-origin.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/clients-get.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/clients-matchall-client-types.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/clients-matchall-include-uncontrolled.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/clients-matchall.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/controller-on-disconnect.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/controller-on-load.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/controller-on-reload.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/extendable-event-async-waituntil.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/extendable-event-waituntil.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-canvas-tainting.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-cors-xhr.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-csp.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-event-after-navigation-within-page.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-event-async-respond-with.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-event-network-error.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-event-redirect.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-event-respond-with-stops-propagation.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-event.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-frame-resource.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-header-visibility.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-mixed-content-to-inscope.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-mixed-content-to-outscope.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-request-css-base-url.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-request-css-images.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-request-fallback.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-request-no-freshness-headers.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-request-redirect.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-request-resources.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-request-xhr.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-response-xhr.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/fetch-waits-for-activate.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/getregistration.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/getregistrations.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/indexeddb.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/install-event-type.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/installing.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/interfaces.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/invalid-blobtype.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/invalid-header.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/multiple-register.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/multiple-update.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/navigate-window.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/navigation-redirect.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/onactivate-script-error.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/oninstall-script-error.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/performance-timeline.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/postmessage-msgport-to-client.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/postmessage-to-client.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/postmessage.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/ready.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/referer.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/register-closed-window.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/register-default-scope.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/register-same-scope-different-script-url.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/register-wait-forever-in-install-worker.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/registration-end-to-end.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/registration-events.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/registration-iframe.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/registration-service-worker-attributes.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/registration.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/rejections.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/request-end-to-end.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resource-timing.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/404.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.install.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.is-appcached.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.is-appcached.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.manifest create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/blank.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/claim-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/client-navigate-frame.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/client-navigate-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/client-navigated-frame.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/clients-get-frame.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/clients-get-other-origin.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/clients-get-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-client-types-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-client-types-shared-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/dummy-shared-worker-interceptor.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/dummy-worker-interceptor.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/dummy-worker-script.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/dummy.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/dummy.txt create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/empty-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/empty.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/end-to-end-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/events-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/extendable-event-async-waituntil.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/extendable-event-waituntil.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fail-on-fetch-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-access-control-login.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-access-control.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-cors-xhr-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-csp-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-csp-iframe.html.sub.headers create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-after-navigation-within-page-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-async-respond-with-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-network-error-controllee-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-network-error-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-redirect-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-respond-with-stops-propagation-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-test-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-header-visibility-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-mixed-content-iframe-inscope-to-inscope.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-mixed-content-iframe-inscope-to-outscope.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-mixed-content-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-css-base-url-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-css-base-url-style.css create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-css-base-url-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-fallback-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-fallback-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-no-freshness-headers-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-no-freshness-headers-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-redirect-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-resources-iframe.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-resources-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-xhr-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-response-xhr-iframe.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-response-xhr-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-rewrite-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/fetch-waits-for-activate-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/frame-for-getregistrations.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/get-host-info.sub.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/indexeddb-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/install-event-type-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/interfaces-worker.sub.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/interfaces.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/invalid-blobtype-iframe.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/invalid-blobtype-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/invalid-chunked-encoding-with-flush.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/invalid-chunked-encoding.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/invalid-header-iframe.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/invalid-header-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/load_worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/loaded.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/malformed-worker.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/mime-type-worker.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/mint-new-worker.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/navigate-window-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-other-origin.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-out-scope.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-scope1.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-scope2.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-from-nested-event-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-then-cancel-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-then-prevent-default-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-with-empty-onerror-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-from-nested-event-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-then-cancel-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-then-prevent-default-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-with-empty-onerror-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/other.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/override_assert_object_equals.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/performance-timeline-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/postmessage-msgport-to-client-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/postmessage-to-client-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/postmessage-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/redirect.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/referer-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/register-closed-window-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/registration-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/reject-install-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/request-end-to-end-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/request-headers.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-iframe.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/service-worker-csp-worker.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/shared-worker-controlled.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/shared-worker-import.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/silence.oga create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/simple-intercept-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/simple.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/simple.txt create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/skip-waiting-installed-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/skip-waiting-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/square.png create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/success.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/test-helpers.sub.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/testharness-helpers.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/unregister-controller-page.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/update-nocookie-worker.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/update-recovery-worker.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/update-worker.py create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/update/update-after-oneday.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/wait-forever-in-install-worker.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/websocket.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/worker-interception-iframe.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/worker-load-interceptor.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/worker-testharness.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/resources/xhr.js create mode 100644 testing/web-platform/tests/service-workers/service-worker/service-worker-csp-connect.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/service-worker-csp-default.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/service-worker-csp-script.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/serviceworkerobject-scripturl.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/shared-worker-controlled.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/skip-waiting-installed.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/skip-waiting-using-registration.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/skip-waiting-without-client.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/skip-waiting-without-using-registration.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/skip-waiting.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/state.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/synced-state.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/uncontrolled-page.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/unregister-controller.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/unregister-then-register-new-script.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/unregister-then-register.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/unregister.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/update-after-navigation-fetch-event.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/update-after-oneday.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/update-recovery.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/update.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/waiting.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/websocket.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/worker-interception.https.html create mode 100644 testing/web-platform/tests/service-workers/service-worker/xhr.https.html create mode 100644 testing/web-platform/tests/service-workers/specgen.json create mode 100644 testing/web-platform/tests/service-workers/stub-3.1-service-worker-obj.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.1.1-service-worker-scope.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.1.2-service-worker-url.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.1.3-service-worker-state.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.1.4-service-worker-on-state-change.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2-navigator-service-worker.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2.1-navigator-service-worker-installing.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2.10-navigator-service-worker-oncontrollerchange.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2.11-navigator-service-worker-onreloadpage.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2.12-navigator-service-worker-onerror.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2.2-navigator-service-worker-waiting.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2.3-navigator-service-worker-active.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2.4-navigator-service-worker-controller.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2.5-navigator-service-worker-ready.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2.6-navigator-service-worker-getAll.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2.7-navigator-service-worker-register.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2.8-navigator-service-worker-unregister.html create mode 100644 testing/web-platform/tests/service-workers/stub-3.2.9-navigator-service-worker-onupdatefound.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.1-service-worker-global-scope.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.1.1-service-worker-global-scope-caches.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.1.2-service-worker-global-scope-clients.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.1.3-service-worker-global-scope-scope.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.1.4-service-worker-global-scope-fetch.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.1.5-service-worker-global-scope-update.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.1.6-service-worker-global-scope-unregister.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.1.7-service-worker-global-scope-onmessage.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.2-client.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.3-service-worker-clients.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.3.1-get-serviced-method.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.3.2-reloadall-method.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.4-request-objects.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.5-response-objects.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.5.2-response.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.5.4-opaque-response.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.6-cache-objects.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.6.1-cache-lifetimes.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.6.2-cache.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.6.3-cache-storage.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.7.1-install-phase-event.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.7.1.1-wait-until-method.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.7.2-install-event.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.7.2.1-install-event-section.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.7.2.2-replace-method.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.7.3-activate-event.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.7.4.1-fetch-event-section.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.7.4.2-respond-with-method.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.7.4.3-default-method.html create mode 100644 testing/web-platform/tests/service-workers/stub-4.7.4.4-is-reload-attribute.html create mode 100644 testing/web-platform/tests/service-workers/stub-5.1-origin-relativity.html create mode 100644 testing/web-platform/tests/service-workers/stub-5.2-cross-origin-resources.html create mode 100644 testing/web-platform/tests/service-workers/tools/blink-import.py (limited to 'testing/web-platform/tests/service-workers') diff --git a/testing/web-platform/tests/service-workers/OWNERS b/testing/web-platform/tests/service-workers/OWNERS new file mode 100644 index 000000000..e210b8f2d --- /dev/null +++ b/testing/web-platform/tests/service-workers/OWNERS @@ -0,0 +1 @@ +@ehsan diff --git a/testing/web-platform/tests/service-workers/cache-storage/OWNERS b/testing/web-platform/tests/service-workers/cache-storage/OWNERS new file mode 100644 index 000000000..2e63dd220 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/OWNERS @@ -0,0 +1,2 @@ +@inexorabletash +@wanderview diff --git a/testing/web-platform/tests/service-workers/cache-storage/common.https.html b/testing/web-platform/tests/service-workers/cache-storage/common.https.html new file mode 100644 index 000000000..b00199844 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/common.https.html @@ -0,0 +1,52 @@ + +Cache Storage: Verify that Window and Workers see same storage + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/blank.html b/testing/web-platform/tests/service-workers/cache-storage/resources/blank.html new file mode 100644 index 000000000..a3c3a4689 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/resources/blank.html @@ -0,0 +1,2 @@ + +Empty doc diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/common-worker.js b/testing/web-platform/tests/service-workers/cache-storage/resources/common-worker.js new file mode 100644 index 000000000..d0e8544b5 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/resources/common-worker.js @@ -0,0 +1,15 @@ +self.onmessage = function(e) { + var cache_name = e.data.name; + + self.caches.open(cache_name) + .then(function(cache) { + return Promise.all([ + cache.put('https://example.com/a', new Response('a')), + cache.put('https://example.com/b', new Response('b')), + cache.put('https://example.com/c', new Response('c')) + ]); + }) + .then(function() { + self.postMessage('ok'); + }); +}; diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/credentials-iframe.html b/testing/web-platform/tests/service-workers/cache-storage/resources/credentials-iframe.html new file mode 100644 index 000000000..00702df9e --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/resources/credentials-iframe.html @@ -0,0 +1,38 @@ + + +Controlled frame for Cache API test with credentials + + +Hello? Yes, this is iframe. + diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/credentials-worker.js b/testing/web-platform/tests/service-workers/cache-storage/resources/credentials-worker.js new file mode 100644 index 000000000..43965b5fe --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/resources/credentials-worker.js @@ -0,0 +1,59 @@ +var cache_name = 'credentials'; + +function assert_equals(actual, expected, message) { + if (!Object.is(actual, expected)) + throw Error(message + ': expected: ' + expected + ', actual: ' + actual); +} + +self.onfetch = function(e) { + if (!/\.txt$/.test(e.request.url)) return; + var content = e.request.url; + var cache; + e.respondWith( + self.caches.open(cache_name) + .then(function(result) { + cache = result; + return cache.put(e.request, new Response(content)); + }) + + .then(function() { return cache.match(e.request); }) + .then(function(result) { return result.text(); }) + .then(function(text) { + assert_equals(text, content, 'Cache.match() body should match'); + }) + + .then(function() { return cache.matchAll(e.request); }) + .then(function(results) { + assert_equals(results.length, 1, 'Should have one response'); + return results[0].text(); + }) + .then(function(text) { + assert_equals(text, content, 'Cache.matchAll() body should match'); + }) + + .then(function() { return self.caches.match(e.request); }) + .then(function(result) { return result.text(); }) + .then(function(text) { + assert_equals(text, content, 'CacheStorage.match() body should match'); + }) + + .then(function() { + return new Response('dummy'); + }) + ); +}; + +self.onmessage = function(e) { + if (e.data === 'keys') { + self.caches.open(cache_name) + .then(function(cache) { return cache.keys(); }) + .then(function(requests) { + var urls = requests.map(function(request) { return request.url; }); + self.clients.matchAll().then(function(clients) { + clients.forEach(function(client) { + client.postMessage(urls); + }); + }); + }); + } +}; diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/fetch-status.py b/testing/web-platform/tests/service-workers/cache-storage/resources/fetch-status.py new file mode 100644 index 000000000..71f13ebc3 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/resources/fetch-status.py @@ -0,0 +1,2 @@ +def main(request, response): + return int(request.GET["status"]), [], "" diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/iframe.html b/testing/web-platform/tests/service-workers/cache-storage/resources/iframe.html new file mode 100644 index 000000000..a2f1e502b --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/resources/iframe.html @@ -0,0 +1,18 @@ + +ok + diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/simple.txt b/testing/web-platform/tests/service-workers/cache-storage/resources/simple.txt new file mode 100644 index 000000000..9e3cb91fb --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/resources/simple.txt @@ -0,0 +1 @@ +a simple text file diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/test-helpers.js b/testing/web-platform/tests/service-workers/cache-storage/resources/test-helpers.js new file mode 100644 index 000000000..f4145e621 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/resources/test-helpers.js @@ -0,0 +1,237 @@ +(function() { + var next_cache_index = 1; + + // Returns a promise that resolves to a newly created Cache object. The + // returned Cache will be destroyed when |test| completes. + function create_temporary_cache(test) { + var uniquifier = String(++next_cache_index); + var cache_name = self.location.pathname + '/' + uniquifier; + + test.add_cleanup(function() { + self.caches.delete(cache_name); + }); + + return self.caches.delete(cache_name) + .then(function() { + return self.caches.open(cache_name); + }); + } + + self.create_temporary_cache = create_temporary_cache; +})(); + +// Runs |test_function| with a temporary unique Cache passed in as the only +// argument. The function is run as a part of Promise chain owned by +// promise_test(). As such, it is expected to behave in a manner identical (with +// the exception of the argument) to a function passed into promise_test(). +// +// E.g.: +// cache_test(function(cache) { +// // Do something with |cache|, which is a Cache object. +// }, "Some Cache test"); +function cache_test(test_function, description) { + promise_test(function(test) { + return create_temporary_cache(test) + .then(test_function); + }, description); +} + +// A set of Request/Response pairs to be used with prepopulated_cache_test(). +var simple_entries = [ + { + name: 'a', + request: new Request('http://example.com/a'), + response: new Response('') + }, + + { + name: 'b', + request: new Request('http://example.com/b'), + response: new Response('') + }, + + { + name: 'a_with_query', + request: new Request('http://example.com/a?q=r'), + response: new Response('') + }, + + { + name: 'A', + request: new Request('http://example.com/A'), + response: new Response('') + }, + + { + name: 'a_https', + request: new Request('https://example.com/a'), + response: new Response('') + }, + + { + name: 'a_org', + request: new Request('http://example.org/a'), + response: new Response('') + }, + + { + name: 'cat', + request: new Request('http://example.com/cat'), + response: new Response('') + }, + + { + name: 'catmandu', + request: new Request('http://example.com/catmandu'), + response: new Response('') + }, + + { + name: 'cat_num_lives', + request: new Request('http://example.com/cat?lives=9'), + response: new Response('') + }, + + { + name: 'cat_in_the_hat', + request: new Request('http://example.com/cat/in/the/hat'), + response: new Response('') + }, + + { + name: 'non_2xx_response', + request: new Request('http://example.com/non2xx'), + response: new Response('', {status: 404, statusText: 'nope'}) + }, + + { + name: 'error_response', + request: new Request('http://example.com/error'), + response: Response.error() + }, +]; + +// A set of Request/Response pairs to be used with prepopulated_cache_test(). +// These contain a mix of test cases that use Vary headers. +var vary_entries = [ + { + name: 'vary_cookie_is_cookie', + request: new Request('http://example.com/c', + {headers: {'Cookies': 'is-for-cookie'}}), + response: new Response('', + {headers: {'Vary': 'Cookies'}}) + }, + + { + name: 'vary_cookie_is_good', + request: new Request('http://example.com/c', + {headers: {'Cookies': 'is-good-enough-for-me'}}), + response: new Response('', + {headers: {'Vary': 'Cookies'}}) + }, + + { + name: 'vary_cookie_absent', + request: new Request('http://example.com/c'), + response: new Response('', + {headers: {'Vary': 'Cookies'}}) + } +]; + +// Run |test_function| with a Cache object and a map of entries. Prior to the +// call, the Cache is populated by cache entries from |entries|. The latter is +// expected to be an Object mapping arbitrary keys to objects of the form +// {request: , response: }. There's no +// guarantee on the order in which entries will be added to the cache. +// +// |test_function| should return a Promise that can be used with promise_test. +function prepopulated_cache_test(entries, test_function, description) { + cache_test(function(cache) { + var p = Promise.resolve(); + var hash = {}; + return Promise.all(entries.map(function(entry) { + hash[entry.name] = entry; + return cache.put(entry.request.clone(), + entry.response.clone()) + .catch(function(e) { + assert_unreached( + 'Test setup failed for entry ' + entry.name + ': ' + e); + }); + })) + .then(function() { + assert_equals(Object.keys(hash).length, entries.length); + }) + .then(function() { + return test_function(cache, hash); + }); + }, description); +} + +// Helper for testing with Headers objects. Compares Headers instances +// by serializing |expected| and |actual| to arrays and comparing. +function assert_header_equals(actual, expected, description) { + assert_class_string(actual, "Headers", description); + var header; + var actual_headers = []; + var expected_headers = []; + for (header of actual) + actual_headers.push(header[0] + ": " + header[1]); + for (header of expected) + expected_headers.push(header[0] + ": " + header[1]); + assert_array_equals(actual_headers, expected_headers, + description + " Headers differ."); +} + +// Helper for testing with Response objects. Compares simple +// attributes defined on the interfaces, as well as the headers. It +// does not compare the response bodies. +function assert_response_equals(actual, expected, description) { + assert_class_string(actual, "Response", description); + ["type", "url", "status", "ok", "statusText"].forEach(function(attribute) { + assert_equals(actual[attribute], expected[attribute], + description + " Attributes differ: " + attribute + "."); + }); + assert_header_equals(actual.headers, expected.headers, description); +} + +// Assert that the two arrays |actual| and |expected| contain the same +// set of Responses as determined by assert_response_equals. The order +// is not significant. +// +// |expected| is assumed to not contain any duplicates. +function assert_response_array_equivalent(actual, expected, description) { + assert_true(Array.isArray(actual), description); + assert_equals(actual.length, expected.length, description); + expected.forEach(function(expected_element) { + // assert_response_in_array treats the first argument as being + // 'actual', and the second as being 'expected array'. We are + // switching them around because we want to be resilient + // against the |actual| array containing duplicates. + assert_response_in_array(expected_element, actual, description); + }); +} + +// Asserts that two arrays |actual| and |expected| contain the same +// set of Responses as determined by assert_response_equals(). The +// corresponding elements must occupy corresponding indices in their +// respective arrays. +function assert_response_array_equals(actual, expected, description) { + assert_true(Array.isArray(actual), description); + assert_equals(actual.length, expected.length, description); + actual.forEach(function(value, index) { + assert_response_equals(value, expected[index], + description + " : object[" + index + "]"); + }); +} + +// Equivalent to assert_in_array, but uses assert_response_equals. +function assert_response_in_array(actual, expected_array, description) { + assert_true(expected_array.some(function(element) { + try { + assert_response_equals(actual, element); + return true; + } catch (e) { + return false; + } + }), description); +} diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/testharness-helpers.js b/testing/web-platform/tests/service-workers/cache-storage/resources/testharness-helpers.js new file mode 100644 index 000000000..e4885727b --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/resources/testharness-helpers.js @@ -0,0 +1,33 @@ +/* + * testharness-helpers contains various useful extensions to testharness.js to + * allow them to be used across multiple tests before they have been + * upstreamed. This file is intended to be usable from both document and worker + * environments, so code should for example not rely on the DOM. + */ + +// Returns a promise that fulfills after the provided |promise| is fulfilled. +// The |test| succeeds only if |promise| rejects with an exception matching +// |code|. Accepted values for |code| follow those accepted for assert_throws(). +// The optional |description| describes the test being performed. +// +// E.g.: +// assert_promise_rejects( +// new Promise(...), // something that should throw an exception. +// 'NotFoundError', +// 'Should throw NotFoundError.'); +// +// assert_promise_rejects( +// new Promise(...), +// new TypeError(), +// 'Should throw TypeError'); +function assert_promise_rejects(promise, code, description) { + return promise.then( + function() { + throw 'assert_promise_rejects: ' + description + ' Promise did not reject.'; + }, + function(e) { + if (code !== undefined) { + assert_throws(code, function() { throw e; }, description); + } + }); +} diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-add.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-add.js new file mode 100644 index 000000000..01fd605ad --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-add.js @@ -0,0 +1,238 @@ +if (self.importScripts) { + importScripts('/resources/testharness.js'); + importScripts('../resources/testharness-helpers.js'); + importScripts('../resources/test-helpers.js'); +} + +cache_test(function(cache) { + return assert_promise_rejects( + cache.add(), + new TypeError(), + 'Cache.add should throw a TypeError when no arguments are given.'); + }, 'Cache.add called with no arguments'); + +cache_test(function(cache) { + return cache.add('../resources/simple.txt') + .then(function(result) { + assert_equals(result, undefined, + 'Cache.add should resolve with undefined on success.'); + return cache.match('../resources/simple.txt'); + }) + .then(function(response) { + assert_class_string(response, 'Response', + 'Cache.add should put a resource in the cache.'); + return response.text(); + }) + .then(function(body) { + assert_equals(body, 'a simple text file\n', + 'Cache.add should retrieve the correct body.'); + }); + }, 'Cache.add called with relative URL specified as a string'); + +cache_test(function(cache) { + return assert_promise_rejects( + cache.add('javascript://this-is-not-http-mmkay'), + new TypeError(), + 'Cache.add should throw a TypeError for non-HTTP/HTTPS URLs.'); + }, 'Cache.add called with non-HTTP/HTTPS URL'); + +cache_test(function(cache) { + var request = new Request('../resources/simple.txt'); + return cache.add(request) + .then(function(result) { + assert_equals(result, undefined, + 'Cache.add should resolve with undefined on success.'); + }); + }, 'Cache.add called with Request object'); + +cache_test(function(cache) { + var request = new Request('../resources/simple.txt', + {method: 'POST', body: 'This is a body.'}); + return assert_promise_rejects( + cache.add(request), + new TypeError(), + 'Cache.add should throw a TypeError for non-GET requests.'); + }, 'Cache.add called with POST request'); + +cache_test(function(cache) { + var request = new Request('../resources/simple.txt'); + return cache.add(request) + .then(function(result) { + assert_equals(result, undefined, + 'Cache.add should resolve with undefined on success.'); + }) + .then(function() { + return cache.add(request); + }) + .then(function(result) { + assert_equals(result, undefined, + 'Cache.add should resolve with undefined on success.'); + }); + }, 'Cache.add called twice with the same Request object'); + +cache_test(function(cache) { + var request = new Request('../resources/simple.txt'); + return request.text() + .then(function() { + assert_false(request.bodyUsed); + }) + .then(function() { + return cache.add(request); + }); + }, 'Cache.add with request with null body (not consumed)'); + +cache_test(function(cache) { + return assert_promise_rejects( + cache.add('this-does-not-exist-please-dont-create-it'), + new TypeError(), + 'Cache.add should reject if response is !ok'); + }, 'Cache.add with request that results in a status of 404'); + +cache_test(function(cache) { + return assert_promise_rejects( + cache.add('../resources/fetch-status.php?status=500'), + new TypeError(), + 'Cache.add should reject if response is !ok'); + }, 'Cache.add with request that results in a status of 500'); + +cache_test(function(cache) { + return assert_promise_rejects( + cache.addAll(), + new TypeError(), + 'Cache.addAll with no arguments should throw TypeError.'); + }, 'Cache.addAll with no arguments'); + +cache_test(function(cache) { + // Assumes the existence of ../resources/simple.txt and ../resources/blank.html + var urls = ['../resources/simple.txt', undefined, '../resources/blank.html']; + return assert_promise_rejects( + cache.addAll(), + new TypeError(), + 'Cache.addAll should throw TypeError for an undefined argument.'); + }, 'Cache.addAll with a mix of valid and undefined arguments'); + +cache_test(function(cache) { + return cache.addAll([]) + .then(function(result) { + assert_equals(result, undefined, + 'Cache.addAll should resolve with undefined on ' + + 'success.'); + return cache.keys(); + }) + .then(function(result) { + assert_equals(result.length, 0, + 'There should be no entry in the cache.'); + }); + }, 'Cache.addAll with an empty array'); + +cache_test(function(cache) { + // Assumes the existence of ../resources/simple.txt and + // ../resources/blank.html + var urls = ['../resources/simple.txt', + self.location.href, + '../resources/blank.html']; + return cache.addAll(urls) + .then(function(result) { + assert_equals(result, undefined, + 'Cache.addAll should resolve with undefined on ' + + 'success.'); + return Promise.all( + urls.map(function(url) { return cache.match(url); })); + }) + .then(function(responses) { + assert_class_string( + responses[0], 'Response', + 'Cache.addAll should put a resource in the cache.'); + assert_class_string( + responses[1], 'Response', + 'Cache.addAll should put a resource in the cache.'); + assert_class_string( + responses[2], 'Response', + 'Cache.addAll should put a resource in the cache.'); + return Promise.all( + responses.map(function(response) { return response.text(); })); + }) + .then(function(bodies) { + assert_equals( + bodies[0], 'a simple text file\n', + 'Cache.add should retrieve the correct body.'); + assert_equals( + bodies[2], '\nEmpty doc\n', + 'Cache.add should retrieve the correct body.'); + }); + }, 'Cache.addAll with string URL arguments'); + +cache_test(function(cache) { + // Assumes the existence of ../resources/simple.txt and + // ../resources/blank.html + var urls = ['../resources/simple.txt', + self.location.href, + '../resources/blank.html']; + var requests = urls.map(function(url) { + return new Request(url); + }); + return cache.addAll(requests) + .then(function(result) { + assert_equals(result, undefined, + 'Cache.addAll should resolve with undefined on ' + + 'success.'); + return Promise.all( + urls.map(function(url) { return cache.match(url); })); + }) + .then(function(responses) { + assert_class_string( + responses[0], 'Response', + 'Cache.addAll should put a resource in the cache.'); + assert_class_string( + responses[1], 'Response', + 'Cache.addAll should put a resource in the cache.'); + assert_class_string( + responses[2], 'Response', + 'Cache.addAll should put a resource in the cache.'); + return Promise.all( + responses.map(function(response) { return response.text(); })); + }) + .then(function(bodies) { + assert_equals( + bodies[0], 'a simple text file\n', + 'Cache.add should retrieve the correct body.'); + assert_equals( + bodies[2], '\nEmpty doc\n', + 'Cache.add should retrieve the correct body.'); + }); + }, 'Cache.addAll with Request arguments'); + +cache_test(function(cache) { + // Assumes that ../resources/simple.txt and ../resources/blank.html exist. + // The second resource does not. + var urls = ['../resources/simple.txt', + 'this-resource-should-not-exist', + '../resources/blank.html']; + var requests = urls.map(function(url) { + return new Request(url); + }); + return assert_promise_rejects( + cache.addAll(requests), + new TypeError(), + 'Cache.addAll should reject with TypeError if any request fails') + .then(function() { + return Promise.all(urls.map(function(url) { return cache.match(url); })); + }) + .then(function(matches) { + assert_array_equals( + matches, + [undefined, undefined, undefined], + 'If any response fails, no response should be added to cache'); + }); + }, 'Cache.addAll with a mix of succeeding and failing requests'); + +cache_test(function(cache) { + var request = new Request('../resources/simple.txt'); + return assert_promise_rejects( + cache.addAll([request, request]), + 'InvalidStateError', + 'Cache.addAll should throw InvalidStateError if the same request is added ' + + 'twice.'); + }, 'Cache.addAll called with the same Request object specified twice'); + +done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-delete.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-delete.js new file mode 100644 index 000000000..75a474c2b --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-delete.js @@ -0,0 +1,96 @@ +if (self.importScripts) { + importScripts('/resources/testharness.js'); + importScripts('../resources/testharness-helpers.js'); + importScripts('../resources/test-helpers.js'); +} + +var test_url = 'https://example.com/foo'; + +// Construct a generic Request object. The URL is |test_url|. All other fields +// are defaults. +function new_test_request() { + return new Request(test_url); +} + +// Construct a generic Response object. +function new_test_response() { + return new Response('Hello world!', { status: 200 }); +} + +cache_test(function(cache) { + return assert_promise_rejects( + cache.delete(), + new TypeError(), + 'Cache.delete should reject with a TypeError when called with no ' + + 'arguments.'); + }, 'Cache.delete with no arguments'); + +cache_test(function(cache) { + return cache.put(new_test_request(), new_test_response()) + .then(function() { + return cache.delete(test_url); + }) + .then(function(result) { + assert_true(result, + 'Cache.delete should resolve with "true" if an entry ' + + 'was successfully deleted.'); + return cache.match(test_url); + }) + .then(function(result) { + assert_equals(result, undefined, + 'Cache.delete should remove matching entries from cache.'); + }); + }, 'Cache.delete called with a string URL'); + +cache_test(function(cache) { + var request = new Request(test_url); + return cache.put(request, new_test_response()) + .then(function() { + return cache.delete(request); + }) + .then(function(result) { + assert_true(result, + 'Cache.delete should resolve with "true" if an entry ' + + 'was successfully deleted.'); + }); + }, 'Cache.delete called with a Request object'); + +cache_test(function(cache) { + return cache.delete(test_url) + .then(function(result) { + assert_false(result, + 'Cache.delete should resolve with "false" if there ' + + 'are no matching entries.'); + }); + }, 'Cache.delete with a non-existent entry'); + +var cache_entries = { + a: { + request: new Request('http://example.com/abc'), + response: new Response('') + }, + + b: { + request: new Request('http://example.com/b'), + response: new Response('') + }, + + a_with_query: { + request: new Request('http://example.com/abc?q=r'), + response: new Response('') + } +}; + +function prepopulated_cache_test(test_function, description) { + cache_test(function(cache) { + return Promise.all(Object.keys(cache_entries).map(function(k) { + return cache.put(cache_entries[k].request.clone(), + cache_entries[k].response.clone()); + })) + .then(function() { + return test_function(cache); + }); + }, description); +} + +done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-match.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-match.js new file mode 100644 index 000000000..716bfe5a6 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-match.js @@ -0,0 +1,193 @@ +if (self.importScripts) { + importScripts('/resources/testharness.js'); + importScripts('../resources/testharness-helpers.js'); + importScripts('../resources/test-helpers.js'); +} + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.match('not-present-in-the-cache') + .then(function(result) { + assert_equals(result, undefined, + 'Cache.match failures should resolve with undefined.'); + }); + }, 'Cache.match with no matching entries'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.match(entries.a.request.url) + .then(function(result) { + assert_response_equals(result, entries.a.response, + 'Cache.match should match by URL.'); + }); + }, 'Cache.match with URL'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.match(entries.a.request) + .then(function(result) { + assert_response_equals(result, entries.a.response, + 'Cache.match should match by Request.'); + }); + }, 'Cache.match with Request'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.match(new Request(entries.a.request.url)) + .then(function(result) { + assert_response_equals(result, entries.a.response, + 'Cache.match should match by Request.'); + }); + }, 'Cache.match with new Request'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.match(entries.a.request, + {ignoreSearch: true}) + .then(function(result) { + assert_response_in_array( + result, + [ + entries.a.response, + entries.a_with_query.response + ], + 'Cache.match with ignoreSearch should ignore the ' + + 'search parameters of cached request.'); + }); + }, + 'Cache.match with ignoreSearch option (request with no search ' + + 'parameters)'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.match(entries.a_with_query.request, + {ignoreSearch: true}) + .then(function(result) { + assert_response_in_array( + result, + [ + entries.a.response, + entries.a_with_query.response + ], + 'Cache.match with ignoreSearch should ignore the ' + + 'search parameters of request.'); + }); + }, + 'Cache.match with ignoreSearch option (request with search parameter)'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.match(entries.cat.request.url + '#mouse') + .then(function(result) { + assert_response_equals(result, entries.cat.response, + 'Cache.match should ignore URL fragment.'); + }); + }, 'Cache.match with URL containing fragment'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.match('http') + .then(function(result) { + assert_equals( + result, undefined, + 'Cache.match should treat query as a URL and not ' + + 'just a string fragment.'); + }); + }, 'Cache.match with string fragment "http" as query'); + +prepopulated_cache_test(vary_entries, function(cache, entries) { + return cache.match('http://example.com/c') + .then(function(result) { + assert_response_in_array( + result, + [ + entries.vary_cookie_absent.response + ], + 'Cache.match should honor "Vary" header.'); + }); + }, 'Cache.match with responses containing "Vary" header'); + +cache_test(function(cache) { + var request = new Request('http://example.com'); + var response; + var request_url = new URL('../resources/simple.txt', location.href).href; + return fetch(request_url) + .then(function(fetch_result) { + response = fetch_result; + assert_equals( + response.url, request_url, + '[https://fetch.spec.whatwg.org/#dom-response-url] ' + + 'Reponse.url should return the URL of the response.'); + return cache.put(request, response.clone()); + }) + .then(function() { + return cache.match(request.url); + }) + .then(function(result) { + assert_response_equals( + result, response, + 'Cache.match should return a Response object that has the same ' + + 'properties as the stored response.'); + return cache.match(response.url); + }) + .then(function(result) { + assert_equals( + result, undefined, + 'Cache.match should not match cache entry based on response URL.'); + }); + }, 'Cache.match with Request and Response objects with different URLs'); + +cache_test(function(cache) { + var request_url = new URL('../resources/simple.txt', location.href).href; + return fetch(request_url) + .then(function(fetch_result) { + return cache.put(new Request(request_url), fetch_result); + }) + .then(function() { + return cache.match(request_url); + }) + .then(function(result) { + return result.text(); + }) + .then(function(body_text) { + assert_equals(body_text, 'a simple text file\n', + 'Cache.match should return a Response object with a ' + + 'valid body.'); + }) + .then(function() { + return cache.match(request_url); + }) + .then(function(result) { + return result.text(); + }) + .then(function(body_text) { + assert_equals(body_text, 'a simple text file\n', + 'Cache.match should return a Response object with a ' + + 'valid body each time it is called.'); + }); + }, 'Cache.match invoked multiple times for the same Request/Response'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + var request = new Request(entries.a.request.clone(), {method: 'POST'}); + return cache.match(request) + .then(function(result) { + assert_equals(result, undefined, + 'Cache.match should not find a match'); + }); + }, 'Cache.match with POST Request'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + var response = entries.non_2xx_response.response; + return cache.match(entries.non_2xx_response.request.url) + .then(function(result) { + assert_response_equals( + result, entries.non_2xx_response.response, + 'Cache.match should return a Response object that has the ' + + 'same properties as a stored non-2xx response.'); + }); + }, 'Cache.match with a non-2xx Response'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + var response = entries.error_response.response; + return cache.match(entries.error_response.request.url) + .then(function(result) { + assert_response_equals( + result, entries.error_response.response, + 'Cache.match should return a Response object that has the ' + + 'same properties as a stored network error response.'); + }); + }, 'Cache.match with a network error Response'); + +done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-matchAll.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-matchAll.js new file mode 100644 index 000000000..2bc661a5c --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-matchAll.js @@ -0,0 +1,154 @@ +if (self.importScripts) { + importScripts('/resources/testharness.js'); + importScripts('../resources/testharness-helpers.js'); + importScripts('../resources/test-helpers.js'); +} + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.matchAll('not-present-in-the-cache') + .then(function(result) { + assert_response_array_equivalent( + result, [], + 'Cache.matchAll should resolve with an empty array on failure.'); + }); + }, 'Cache.matchAll with no matching entries'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.matchAll(entries.a.request.url) + .then(function(result) { + assert_response_array_equals(result, [entries.a.response], + 'Cache.matchAll should match by URL.'); + }); + }, 'Cache.matchAll with URL'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.matchAll(entries.a.request) + .then(function(result) { + assert_response_array_equals( + result, [entries.a.response], + 'Cache.matchAll should match by Request.'); + }); + }, 'Cache.matchAll with Request'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.matchAll(new Request(entries.a.request.url)) + .then(function(result) { + assert_response_array_equals( + result, [entries.a.response], + 'Cache.matchAll should match by Request.'); + }); + }, 'Cache.matchAll with new Request'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.matchAll(entries.a.request, + {ignoreSearch: true}) + .then(function(result) { + assert_response_array_equivalent( + result, + [ + entries.a.response, + entries.a_with_query.response + ], + 'Cache.matchAll with ignoreSearch should ignore the ' + + 'search parameters of cached request.'); + }); + }, + 'Cache.matchAll with ignoreSearch option (request with no search ' + + 'parameters)'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.matchAll(entries.a_with_query.request, + {ignoreSearch: true}) + .then(function(result) { + assert_response_array_equivalent( + result, + [ + entries.a.response, + entries.a_with_query.response + ], + 'Cache.matchAll with ignoreSearch should ignore the ' + + 'search parameters of request.'); + }); + }, + 'Cache.matchAll with ignoreSearch option (request with search parameter)'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.matchAll(entries.cat.request.url + '#mouse') + .then(function(result) { + assert_response_array_equivalent( + result, + [ + entries.cat.response, + ], + 'Cache.matchAll should ignore URL fragment.'); + }); + }, 'Cache.matchAll with URL containing fragment'); + +prepopulated_cache_test(simple_entries, function(cache, entries) { + return cache.matchAll('http') + .then(function(result) { + assert_response_array_equivalent( + result, [], + 'Cache.matchAll should treat query as a URL and not ' + + 'just a string fragment.'); + }); + }, 'Cache.matchAll with string fragment "http" as query'); + +prepopulated_cache_test(vary_entries, function(cache, entries) { + return cache.matchAll('http://example.com/c') + .then(function(result) { + assert_response_array_equivalent( + result, + [ + entries.vary_cookie_absent.response + ], + 'Cache.matchAll should exclude matches if a vary header is ' + + 'missing in the query request, but is present in the cached ' + + 'request.'); + }) + + .then(function() { + return cache.matchAll( + new Request('http://example.com/c', + {headers: {'Cookies': 'none-of-the-above'}})); + }) + .then(function(result) { + assert_response_array_equivalent( + result, + [ + ], + 'Cache.matchAll should exclude matches if a vary header is ' + + 'missing in the cached request, but is present in the query ' + + 'request.'); + }) + + .then(function() { + return cache.matchAll( + new Request('http://example.com/c', + {headers: {'Cookies': 'is-for-cookie'}})); + }) + .then(function(result) { + assert_response_array_equivalent( + result, + [entries.vary_cookie_is_cookie.response], + 'Cache.matchAll should match the entire header if a vary header ' + + 'is present in both the query and cached requests.'); + }); + }, 'Cache.matchAll with responses containing "Vary" header'); + +prepopulated_cache_test(vary_entries, function(cache, entries) { + return cache.matchAll('http://example.com/c', + {ignoreVary: true}) + .then(function(result) { + assert_response_array_equivalent( + result, + [ + entries.vary_cookie_is_cookie.response, + entries.vary_cookie_is_good.response, + entries.vary_cookie_absent.response + ], + 'Cache.matchAll should honor "ignoreVary" parameter.'); + }); + }, 'Cache.matchAll with "ignoreVary" parameter'); + +done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js new file mode 100644 index 000000000..bcc8541ad --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js @@ -0,0 +1,305 @@ +if (self.importScripts) { + importScripts('/resources/testharness.js'); + importScripts('../resources/testharness-helpers.js'); + importScripts('../resources/test-helpers.js'); +} + +var test_url = 'https://example.com/foo'; +var test_body = 'Hello world!'; + +cache_test(function(cache) { + var request = new Request(test_url); + var response = new Response(test_body); + return cache.put(request, response) + .then(function(result) { + assert_equals(result, undefined, + 'Cache.put should resolve with undefined on success.'); + }); + }, 'Cache.put called with simple Request and Response'); + +cache_test(function(cache) { + var test_url = new URL('../resources/simple.txt', location.href).href; + var request = new Request(test_url); + var response; + return fetch(test_url) + .then(function(fetch_result) { + response = fetch_result.clone(); + return cache.put(request, fetch_result); + }) + .then(function() { + return cache.match(test_url); + }) + .then(function(result) { + assert_response_equals(result, response, + 'Cache.put should update the cache with ' + + 'new request and response.'); + return result.text(); + }) + .then(function(body) { + assert_equals(body, 'a simple text file\n', + 'Cache.put should store response body.'); + }); + }, 'Cache.put called with Request and Response from fetch()'); + +cache_test(function(cache) { + var request = new Request(test_url); + var response = new Response(test_body); + assert_false(request.bodyUsed, + '[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' + + 'Request.bodyUsed should be initially false.'); + return cache.put(request, response) + .then(function() { + assert_false(request.bodyUsed, + 'Cache.put should not mark empty request\'s body used'); + }); + }, 'Cache.put with Request without a body'); + +cache_test(function(cache) { + var request = new Request(test_url); + var response = new Response(); + assert_false(response.bodyUsed, + '[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' + + 'Response.bodyUsed should be initially false.'); + return cache.put(request, response) + .then(function() { + assert_false(response.bodyUsed, + 'Cache.put should not mark empty response\'s body used'); + }); + }, 'Cache.put with Response without a body'); + +cache_test(function(cache) { + var request = new Request(test_url); + var response = new Response(test_body); + return cache.put(request, response.clone()) + .then(function() { + return cache.match(test_url); + }) + .then(function(result) { + assert_response_equals(result, response, + 'Cache.put should update the cache with ' + + 'new Request and Response.'); + }); + }, 'Cache.put with a Response containing an empty URL'); + +cache_test(function(cache) { + var request = new Request(test_url); + var response = new Response('', { + status: 200, + headers: [['Content-Type', 'text/plain']] + }); + return cache.put(request, response) + .then(function() { + return cache.match(test_url); + }) + .then(function(result) { + assert_equals(result.status, 200, 'Cache.put should store status.'); + assert_equals(result.headers.get('Content-Type'), 'text/plain', + 'Cache.put should store headers.'); + return result.text(); + }) + .then(function(body) { + assert_equals(body, '', + 'Cache.put should store response body.'); + }); + }, 'Cache.put with an empty response body'); + +cache_test(function(cache) { + var test_url = new URL('../resources/fetch-status.py?status=500', location.href).href; + var request = new Request(test_url); + var response; + return fetch(test_url) + .then(function(fetch_result) { + assert_equals(fetch_result.status, 500, + 'Test framework error: The status code should be 500.'); + response = fetch_result.clone(); + return cache.put(request, fetch_result); + }) + .then(function() { + return cache.match(test_url); + }) + .then(function(result) { + assert_response_equals(result, response, + 'Cache.put should update the cache with ' + + 'new request and response.'); + return result.text(); + }) + .then(function(body) { + assert_equals(body, '', + 'Cache.put should store response body.'); + }); + }, 'Cache.put with HTTP 500 response'); + +cache_test(function(cache) { + var alternate_response_body = 'New body'; + var alternate_response = new Response(alternate_response_body, + { statusText: 'New status' }); + return cache.put(new Request(test_url), + new Response('Old body', { statusText: 'Old status' })) + .then(function() { + return cache.put(new Request(test_url), alternate_response.clone()); + }) + .then(function() { + return cache.match(test_url); + }) + .then(function(result) { + assert_response_equals(result, alternate_response, + 'Cache.put should replace existing ' + + 'response with new response.'); + return result.text(); + }) + .then(function(body) { + assert_equals(body, alternate_response_body, + 'Cache put should store new response body.'); + }); + }, 'Cache.put called twice with matching Requests and different Responses'); + +cache_test(function(cache) { + var first_url = test_url; + var second_url = first_url + '#(O_o)'; + var alternate_response_body = 'New body'; + var alternate_response = new Response(alternate_response_body, + { statusText: 'New status' }); + return cache.put(new Request(first_url), + new Response('Old body', { statusText: 'Old status' })) + .then(function() { + return cache.put(new Request(second_url), alternate_response.clone()); + }) + .then(function() { + return cache.match(test_url); + }) + .then(function(result) { + assert_response_equals(result, alternate_response, + 'Cache.put should replace existing ' + + 'response with new response.'); + return result.text(); + }) + .then(function(body) { + assert_equals(body, alternate_response_body, + 'Cache put should store new response body.'); + }); + }, 'Cache.put called twice with request URLs that differ only by a fragment'); + +cache_test(function(cache) { + var url = 'http://example.com/foo'; + return cache.put(url, new Response('some body')) + .then(function() { return cache.match(url); }) + .then(function(response) { return response.text(); }) + .then(function(body) { + assert_equals(body, 'some body', + 'Cache.put should accept a string as request.'); + }); + }, 'Cache.put with a string request'); + +cache_test(function(cache) { + return assert_promise_rejects( + cache.put(new Request(test_url), 'Hello world!'), + new TypeError(), + 'Cache.put should only accept a Response object as the response.'); + }, 'Cache.put with an invalid response'); + +cache_test(function(cache) { + return assert_promise_rejects( + cache.put(new Request('file:///etc/passwd'), + new Response(test_body)), + new TypeError(), + 'Cache.put should reject non-HTTP/HTTPS requests with a TypeError.'); + }, 'Cache.put with a non-HTTP/HTTPS request'); + +cache_test(function(cache) { + var response = new Response(test_body); + return cache.put(new Request('relative-url'), response.clone()) + .then(function() { + return cache.match(new URL('relative-url', location.href).href); + }) + .then(function(result) { + assert_response_equals(result, response, + 'Cache.put should accept a relative URL ' + + 'as the request.'); + }); + }, 'Cache.put with a relative URL'); + +cache_test(function(cache) { + var request = new Request('http://example.com/foo', { method: 'HEAD' }); + return assert_promise_rejects( + cache.put(request, new Response(test_body)), + new TypeError(), + 'Cache.put should throw a TypeError for non-GET requests.'); + }, 'Cache.put with a non-GET request'); + +cache_test(function(cache) { + return assert_promise_rejects( + cache.put(new Request(test_url), null), + new TypeError(), + 'Cache.put should throw a TypeError for a null response.'); + }, 'Cache.put with a null response'); + +cache_test(function(cache) { + var request = new Request(test_url, {method: 'POST', body: test_body}); + return assert_promise_rejects( + cache.put(request, new Response(test_body)), + new TypeError(), + 'Cache.put should throw a TypeError for a POST request.'); + }, 'Cache.put with a POST request'); + +cache_test(function(cache) { + var response = new Response(test_body); + assert_false(response.bodyUsed, + '[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' + + 'Response.bodyUsed should be initially false.'); + return response.text().then(function() { + assert_true( + response.bodyUsed, + '[https://fetch.spec.whatwg.org/#concept-body-consume-body] ' + + 'The text() method should make the body disturbed.'); + var request = new Request(test_url); + return cache.put(request, response).then(() => { + assert_unreached('cache.put should be rejected'); + }, () => {}); + }); + }, 'Cache.put with a used response body'); + +cache_test(function(cache) { + var response = new Response(test_body); + return cache.put(new Request(test_url), response) + .then(function() { + assert_throws(new TypeError(), () => response.body.getReader()); + }); + }, 'getReader() after Cache.put'); + +cache_test(function(cache) { + return assert_promise_rejects( + cache.put(new Request(test_url), + new Response(test_body, { headers: { VARY: '*' }})), + new TypeError(), + 'Cache.put should reject VARY:* Responses with a TypeError.'); + }, 'Cache.put with a VARY:* Response'); + +cache_test(function(cache) { + return assert_promise_rejects( + cache.put(new Request(test_url), + new Response(test_body, + { headers: { VARY: 'Accept-Language,*' }})), + new TypeError(), + 'Cache.put should reject Responses with an embedded VARY:* with a ' + + 'TypeError.'); + }, 'Cache.put with an embedded VARY:* Response'); + +cache_test(function(cache) { + var url = 'foo.html'; + var redirectURL = 'http://example.com/foo-bar.html'; + var redirectResponse = Response.redirect(redirectURL); + assert_equals(redirectResponse.headers.get('Location'), redirectURL, + 'Response.redirect() should set Location header.'); + return cache.put(url, redirectResponse.clone()) + .then(function() { + return cache.match(url); + }) + .then(function(response) { + assert_response_equals(response, redirectResponse, + 'Redirect response is reproduced by the Cache API'); + assert_equals(response.headers.get('Location'), redirectURL, + 'Location header is preserved by Cache API.'); + }); + }, 'Cache.put should store Response.redirect() correctly'); + +done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-keys.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-keys.js new file mode 100644 index 000000000..4d7bc623f --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-keys.js @@ -0,0 +1,36 @@ +if (self.importScripts) { + importScripts('/resources/testharness.js'); + importScripts('../resources/testharness-helpers.js'); + importScripts('../resources/test-helpers.js'); +} + +var test_cache_list = + ['', 'example', 'Another cache name', 'A', 'a', 'ex ample']; + +promise_test(function(test) { + return self.caches.keys() + .then(function(keys) { + assert_true(Array.isArray(keys), + 'CacheStorage.keys should return an Array.'); + return Promise.all(keys.map(function(key) { + return self.caches.delete(key); + })); + }) + .then(function() { + return Promise.all(test_cache_list.map(function(key) { + return self.caches.open(key); + })); + }) + + .then(function() { return self.caches.keys(); }) + .then(function(keys) { + assert_true(Array.isArray(keys), + 'CacheStorage.keys should return an Array.'); + assert_array_equals(keys, + test_cache_list, + 'CacheStorage.keys should only return ' + + 'existing caches.'); + }); + }, 'CacheStorage keys'); + +done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-match.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-match.js new file mode 100644 index 000000000..0052e43ca --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-match.js @@ -0,0 +1,124 @@ +if (self.importScripts) { + importScripts('/resources/testharness.js'); + importScripts('../resources/testharness-helpers.js'); + importScripts('../resources/test-helpers.js'); +} + +(function() { + var next_index = 1; + + // Returns a transaction (request, response, and url) for a unique URL. + function create_unique_transaction(test) { + var uniquifier = String(next_index++); + var url = 'http://example.com/' + uniquifier; + + return { + request: new Request(url), + response: new Response('hello'), + url: url + }; + } + + self.create_unique_transaction = create_unique_transaction; +})(); + +cache_test(function(cache) { + var transaction = create_unique_transaction(); + + return cache.put(transaction.request.clone(), transaction.response.clone()) + .then(function() { + return self.caches.match(transaction.request); + }) + .then(function(response) { + assert_response_equals(response, transaction.response, + 'The response should not have changed.'); + }); +}, 'CacheStorageMatch with no cache name provided'); + +cache_test(function(cache) { + var transaction = create_unique_transaction(); + + var test_cache_list = ['a', 'b', 'c']; + return cache.put(transaction.request.clone(), transaction.response.clone()) + .then(function() { + return Promise.all(test_cache_list.map(function(key) { + return self.caches.open(key); + })); + }) + .then(function() { + return self.caches.match(transaction.request); + }) + .then(function(response) { + assert_response_equals(response, transaction.response, + 'The response should not have changed.'); + }); +}, 'CacheStorageMatch from one of many caches'); + +promise_test(function(test) { + var transaction = create_unique_transaction(); + + var test_cache_list = ['x', 'y', 'z']; + return Promise.all(test_cache_list.map(function(key) { + return self.caches.open(key); + })) + .then(function() { return caches.open('x'); }) + .then(function(cache) { + return cache.put(transaction.request.clone(), + transaction.response.clone()); + }) + .then(function() { + return self.caches.match(transaction.request, {cacheName: 'x'}); + }) + .then(function(response) { + assert_response_equals(response, transaction.response, + 'The response should not have changed.'); + }) + .then(function() { + return self.caches.match(transaction.request, {cacheName: 'y'}); + }) + .then(function(response) { + assert_equals(response, undefined, + 'Cache y should not have a response for the request.'); + }); +}, 'CacheStorageMatch from one of many caches by name'); + +cache_test(function(cache) { + var transaction = create_unique_transaction(); + return cache.put(transaction.url, transaction.response.clone()) + .then(function() { + return self.caches.match(transaction.request); + }) + .then(function(response) { + assert_response_equals(response, transaction.response, + 'The response should not have changed.'); + }); +}, 'CacheStorageMatch a string request'); + +promise_test(function(test) { + var transaction = create_unique_transaction(); + return self.caches.match(transaction.request) + .then(function(response) { + assert_equals(response, undefined, + 'The response should not be found.'); + }) +}, 'CacheStorageMatch with no cached entry'); + +promise_test(function(test) { + var transaction = create_unique_transaction(); + return self.caches.has('foo') + .then(function(has_foo) { + assert_false(has_foo, "The cache should not exist."); + return self.caches.match(transaction.request, {cacheName: 'foo'}); + }) + .then(function(response) { + assert_equals(response, undefined, + 'The match with bad cache name should resolve to ' + + 'undefined.'); + return self.caches.has('foo'); + }) + .then(function(has_foo) { + assert_false(has_foo, "The cache should still not exist."); + }) +}, 'CacheStorageMatch with no caches available but name provided'); + +done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage.js new file mode 100644 index 000000000..594b01b58 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage.js @@ -0,0 +1,197 @@ +if (self.importScripts) { + importScripts('/resources/testharness.js'); + importScripts('../resources/testharness-helpers.js'); + importScripts('../resources/test-helpers.js'); +} + +promise_test(function(t) { + var cache_name = 'cache-storage/foo'; + return self.caches.delete(cache_name) + .then(function() { + return self.caches.open(cache_name); + }) + .then(function(cache) { + assert_true(cache instanceof Cache, + 'CacheStorage.open should return a Cache.'); + }); + }, 'CacheStorage.open'); + +promise_test(function(t) { + // Note that this test may collide with other tests running in the same + // origin that also uses an empty cache name. + var cache_name = ''; + return self.caches.delete(cache_name) + .then(function() { + return self.caches.open(cache_name); + }) + .then(function(cache) { + assert_true(cache instanceof Cache, + 'CacheStorage.open should accept an empty name.'); + }); + }, 'CacheStorage.open with an empty name'); + +promise_test(function(t) { + return assert_promise_rejects( + self.caches.open(), + new TypeError(), + 'CacheStorage.open should throw TypeError if called with no arguments.'); + }, 'CacheStorage.open with no arguments'); + +promise_test(function(t) { + var test_cases = [ + { + name: 'cache-storage/lowercase', + should_not_match: + [ + 'cache-storage/Lowercase', + ' cache-storage/lowercase', + 'cache-storage/lowercase ' + ] + }, + { + name: 'cache-storage/has a space', + should_not_match: + [ + 'cache-storage/has' + ] + }, + { + name: 'cache-storage/has\000_in_the_name', + should_not_match: + [ + 'cache-storage/has', + 'cache-storage/has_in_the_name' + ] + } + ]; + return Promise.all(test_cases.map(function(testcase) { + var cache_name = testcase.name; + return self.caches.delete(cache_name) + .then(function() { + return self.caches.open(cache_name); + }) + .then(function() { + return self.caches.has(cache_name); + }) + .then(function(result) { + assert_true(result, + 'CacheStorage.has should return true for existing ' + + 'cache.'); + }) + .then(function() { + return Promise.all( + testcase.should_not_match.map(function(cache_name) { + return self.caches.has(cache_name) + .then(function(result) { + assert_false(result, + 'CacheStorage.has should only perform ' + + 'exact matches on cache names.'); + }); + })); + }) + .then(function() { + return self.caches.delete(cache_name); + }); + })); + }, 'CacheStorage.has with existing cache'); + +promise_test(function(t) { + return self.caches.has('cheezburger') + .then(function(result) { + assert_false(result, + 'CacheStorage.has should return false for ' + + 'nonexistent cache.'); + }); + }, 'CacheStorage.has with nonexistent cache'); + +promise_test(function(t) { + var cache_name = 'cache-storage/open'; + var cache; + return self.caches.delete(cache_name) + .then(function() { + return self.caches.open(cache_name); + }) + .then(function(result) { + cache = result; + }) + .then(function() { + return cache.add('../resources/simple.txt'); + }) + .then(function() { + return self.caches.open(cache_name); + }) + .then(function(result) { + assert_true(result instanceof Cache, + 'CacheStorage.open should return a Cache object'); + assert_not_equals(result, cache, + 'CacheStorage.open should return a new Cache ' + + 'object each time its called.'); + return Promise.all([cache.keys(), result.keys()]); + }) + .then(function(results) { + var expected_urls = results[0].map(function(r) { return r.url }); + var actual_urls = results[1].map(function(r) { return r.url }); + assert_array_equals(actual_urls, expected_urls, + 'CacheStorage.open should return a new Cache ' + + 'object for the same backing store.'); + }); + }, 'CacheStorage.open with existing cache'); + +promise_test(function(t) { + var cache_name = 'cache-storage/delete'; + + return self.caches.delete(cache_name) + .then(function() { + return self.caches.open(cache_name); + }) + .then(function() { return self.caches.delete(cache_name); }) + .then(function(result) { + assert_true(result, + 'CacheStorage.delete should return true after ' + + 'deleting an existing cache.'); + }) + + .then(function() { return self.caches.has(cache_name); }) + .then(function(cache_exists) { + assert_false(cache_exists, + 'CacheStorage.has should return false after ' + + 'fulfillment of CacheStorage.delete promise.'); + }); + }, 'CacheStorage.delete with existing cache'); + +promise_test(function(t) { + return self.caches.delete('cheezburger') + .then(function(result) { + assert_false(result, + 'CacheStorage.delete should return false for a ' + + 'nonexistent cache.'); + }); + }, 'CacheStorage.delete with nonexistent cache'); + +promise_test(function(t) { + var bad_name = 'unpaired\uD800'; + var converted_name = 'unpaired\uFFFD'; // Don't create cache with this name. + return self.caches.has(converted_name) + .then(function(cache_exists) { + assert_false(cache_exists, + 'Test setup failure: cache should not exist'); + }) + .then(function() { return self.caches.open(bad_name); }) + .then(function() { return self.caches.keys(); }) + .then(function(keys) { + assert_true(keys.indexOf(bad_name) !== -1, + 'keys should include cache with bad name'); + }) + .then(function() { return self.caches.has(bad_name); }) + .then(function(cache_exists) { + assert_true(cache_exists, + 'CacheStorage names should be not be converted.'); + }) + .then(function() { return self.caches.has(converted_name); }) + .then(function(cache_exists) { + assert_false(cache_exists, + 'CacheStorage names should be not be converted.'); + }); + }, 'CacheStorage names are DOMStrings not USVStrings'); + +done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-add.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-add.https.html new file mode 100644 index 000000000..232de668e --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-add.https.html @@ -0,0 +1,10 @@ + +Cache.add and Cache.addAll + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-delete.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-delete.https.html new file mode 100644 index 000000000..6ff27be30 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-delete.https.html @@ -0,0 +1,10 @@ + +Cache.delete + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-match.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-match.https.html new file mode 100644 index 000000000..81db70943 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-match.https.html @@ -0,0 +1,10 @@ + +Cache.match + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-matchAll.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-matchAll.https.html new file mode 100644 index 000000000..f1a38ff07 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-matchAll.https.html @@ -0,0 +1,10 @@ + +Cache.matchAll + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-put.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-put.https.html new file mode 100644 index 000000000..961602386 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-put.https.html @@ -0,0 +1,10 @@ + +Cache.put + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-keys.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-keys.https.html new file mode 100644 index 000000000..adde95eb8 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-keys.https.html @@ -0,0 +1,10 @@ + +CacheStorage.keys + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-match.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-match.https.html new file mode 100644 index 000000000..fef14074d --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-match.https.html @@ -0,0 +1,10 @@ + +CacheStorage.match + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage.https.html new file mode 100644 index 000000000..3934258f2 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage.https.html @@ -0,0 +1,10 @@ + +CacheStorage + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/credentials.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/credentials.html new file mode 100644 index 000000000..7bc494eb1 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/credentials.html @@ -0,0 +1,46 @@ + + +Cache Storage: Verify credentials are respected by Cache operations + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-add.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-add.https.html new file mode 100644 index 000000000..d9945f9ae --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/window/cache-add.https.html @@ -0,0 +1,9 @@ + +Cache Storage: Cache.add and Cache.addAll + + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-delete.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-delete.https.html new file mode 100644 index 000000000..735d2cdb4 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/window/cache-delete.https.html @@ -0,0 +1,9 @@ + +Cache Storage: Cache.delete + + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-match.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-match.https.html new file mode 100644 index 000000000..0ff5c6799 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/window/cache-match.https.html @@ -0,0 +1,9 @@ + +Cache Storage: Cache.match + + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-matchAll.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-matchAll.https.html new file mode 100644 index 000000000..372e641a5 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/window/cache-matchAll.https.html @@ -0,0 +1,9 @@ + +Cache.matchAll + + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-put.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-put.https.html new file mode 100644 index 000000000..1d9e02ba6 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/window/cache-put.https.html @@ -0,0 +1,9 @@ + +Cache Storage: Cache.put + + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-keys.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-keys.https.html new file mode 100644 index 000000000..b4f94bade --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-keys.https.html @@ -0,0 +1,9 @@ + +Cache Storage: CacheStorage.keys + + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-match.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-match.https.html new file mode 100644 index 000000000..72005f43a --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-match.https.html @@ -0,0 +1,9 @@ + +Cache Storage: CacheStorage.match + + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage.https.html new file mode 100644 index 000000000..6c4f4af7f --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage.https.html @@ -0,0 +1,9 @@ + +Cache Storage: CacheStorage + + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/sandboxed-iframes.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/sandboxed-iframes.https.html new file mode 100644 index 000000000..061858521 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/window/sandboxed-iframes.https.html @@ -0,0 +1,67 @@ + +Cache Storage: Verify access in sandboxed iframes + + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-add.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-add.https.html new file mode 100644 index 000000000..2658e1e50 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-add.https.html @@ -0,0 +1,9 @@ + +Cache.add and Cache.addAll + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-delete.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-delete.https.html new file mode 100644 index 000000000..3d63a2f7f --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-delete.https.html @@ -0,0 +1,9 @@ + +Cache.delete + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-match.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-match.https.html new file mode 100644 index 000000000..479a29d1e --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-match.https.html @@ -0,0 +1,9 @@ + +Cache.match + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-matchAll.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-matchAll.https.html new file mode 100644 index 000000000..c7e893a23 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-matchAll.https.html @@ -0,0 +1,9 @@ + +Cache.matchAll + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-put.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-put.https.html new file mode 100644 index 000000000..20aeb2351 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-put.https.html @@ -0,0 +1,9 @@ + +Cache.put + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-keys.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-keys.https.html new file mode 100644 index 000000000..71d995bc9 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-keys.https.html @@ -0,0 +1,9 @@ + +CacheStorage.keys + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-match.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-match.https.html new file mode 100644 index 000000000..cd93410d2 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-match.https.html @@ -0,0 +1,9 @@ + +CacheStorage.match + + + + + diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage.https.html new file mode 100644 index 000000000..0899609e4 --- /dev/null +++ b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage.https.html @@ -0,0 +1,9 @@ + +CacheStorage + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/registration-attribute.https.html b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/registration-attribute.https.html new file mode 100644 index 000000000..f0dad6a7b --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/registration-attribute.https.html @@ -0,0 +1,37 @@ + +ServiceWorkerGlobalScope: registration + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/registration-attribute-worker.js b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/registration-attribute-worker.js new file mode 100644 index 000000000..c98acbcfb --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/registration-attribute-worker.js @@ -0,0 +1,132 @@ +importScripts('../../resources/test-helpers.sub.js'); +importScripts('../../resources/worker-testharness.js'); + +var events_seen = []; + +assert_equals( + self.registration.scope, + normalizeURL('scope/registration-attribute'), + 'On worker script evaluation, registration attribute should be set'); +assert_equals( + self.registration.installing, + null, + 'On worker script evaluation, installing worker should be null'); +assert_equals( + self.registration.waiting, + null, + 'On worker script evaluation, waiting worker should be null'); +assert_equals( + self.registration.active, + null, + 'On worker script evaluation, active worker should be null'); + +self.registration.addEventListener('updatefound', function() { + events_seen.push('updatefound'); + + assert_equals( + self.registration.scope, + normalizeURL('scope/registration-attribute'), + 'On updatefound event, registration attribute should be set'); + assert_equals( + self.registration.installing.scriptURL, + normalizeURL('registration-attribute-worker.js'), + 'On updatefound event, installing worker should be set'); + assert_equals( + self.registration.waiting, + null, + 'On updatefound event, waiting worker should be null'); + assert_equals( + self.registration.active, + null, + 'On updatefound event, active worker should be null'); + + assert_equals( + self.registration.installing.state, + 'installing', + 'On updatefound event, worker should be in the installing state'); + + var worker = self.registration.installing; + self.registration.installing.addEventListener('statechange', function() { + events_seen.push('statechange(' + worker.state + ')'); + }); + }); + +self.addEventListener('install', function(e) { + events_seen.push('install'); + + assert_equals( + self.registration.scope, + normalizeURL('scope/registration-attribute'), + 'On install event, registration attribute should be set'); + assert_equals( + self.registration.installing.scriptURL, + normalizeURL('registration-attribute-worker.js'), + 'On install event, installing worker should be set'); + assert_equals( + self.registration.waiting, + null, + 'On install event, waiting worker should be null'); + assert_equals( + self.registration.active, + null, + 'On install event, active worker should be null'); + + assert_equals( + self.registration.installing.state, + 'installing', + 'On install event, worker should be in the installing state'); + }); + +self.addEventListener('activate', function(e) { + events_seen.push('activate'); + + assert_equals( + self.registration.scope, + normalizeURL('scope/registration-attribute'), + 'On activate event, registration attribute should be set'); + assert_equals( + self.registration.installing, + null, + 'On activate event, installing worker should be null'); + assert_equals( + self.registration.waiting, + null, + 'On activate event, waiting worker should be null'); + assert_equals( + self.registration.active.scriptURL, + normalizeURL('registration-attribute-worker.js'), + 'On activate event, active worker should be set'); + + assert_equals( + self.registration.active.state, + 'activating', + 'On activate event, worker should be in the activating state'); + }); + +self.addEventListener('fetch', function(e) { + events_seen.push('fetch'); + + assert_equals( + self.registration.scope, + normalizeURL('scope/registration-attribute'), + 'On fetch event, registration attribute should be set'); + assert_equals( + self.registration.installing, + null, + 'On fetch event, installing worker should be null'); + assert_equals( + self.registration.waiting, + null, + 'On fetch event, waiting worker should be null'); + assert_equals( + self.registration.active.scriptURL, + normalizeURL('registration-attribute-worker.js'), + 'On fetch event, active worker should be set'); + + assert_equals( + self.registration.active.state, + 'activated', + 'On fetch event, worker should be in the activated state'); + + e.respondWith(new Response(events_seen)); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/unregister-controlling-worker.html b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/unregister-controlling-worker.html new file mode 100644 index 000000000..e69de29bb diff --git a/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/unregister-worker.js b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/unregister-worker.js new file mode 100644 index 000000000..6cee53654 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/unregister-worker.js @@ -0,0 +1,23 @@ +function matchQuery(query) { + return self.location.href.indexOf(query) != -1; +} + +if (matchQuery('?evaluation')) + self.registration.unregister(); + +self.addEventListener('install', function(e) { + if (matchQuery('?install')) + self.registration.unregister(); + }); + +self.addEventListener('activate', function(e) { + if (matchQuery('?activate')) + self.registration.unregister(); + }); + +self.addEventListener('message', function(e) { + self.registration.unregister() + .then(function(result) { + e.data.port.postMessage({result: result}); + }); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/update-worker.js b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/update-worker.js new file mode 100644 index 000000000..63c4534b7 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/update-worker.js @@ -0,0 +1,25 @@ +importScripts('../../resources/test-helpers.sub.js'); +importScripts('../../resources/worker-testharness.js'); + +var events_seen = []; + +self.registration.addEventListener('updatefound', function() { + events_seen.push('updatefound'); + }); + +self.addEventListener('activate', function(e) { + events_seen.push('activate'); + }); + +self.addEventListener('fetch', function(e) { + events_seen.push('fetch'); + e.respondWith(new Response(events_seen)); + }); + +self.addEventListener('message', function(e) { + events_seen.push('message'); + self.registration.update(); + }); + +// update() during the script evaluation should be ignored. +self.registration.update(); diff --git a/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/update-worker.py b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/update-worker.py new file mode 100644 index 000000000..5158bf251 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/update-worker.py @@ -0,0 +1,14 @@ +import os +import time + +def main(request, response): + # update() does not bypass cache so set the max-age to 0 such that update() + # can find a new version in the network. + headers = [('Cache-Control', 'max-age: 0'), + ('Content-Type', 'application/javascript')] + with open(os.path.join(os.path.dirname(__file__), + 'update-worker.js'), 'r') as file: + script = file.read() + # Return a different script for each access. + return headers, '// %s\n%s' % (time.time(), script) + diff --git a/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/unregister.https.html b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/unregister.https.html new file mode 100644 index 000000000..313309188 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/unregister.https.html @@ -0,0 +1,127 @@ + +ServiceWorkerGlobalScope: unregister + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/update.https.html b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/update.https.html new file mode 100644 index 000000000..a9285a1c9 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/ServiceWorkerGlobalScope/update.https.html @@ -0,0 +1,45 @@ + +ServiceWorkerGlobalScope: update + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/activate-event-after-install-state-change.https.html b/testing/web-platform/tests/service-workers/service-worker/activate-event-after-install-state-change.https.html new file mode 100644 index 000000000..57fccf137 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/activate-event-after-install-state-change.https.html @@ -0,0 +1,32 @@ + +Service Worker: registration events + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/activation-after-registration.https.html b/testing/web-platform/tests/service-workers/service-worker/activation-after-registration.https.html new file mode 100644 index 000000000..ff0990df6 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/activation-after-registration.https.html @@ -0,0 +1,29 @@ + +Service Worker: Activation occurs after registration + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/activation.https.html b/testing/web-platform/tests/service-workers/service-worker/activation.https.html new file mode 100644 index 000000000..75fdff813 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/activation.https.html @@ -0,0 +1,179 @@ + + +service worker: activation + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/active.https.html b/testing/web-platform/tests/service-workers/service-worker/active.https.html new file mode 100644 index 000000000..deee6a50e --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/active.https.html @@ -0,0 +1,55 @@ + +ServiceWorker: navigator.serviceWorker.active + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/appcache-ordering-main.https.html b/testing/web-platform/tests/service-workers/service-worker/appcache-ordering-main.https.html new file mode 100644 index 000000000..609d67e45 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/appcache-ordering-main.https.html @@ -0,0 +1,91 @@ + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/claim-not-using-registration.https.html b/testing/web-platform/tests/service-workers/service-worker/claim-not-using-registration.https.html new file mode 100644 index 000000000..e18e061cd --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/claim-not-using-registration.https.html @@ -0,0 +1,123 @@ + +Service Worker: claim client not using registration + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/claim-using-registration.https.html b/testing/web-platform/tests/service-workers/service-worker/claim-using-registration.https.html new file mode 100644 index 000000000..640b0be3e --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/claim-using-registration.https.html @@ -0,0 +1,100 @@ + +Service Worker: claim client using registration + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/client-navigate.https.html b/testing/web-platform/tests/service-workers/service-worker/client-navigate.https.html new file mode 100644 index 000000000..a505e8722 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/client-navigate.https.html @@ -0,0 +1,117 @@ + + +Service Worker: WindowClient.navigate + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/clients-get-cross-origin.https.html b/testing/web-platform/tests/service-workers/service-worker/clients-get-cross-origin.https.html new file mode 100644 index 000000000..3413acbf9 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/clients-get-cross-origin.https.html @@ -0,0 +1,42 @@ + +Service Worker: Clients.get across origins + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/clients-get.https.html b/testing/web-platform/tests/service-workers/service-worker/clients-get.https.html new file mode 100644 index 000000000..af38502dd --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/clients-get.https.html @@ -0,0 +1,70 @@ + +Service Worker: Clients.get + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/clients-matchall-client-types.https.html b/testing/web-platform/tests/service-workers/service-worker/clients-matchall-client-types.https.html new file mode 100644 index 000000000..3645e8635 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/clients-matchall-client-types.https.html @@ -0,0 +1,78 @@ + +Service Worker: Clients.matchAll with various clientTypes + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/clients-matchall-include-uncontrolled.https.html b/testing/web-platform/tests/service-workers/service-worker/clients-matchall-include-uncontrolled.https.html new file mode 100644 index 000000000..9285aef97 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/clients-matchall-include-uncontrolled.https.html @@ -0,0 +1,93 @@ + +Service Worker: Clients.matchAll with includeUncontrolled + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/clients-matchall.https.html b/testing/web-platform/tests/service-workers/service-worker/clients-matchall.https.html new file mode 100644 index 000000000..12e3da4e6 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/clients-matchall.https.html @@ -0,0 +1,45 @@ + +Service Worker: Clients.matchAll + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/controller-on-disconnect.https.html b/testing/web-platform/tests/service-workers/service-worker/controller-on-disconnect.https.html new file mode 100644 index 000000000..920d190e3 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/controller-on-disconnect.https.html @@ -0,0 +1,40 @@ + +Service Worker: Controller on load + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/controller-on-load.https.html b/testing/web-platform/tests/service-workers/service-worker/controller-on-load.https.html new file mode 100644 index 000000000..ff3b7ce04 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/controller-on-load.https.html @@ -0,0 +1,45 @@ + +Service Worker: Controller on load + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/controller-on-reload.https.html b/testing/web-platform/tests/service-workers/service-worker/controller-on-reload.https.html new file mode 100644 index 000000000..4490c7079 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/controller-on-reload.https.html @@ -0,0 +1,54 @@ + +Service Worker: Controller on reload + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/extendable-event-async-waituntil.https.html b/testing/web-platform/tests/service-workers/service-worker/extendable-event-async-waituntil.https.html new file mode 100644 index 000000000..c06bf84ab --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/extendable-event-async-waituntil.https.html @@ -0,0 +1,30 @@ + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/extendable-event-waituntil.https.html b/testing/web-platform/tests/service-workers/service-worker/extendable-event-waituntil.https.html new file mode 100644 index 000000000..003e703b1 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/extendable-event-waituntil.https.html @@ -0,0 +1,125 @@ + +ExtendableEvent: waitUntil + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html new file mode 100644 index 000000000..fdb64e15d --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html @@ -0,0 +1,38 @@ + +Service Worker: canvas tainting of the fetched image using cached responses + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-canvas-tainting.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-canvas-tainting.https.html new file mode 100644 index 000000000..bb7547392 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-canvas-tainting.https.html @@ -0,0 +1,38 @@ + +Service Worker: canvas tainting of the fetched image + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-cors-xhr.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-cors-xhr.https.html new file mode 100644 index 000000000..3b1f1d6bc --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-cors-xhr.https.html @@ -0,0 +1,38 @@ + +Service Worker: CORS XHR of fetch() + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-csp.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-csp.https.html new file mode 100644 index 000000000..bdb56c213 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-csp.https.html @@ -0,0 +1,32 @@ + +Service Worker: CSP control of fetch() + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-event-after-navigation-within-page.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-event-after-navigation-within-page.https.html new file mode 100644 index 000000000..dce1f794f --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-event-after-navigation-within-page.https.html @@ -0,0 +1,65 @@ + +ServiceWorker: navigator.serviceWorker.waiting + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-event-async-respond-with.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-event-async-respond-with.https.html new file mode 100644 index 000000000..912e709ca --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-event-async-respond-with.https.html @@ -0,0 +1,34 @@ + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-event-network-error.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-event-network-error.https.html new file mode 100644 index 000000000..f6a3d0776 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-event-network-error.https.html @@ -0,0 +1,42 @@ + +Service Worker: Fetch event network error + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-event-redirect.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-event-redirect.https.html new file mode 100644 index 000000000..17f4cb15e --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-event-redirect.https.html @@ -0,0 +1,1102 @@ + +Service Worker: Fetch Event Redirect Handling + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-event-respond-with-stops-propagation.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-event-respond-with-stops-propagation.https.html new file mode 100644 index 000000000..5d3346e7b --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-event-respond-with-stops-propagation.https.html @@ -0,0 +1,35 @@ + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-event.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-event.https.html new file mode 100644 index 000000000..dfa96ebb5 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-event.https.html @@ -0,0 +1,575 @@ + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-frame-resource.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-frame-resource.https.html new file mode 100644 index 000000000..cc1dac472 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-frame-resource.https.html @@ -0,0 +1,221 @@ + +Service Worker: Fetch for the frame loading. + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-header-visibility.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-header-visibility.https.html new file mode 100644 index 000000000..36bf16f32 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-header-visibility.https.html @@ -0,0 +1,52 @@ + +Service Worker: Visibility of headers during fetch. + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-mixed-content-to-inscope.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-mixed-content-to-inscope.https.html new file mode 100644 index 000000000..fb9fa9b7b --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-mixed-content-to-inscope.https.html @@ -0,0 +1,27 @@ + +Service Worker: Mixed content of fetch() + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-mixed-content-to-outscope.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-mixed-content-to-outscope.https.html new file mode 100644 index 000000000..cee89ce16 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-mixed-content-to-outscope.https.html @@ -0,0 +1,27 @@ + +Service Worker: Mixed content of fetch() + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-request-css-base-url.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-request-css-base-url.https.html new file mode 100644 index 000000000..0405ed709 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-request-css-base-url.https.html @@ -0,0 +1,56 @@ + +Service Worker: CSS's base URL must be the request URL even when fetched from other URL + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-request-css-images.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-request-css-images.https.html new file mode 100644 index 000000000..777308241 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-request-css-images.https.html @@ -0,0 +1,176 @@ + +Service Worker: FetchEvent for css image + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-request-fallback.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-request-fallback.https.html new file mode 100644 index 000000000..8290e21dd --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-request-fallback.https.html @@ -0,0 +1,113 @@ + +Service Worker: the fallback behavior of FetchEvent + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-request-no-freshness-headers.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-request-no-freshness-headers.https.html new file mode 100644 index 000000000..829b0cf25 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-request-no-freshness-headers.https.html @@ -0,0 +1,53 @@ + +Service Worker: the headers of FetchEvent shouldn't contain freshness headers + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-request-redirect.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-request-redirect.https.html new file mode 100644 index 000000000..25d4a6ef3 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-request-redirect.https.html @@ -0,0 +1,372 @@ + +Service Worker: FetchEvent for resources + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-request-resources.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-request-resources.https.html new file mode 100644 index 000000000..7a64e9444 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-request-resources.https.html @@ -0,0 +1,189 @@ + +Service Worker: FetchEvent for resources + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-request-xhr.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-request-xhr.https.html new file mode 100644 index 000000000..1b80985a3 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-request-xhr.https.html @@ -0,0 +1,33 @@ + +Service Worker: the body of FetchEvent using XMLHttpRequest + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-response-xhr.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-response-xhr.https.html new file mode 100644 index 000000000..8b66c6051 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-response-xhr.https.html @@ -0,0 +1,37 @@ + +Service Worker: the response of FetchEvent using XMLHttpRequest + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/fetch-waits-for-activate.https.html b/testing/web-platform/tests/service-workers/service-worker/fetch-waits-for-activate.https.html new file mode 100644 index 000000000..304680c97 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/fetch-waits-for-activate.https.html @@ -0,0 +1,63 @@ + +Service Worker: Fetch Event Waits for Activate Event + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/getregistration.https.html b/testing/web-platform/tests/service-workers/service-worker/getregistration.https.html new file mode 100644 index 000000000..c86fda50d --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/getregistration.https.html @@ -0,0 +1,87 @@ + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/getregistrations.https.html b/testing/web-platform/tests/service-workers/service-worker/getregistrations.https.html new file mode 100644 index 000000000..b65a97869 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/getregistrations.https.html @@ -0,0 +1,191 @@ + +Service Worker: getRegistrations() + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/indexeddb.https.html b/testing/web-platform/tests/service-workers/service-worker/indexeddb.https.html new file mode 100644 index 000000000..4de2bc43e --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/indexeddb.https.html @@ -0,0 +1,35 @@ + +Service Worker: Indexed DB + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/install-event-type.https.html b/testing/web-platform/tests/service-workers/service-worker/install-event-type.https.html new file mode 100644 index 000000000..7e74af85c --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/install-event-type.https.html @@ -0,0 +1,30 @@ + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/installing.https.html b/testing/web-platform/tests/service-workers/service-worker/installing.https.html new file mode 100644 index 000000000..57d878111 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/installing.https.html @@ -0,0 +1,37 @@ + +ServiceWorker: navigator.serviceWorker.installing + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/interfaces.https.html b/testing/web-platform/tests/service-workers/service-worker/interfaces.https.html new file mode 100644 index 000000000..403a00534 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/interfaces.https.html @@ -0,0 +1,56 @@ + +Service Worker: Interfaces + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/invalid-blobtype.https.html b/testing/web-platform/tests/service-workers/service-worker/invalid-blobtype.https.html new file mode 100644 index 000000000..f1f2d1bdc --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/invalid-blobtype.https.html @@ -0,0 +1,30 @@ + +Service Worker: respondWith with header value containing a null byte + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/invalid-header.https.html b/testing/web-platform/tests/service-workers/service-worker/invalid-header.https.html new file mode 100644 index 000000000..794695264 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/invalid-header.https.html @@ -0,0 +1,30 @@ + +Service Worker: respondWith with header value containing a null byte + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/multiple-register.https.html b/testing/web-platform/tests/service-workers/service-worker/multiple-register.https.html new file mode 100644 index 000000000..1089cffda --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/multiple-register.https.html @@ -0,0 +1,116 @@ + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/multiple-update.https.html b/testing/web-platform/tests/service-workers/service-worker/multiple-update.https.html new file mode 100644 index 000000000..84aac9583 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/multiple-update.https.html @@ -0,0 +1,92 @@ + + +Service Worker: Trigger multiple updates + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/navigate-window.https.html b/testing/web-platform/tests/service-workers/service-worker/navigate-window.https.html new file mode 100644 index 000000000..e3aaf4c5c --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/navigate-window.https.html @@ -0,0 +1,141 @@ + +Service Worker: Navigate a Window + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/navigation-redirect.https.html b/testing/web-platform/tests/service-workers/service-worker/navigation-redirect.https.html new file mode 100644 index 000000000..7b606cf0c --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/navigation-redirect.https.html @@ -0,0 +1,449 @@ + +Service Worker: Navigation redirection + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/onactivate-script-error.https.html b/testing/web-platform/tests/service-workers/service-worker/onactivate-script-error.https.html new file mode 100644 index 000000000..23a7f2c86 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/onactivate-script-error.https.html @@ -0,0 +1,75 @@ + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/oninstall-script-error.https.html b/testing/web-platform/tests/service-workers/service-worker/oninstall-script-error.https.html new file mode 100644 index 000000000..a9ca19cab --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/oninstall-script-error.https.html @@ -0,0 +1,67 @@ + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/performance-timeline.https.html b/testing/web-platform/tests/service-workers/service-worker/performance-timeline.https.html new file mode 100644 index 000000000..182076baa --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/performance-timeline.https.html @@ -0,0 +1,11 @@ + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/postmessage-msgport-to-client.https.html b/testing/web-platform/tests/service-workers/service-worker/postmessage-msgport-to-client.https.html new file mode 100644 index 000000000..38b4f56e7 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/postmessage-msgport-to-client.https.html @@ -0,0 +1,51 @@ + +Service Worker: postMessage to Client + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/postmessage-to-client.https.html b/testing/web-platform/tests/service-workers/service-worker/postmessage-to-client.https.html new file mode 100644 index 000000000..a031ee2ed --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/postmessage-to-client.https.html @@ -0,0 +1,49 @@ + +Service Worker: postMessage to Client + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/postmessage.https.html b/testing/web-platform/tests/service-workers/service-worker/postmessage.https.html new file mode 100644 index 000000000..a6f665179 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/postmessage.https.html @@ -0,0 +1,60 @@ + +Service Worker: postMessage + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/ready.https.html b/testing/web-platform/tests/service-workers/service-worker/ready.https.html new file mode 100644 index 000000000..ee6a97ca8 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/ready.https.html @@ -0,0 +1,172 @@ + +Service Worker: navigator.serviceWorker.ready + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/referer.https.html b/testing/web-platform/tests/service-workers/service-worker/referer.https.html new file mode 100644 index 000000000..9b3565329 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/referer.https.html @@ -0,0 +1,30 @@ + +Service Worker: check referer of fetch() + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/register-closed-window.https.html b/testing/web-platform/tests/service-workers/service-worker/register-closed-window.https.html new file mode 100644 index 000000000..221356716 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/register-closed-window.https.html @@ -0,0 +1,35 @@ + +Service Worker: Register() on Closed Window + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/register-default-scope.https.html b/testing/web-platform/tests/service-workers/service-worker/register-default-scope.https.html new file mode 100644 index 000000000..dc136d4e8 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/register-default-scope.https.html @@ -0,0 +1,66 @@ + +register() and scope + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/register-same-scope-different-script-url.https.html b/testing/web-platform/tests/service-workers/service-worker/register-same-scope-different-script-url.https.html new file mode 100644 index 000000000..445be7409 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/register-same-scope-different-script-url.https.html @@ -0,0 +1,240 @@ + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/register-wait-forever-in-install-worker.https.html b/testing/web-platform/tests/service-workers/service-worker/register-wait-forever-in-install-worker.https.html new file mode 100644 index 000000000..e23f9f4fc --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/register-wait-forever-in-install-worker.https.html @@ -0,0 +1,56 @@ + +Service Worker: Register wait-forever-in-install-worker + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/registration-end-to-end.https.html b/testing/web-platform/tests/service-workers/service-worker/registration-end-to-end.https.html new file mode 100644 index 000000000..e92b6502f --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/registration-end-to-end.https.html @@ -0,0 +1,96 @@ + +Service Worker: registration end-to-end + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/registration-events.https.html b/testing/web-platform/tests/service-workers/service-worker/registration-events.https.html new file mode 100644 index 000000000..972ce7410 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/registration-events.https.html @@ -0,0 +1,37 @@ + +Service Worker: registration events + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/registration-iframe.https.html b/testing/web-platform/tests/service-workers/service-worker/registration-iframe.https.html new file mode 100644 index 000000000..fb60afe84 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/registration-iframe.https.html @@ -0,0 +1,108 @@ + + +Service Worker: Registration for iframe + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/registration-service-worker-attributes.https.html b/testing/web-platform/tests/service-workers/service-worker/registration-service-worker-attributes.https.html new file mode 100644 index 000000000..a0dea5428 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/registration-service-worker-attributes.https.html @@ -0,0 +1,70 @@ + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/registration.https.html b/testing/web-platform/tests/service-workers/service-worker/registration.https.html new file mode 100644 index 000000000..ae9f85fb2 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/registration.https.html @@ -0,0 +1,368 @@ + +Service Worker: Registration + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/rejections.https.html b/testing/web-platform/tests/service-workers/service-worker/rejections.https.html new file mode 100644 index 000000000..8002ad9a8 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/rejections.https.html @@ -0,0 +1,21 @@ + +Service Worker: Rejection Types + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/request-end-to-end.https.html b/testing/web-platform/tests/service-workers/service-worker/request-end-to-end.https.html new file mode 100644 index 000000000..c9c3b3046 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/request-end-to-end.https.html @@ -0,0 +1,61 @@ + +Service Worker: Request end-to-end + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resource-timing.https.html b/testing/web-platform/tests/service-workers/service-worker/resource-timing.https.html new file mode 100644 index 000000000..f33c41d71 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resource-timing.https.html @@ -0,0 +1,58 @@ + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/404.py b/testing/web-platform/tests/service-workers/service-worker/resources/404.py new file mode 100644 index 000000000..235a3d4ff --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/404.py @@ -0,0 +1,5 @@ +# iframe does not fire onload event if the response's content-type is not +# text/plain or text/html so this script exists if you want to test a 404 load +# in an iframe. +def main(req, res): + return 404, [('Content-Type', 'text/plain')], "Page not found" diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.install.html b/testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.install.html new file mode 100644 index 000000000..428ad92c7 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.install.html @@ -0,0 +1,26 @@ + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.is-appcached.html b/testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.is-appcached.html new file mode 100644 index 000000000..485ab1771 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.is-appcached.html @@ -0,0 +1,13 @@ + + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.is-appcached.js b/testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.is-appcached.js new file mode 100644 index 000000000..a562b6f1c --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.is-appcached.js @@ -0,0 +1 @@ +var is_appcached = true; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.manifest b/testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.manifest new file mode 100644 index 000000000..0deed0e91 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/appcache-ordering.manifest @@ -0,0 +1,7 @@ +CACHE MANIFEST + +appcache-ordering.is-appcached.html + +FALLBACK: +appcache-ordering.is-appcached404.js appcache-ordering.is-appcached.js + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/blank.html b/testing/web-platform/tests/service-workers/service-worker/resources/blank.html new file mode 100644 index 000000000..a3c3a4689 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/blank.html @@ -0,0 +1,2 @@ + +Empty doc diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/claim-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/claim-worker.js new file mode 100644 index 000000000..317feb1a0 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/claim-worker.js @@ -0,0 +1,14 @@ +self.addEventListener('message', function(event) { + self.clients.claim() + .then(function(result) { + if (result !== undefined) { + event.data.port.postMessage( + 'FAIL: claim() should be resolved with undefined'); + return; + } + event.data.port.postMessage('PASS'); + }) + .catch(function(error) { + event.data.port.postMessage('FAIL: exception: ' + error.name); + }); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/client-navigate-frame.html b/testing/web-platform/tests/service-workers/service-worker/resources/client-navigate-frame.html new file mode 100644 index 000000000..7e186f8ee --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/client-navigate-frame.html @@ -0,0 +1,12 @@ + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/client-navigate-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/client-navigate-worker.js new file mode 100644 index 000000000..3f2424078 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/client-navigate-worker.js @@ -0,0 +1,71 @@ +importScripts("worker-testharness.js"); +importScripts("test-helpers.sub.js"); +importScripts("get-host-info.sub.js") +importScripts("testharness-helpers.js") + +self.onfetch = function(e) { + if (e.request.url.indexOf("client-navigate-frame.html") >= 0) { + if (e.clientId === null) { + e.respondWith(fetch(e.request)); + } else { + e.respondWith(Response.error()); + } + return; + } + e.respondWith(new Response(e.clientId)); +}; + +function pass(test, url) { + return { result: test, + url: url }; +} + +function fail(test, reason) { + return { result: "FAILED " + test + " " + reason } +} + +self.onmessage = function(e) { + var port = e.data.port; + var test = e.data.test; + var clientId = e.data.clientId; + var clientUrl = ""; + if (test === "test_client_navigate_success") { + promise_test(function(t) { + this.add_cleanup(() => port.postMessage(pass(test, clientUrl))); + return self.clients.get(clientId) + .then(client => client.navigate("client-navigated-frame.html")) + .then(client => { + clientUrl = client.url; + assert_true(client instanceof WindowClient); + }) + .catch(unreached_rejection(t)); + }, "Return value should be instance of WindowClient"); + } else if (test === "test_client_navigate_failure") { + promise_test(function(t) { + return self.clients.get(clientId) + .then(client => assert_promise_rejects(client.navigate("http://example.com"))) + .catch(unreached_rejection(t)); + }, "Navigating to different origin should reject"); + + promise_test(function(t) { + this.add_cleanup(function() { port.postMessage(pass(test, "")); }); + return self.clients.get(clientId) + .then(client => promise_rejects(t, new TypeError(), client.navigate("about:blank"))) + .catch(unreached_rejection(t)); + }, "Navigating to about:blank should reject with TypeError") + } else if (test === "test_client_navigate_redirect") { + var host_info = get_host_info(); + var url = new URL(host_info['HTTPS_REMOTE_ORIGIN']).toString() + + new URL("client-navigated-frame.html", location).pathname.substring(1); + promise_test(function(t) { + this.add_cleanup(() => port.postMessage(pass(test, clientUrl))); + return self.clients.get(clientId) + .then(client => client.navigate("redirect.py?Redirect=" + url)) + .then(client => { + clientUrl = (client && client.url) || "" + assert_true(client === null); + }) + .catch(unreached_rejection(t)); + }, "Redirecting to another origin should resolve with null"); + } +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/client-navigated-frame.html b/testing/web-platform/tests/service-workers/service-worker/resources/client-navigated-frame.html new file mode 100644 index 000000000..307f7f9ac --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/client-navigated-frame.html @@ -0,0 +1,3 @@ + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/clients-get-frame.html b/testing/web-platform/tests/service-workers/service-worker/resources/clients-get-frame.html new file mode 100644 index 000000000..27143d4b9 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/clients-get-frame.html @@ -0,0 +1,12 @@ + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/clients-get-other-origin.html b/testing/web-platform/tests/service-workers/service-worker/resources/clients-get-other-origin.html new file mode 100644 index 000000000..cbd3dcc6f --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/clients-get-other-origin.html @@ -0,0 +1,64 @@ + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/clients-get-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/clients-get-worker.js new file mode 100644 index 000000000..9ac2c2264 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/clients-get-worker.js @@ -0,0 +1,53 @@ +self.onfetch = function(e) { + if (e.request.url.indexOf("clients-get-frame.html") >= 0) { + if (e.clientId === null) { + e.respondWith(fetch(e.request)); + } else { + e.respondWith(Response.error()); + } + return; + } + e.respondWith(new Response(e.clientId)); +}; + +self.onmessage = function(e) { + var port = e.data.port; + if (e.data.message == 'get_client_ids') { + var clientIds = e.data.clientIds; + var message = []; + + Promise.all( + clientIds.map(function(clientId) { + return self.clients.get(clientId); + }).concat(self.clients.get("invalid-id")) + ).then(function(clients) { + clients.forEach(function(client) { + if (client instanceof Client) { + message.push([client.visibilityState, + client.focused, + client.url, + client.frameType]); + } else { + message.push(client); + } + }); + port.postMessage(message); + }); + } else if (e.data.message == 'get_other_client_id') { + var clientId = e.data.clientId; + var message; + + self.clients.get(clientId) + .then(function(client) { + if (client instanceof Client) { + message = [client.visibilityState, + client.focused, + client.url, + client.frameType]; + } else { + message = client; + } + port.postMessage(message); + }); + } +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-client-types-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-client-types-iframe.html new file mode 100644 index 000000000..51b4dca03 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-client-types-iframe.html @@ -0,0 +1,8 @@ + +Empty doc + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-client-types-shared-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-client-types-shared-worker.js new file mode 100644 index 000000000..1ae72fb89 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-client-types-shared-worker.js @@ -0,0 +1,4 @@ +onconnect = function(e) { + var port = e.ports[0]; + port.postMessage('started'); +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-worker.js new file mode 100644 index 000000000..f0ae90d81 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/clients-matchall-worker.js @@ -0,0 +1,24 @@ +self.onmessage = function(e) { + var port = e.data.port; + var options = e.data.options; + + self.clients.matchAll(options).then(function(clients) { + var message = []; + clients.forEach(function(client) { + var frame_type = client.frameType; + if (client.url.indexOf('clients-matchall-include-uncontrolled.https.html') > -1 && + client.frameType == 'auxiliary') { + // The test tab might be opened using window.open() by the test framework. + // In that case, just pretend it's top-level! + frame_type = 'top-level'; + } + message.push([client.visibilityState, + client.focused, + client.url, + frame_type]); + }); + // Sort by url + message.sort(function(a, b) { return a[2] > b[2] ? 1 : -1; }); + port.postMessage(message); + }); +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/dummy-shared-worker-interceptor.js b/testing/web-platform/tests/service-workers/service-worker/resources/dummy-shared-worker-interceptor.js new file mode 100644 index 000000000..82b24459b --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/dummy-shared-worker-interceptor.js @@ -0,0 +1,7 @@ +var worker_text = 'onconnect = function(e) { e.ports[0].postMessage("worker loading intercepted by service worker"); };'; + +self.onfetch = function(event) { + if (event.request.url.indexOf('dummy-shared-worker.js') != -1) + event.respondWith(new Response(worker_text)); +}; + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/dummy-worker-interceptor.js b/testing/web-platform/tests/service-workers/service-worker/resources/dummy-worker-interceptor.js new file mode 100644 index 000000000..43244e1d9 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/dummy-worker-interceptor.js @@ -0,0 +1,21 @@ +importScripts('get-host-info.sub.js'); + +var worker_text = 'postMessage("worker loading intercepted by service worker"); '; + +self.onfetch = function(event) { + if (event.request.url.indexOf('synthesized') != -1) { + event.respondWith(new Response(worker_text)); + } else if (event.request.url.indexOf('same-origin') != -1) { + event.respondWith(fetch('dummy-worker-script.py')); + } else if (event.request.url.indexOf('cors') != -1) { + var path = (new URL('dummy-worker-script.py', self.location)).pathname; + var url = get_host_info()['HTTPS_REMOTE_ORIGIN'] + path; + var mode = "no-cors"; + if (event.request.url.indexOf('no-cors') == -1) { + url += '?ACAOrigin=*'; + mode = "cors"; + } + event.respondWith(fetch(url, { mode: mode })); + } +}; + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/dummy-worker-script.py b/testing/web-platform/tests/service-workers/service-worker/resources/dummy-worker-script.py new file mode 100644 index 000000000..6f40b5ed6 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/dummy-worker-script.py @@ -0,0 +1,9 @@ +def main(request, response): + headers = [] + + if "ACAOrigin" in request.GET: + for item in request.GET["ACAOrigin"].split(","): + headers.append(("Access-Control-Allow-Origin", item)) + + return headers, "postMessage('dummy-worker-script loaded');" + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/dummy.html b/testing/web-platform/tests/service-workers/service-worker/resources/dummy.html new file mode 100644 index 000000000..12a179980 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/dummy.html @@ -0,0 +1,2 @@ + +Hello world diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/dummy.txt b/testing/web-platform/tests/service-workers/service-worker/resources/dummy.txt new file mode 100644 index 000000000..802992c42 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/dummy.txt @@ -0,0 +1 @@ +Hello world diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/empty-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/empty-worker.js new file mode 100644 index 000000000..49ceb2648 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/empty-worker.js @@ -0,0 +1 @@ +// Do nothing. diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/empty.js b/testing/web-platform/tests/service-workers/service-worker/resources/empty.js new file mode 100644 index 000000000..e69de29bb diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/end-to-end-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/end-to-end-worker.js new file mode 100644 index 000000000..d45a50556 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/end-to-end-worker.js @@ -0,0 +1,7 @@ +onmessage = function(e) { + var message = e.data; + if (typeof message === 'object' && 'port' in message) { + var response = 'Ack for: ' + message.from; + message.port.postMessage(response); + } +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/events-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/events-worker.js new file mode 100644 index 000000000..80a218867 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/events-worker.js @@ -0,0 +1,12 @@ +var eventsSeen = []; + +function handler(event) { eventsSeen.push(event.type); } + +['activate', 'install'].forEach(function(type) { + self.addEventListener(type, handler); + }); + +onmessage = function(e) { + var message = e.data; + message.port.postMessage({events: eventsSeen}); +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/extendable-event-async-waituntil.js b/testing/web-platform/tests/service-workers/service-worker/resources/extendable-event-async-waituntil.js new file mode 100644 index 000000000..d77238d93 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/extendable-event-async-waituntil.js @@ -0,0 +1,20 @@ +var result = 'FAIL: did not throw.'; + +self.addEventListener('message', function(event) { + event.data.port.postMessage(result); + }); + +self.addEventListener('install', function(event) { + self.installEvent = event; + }); + +self.addEventListener('activate', function(event) { + try { + self.installEvent.waitUntil(new Promise(function(){})); + } catch (error) { + if (error.name == 'InvalidStateError') + result = 'PASS'; + else + result = 'FAIL: unexpected exception: ' + error; + } + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/extendable-event-waituntil.js b/testing/web-platform/tests/service-workers/service-worker/resources/extendable-event-waituntil.js new file mode 100644 index 000000000..48fdf1b99 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/extendable-event-waituntil.js @@ -0,0 +1,75 @@ +var pendingPorts = []; +var portResolves = []; + +onmessage = function(e) { + var message = e.data; + if ('port' in message) { + var resolve = self.portResolves.shift(); + if (resolve) + resolve(message.port); + else + self.pendingPorts.push(message.port); + } +}; + +function fulfillPromise() { + return new Promise(function(resolve) { + // Make sure the oninstall/onactivate callback returns first. + Promise.resolve().then(function() { + var port = self.pendingPorts.shift(); + if (port) + resolve(port); + else + self.portResolves.push(resolve); + }); + }).then(function(port) { + port.postMessage('SYNC'); + return new Promise(function(resolve) { + port.onmessage = function(e) { + if (e.data == 'ACK') + resolve(); + }; + }); + }); +} + +function rejectPromise() { + return new Promise(function(resolve, reject) { + // Make sure the oninstall/onactivate callback returns first. + Promise.resolve().then(reject); + }); +} + +function stripScopeName(url) { + return url.split('/').slice(-1)[0]; +} + +oninstall = function(e) { + switch (stripScopeName(self.location.href)) { + case 'install-fulfilled': + e.waitUntil(fulfillPromise()); + break; + case 'install-rejected': + e.waitUntil(rejectPromise()); + break; + case 'install-multiple-fulfilled': + e.waitUntil(fulfillPromise()); + e.waitUntil(fulfillPromise()); + break; + case 'install-reject-precedence': + e.waitUntil(fulfillPromise()); + e.waitUntil(rejectPromise()); + break; + } +}; + +onactivate = function(e) { + switch (stripScopeName(self.location.href)) { + case 'activate-fulfilled': + e.waitUntil(fulfillPromise()); + break; + case 'activate-rejected': + e.waitUntil(rejectPromise()); + break; + } +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fail-on-fetch-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fail-on-fetch-worker.js new file mode 100644 index 000000000..517f289fb --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fail-on-fetch-worker.js @@ -0,0 +1,5 @@ +importScripts('worker-testharness.js'); + +this.addEventListener('fetch', function(event) { + event.respondWith(new Response('ERROR')); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-access-control-login.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-access-control-login.html new file mode 100644 index 000000000..0ffab1af5 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-access-control-login.html @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-access-control.py b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-access-control.py new file mode 100644 index 000000000..862718ad0 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-access-control.py @@ -0,0 +1,69 @@ +import base64 +import json + +def main(request, response): + headers = [] + headers.append(('X-ServiceWorker-ServerHeader', 'SetInTheServer')) + + if "ACAOrigin" in request.GET: + for item in request.GET["ACAOrigin"].split(","): + headers.append(("Access-Control-Allow-Origin", item)) + + for suffix in ["Headers", "Methods", "Credentials"]: + query = "ACA%s" % suffix + header = "Access-Control-Allow-%s" % suffix + if query in request.GET: + headers.append((header, request.GET[query])) + + if "ACEHeaders" in request.GET: + headers.append(("Access-Control-Expose-Headers", request.GET[query])) + + if ("Auth" in request.GET and not request.auth.username) or "AuthFail" in request.GET: + status = 401 + headers.append(('WWW-Authenticate', 'Basic realm="Restricted"')) + body = 'Authentication canceled' + return status, headers, body + + if "PNGIMAGE" in request.GET: + headers.append(("Content-Type", "image/png")) + body = base64.decodestring("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1B" + "AACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAhSURBVDhPY3wro/KfgQLABKXJBqMG" + "jBoAAqMGDLwBDAwAEsoCTFWunmQAAAAASUVORK5CYII=") + return headers, body + + + username = request.auth.username if request.auth.username else "undefined" + password = request.auth.password if request.auth.username else "undefined" + cookie = request.cookies['cookie'].value if 'cookie' in request.cookies else "undefined" + + files = [] + for key, values in request.POST.iteritems(): + assert len(values) == 1 + value = values[0] + if not hasattr(value, "file"): + continue + data = value.file.read() + files.append({"key": key, + "name": value.file.name, + "type": value.type, + "error": 0, #TODO, + "size": len(data), + "content": data}) + + get_data = {key:request.GET[key] for key,value in request.GET.iteritems()} + post_data = {key:request.POST[key] for key,value in request.POST.iteritems() + if not hasattr(request.POST[key], "file")} + headers_data = {key:request.headers[key] for key,value in request.headers.iteritems()} + + data = {"jsonpResult": "success", + "method": request.method, + "headers": headers_data, + "body": request.body, + "files": files, + "GET": get_data, + "POST": post_data, + "username": username, + "password": password, + "cookie": cookie} + + return headers, "report( %s )" % json.dumps(data) diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html new file mode 100644 index 000000000..3822971e8 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html @@ -0,0 +1,294 @@ + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-cors-xhr-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-cors-xhr-iframe.html new file mode 100644 index 000000000..48f618397 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-cors-xhr-iframe.html @@ -0,0 +1,210 @@ + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-csp-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-csp-iframe.html new file mode 100644 index 000000000..cf7175bc8 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-csp-iframe.html @@ -0,0 +1,72 @@ + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-csp-iframe.html.sub.headers b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-csp-iframe.html.sub.headers new file mode 100644 index 000000000..300efe049 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-csp-iframe.html.sub.headers @@ -0,0 +1 @@ +Content-Security-Policy: img-src https://{{host}}:{{ports[https][0]}} diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-after-navigation-within-page-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-after-navigation-within-page-iframe.html new file mode 100644 index 000000000..bf8a6d5ce --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-after-navigation-within-page-iframe.html @@ -0,0 +1,22 @@ + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-async-respond-with-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-async-respond-with-worker.js new file mode 100644 index 000000000..7f66d20df --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-async-respond-with-worker.js @@ -0,0 +1,19 @@ +var result; + +self.addEventListener('message', function(event) { + event.data.port.postMessage(result); + }); + +self.addEventListener('fetch', function(event) { + setTimeout(function() { + try { + event.respondWith(new Response()); + result = 'FAIL: did not throw'; + } catch (error) { + if (error.name == 'InvalidStateError') + result = 'PASS'; + else + result = 'FAIL: Unexpected exception: ' + error; + } + }, 0); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-network-error-controllee-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-network-error-controllee-iframe.html new file mode 100644 index 000000000..a4c9307e7 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-network-error-controllee-iframe.html @@ -0,0 +1,59 @@ + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-network-error-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-network-error-worker.js new file mode 100644 index 000000000..52d4c8e86 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-network-error-worker.js @@ -0,0 +1,46 @@ +// Test that multiple fetch handlers do not confuse the implementation. +self.addEventListener('fetch', function(event) {}); + +self.addEventListener('fetch', function(event) { + var testcase = new URL(event.request.url).search; + switch (testcase) { + case '?reject': + event.respondWith(Promise.reject()); + break; + case '?prevent-default': + event.preventDefault(); + break; + case '?prevent-default-and-respond-with': + event.preventDefault(); + break; + case '?unused-body': + event.respondWith(new Response('body')); + break; + case '?used-body': + var res = new Response('body'); + res.text(); + event.respondWith(res); + break; + case '?unused-fetched-body': + event.respondWith(fetch('other.html').then(function(res){ + return res; + })); + break; + case '?used-fetched-body': + event.respondWith(fetch('other.html').then(function(res){ + res.text(); + return res; + })); + break; + } + }); + +self.addEventListener('fetch', function(event) {}); + +self.addEventListener('fetch', function(event) { + var testcase = new URL(event.request.url).search; + if (testcase == '?prevent-default-and-respond-with') + event.respondWith(new Response('responding!')); + }); + +self.addEventListener('fetch', function(event) {}); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-redirect-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-redirect-iframe.html new file mode 100644 index 000000000..7548d8af7 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-redirect-iframe.html @@ -0,0 +1,25 @@ + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-respond-with-stops-propagation-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-respond-with-stops-propagation-worker.js new file mode 100644 index 000000000..18da049d6 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-respond-with-stops-propagation-worker.js @@ -0,0 +1,15 @@ +var result = null; + +self.addEventListener('message', function(event) { + event.data.port.postMessage(result); + }); + +self.addEventListener('fetch', function(event) { + if (!result) + result = 'PASS'; + event.respondWith(new Response()); + }); + +self.addEventListener('fetch', function(event) { + result = 'FAIL: fetch event propagated'; + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-test-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-test-worker.js new file mode 100644 index 000000000..55ba4ab4d --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-event-test-worker.js @@ -0,0 +1,151 @@ +function handleString(event) { + event.respondWith(new Response('Test string')); +} + +function handleBlob(event) { + event.respondWith(new Response(new Blob(['Test blob']))); +} + +function handleReferrer(event) { + event.respondWith(new Response(new Blob( + ['Referrer: ' + event.request.referrer]))); +} + +function handleReferrerPolicy(event) { + event.respondWith(new Response(new Blob( + ['ReferrerPolicy: ' + event.request.referrerPolicy]))); +} + +function handleReferrerFull(event) { + event.respondWith(new Response(new Blob( + ['Referrer: ' + event.request.referrer + '\n' + + 'ReferrerPolicy: ' + event.request.referrerPolicy]))); +} + +function handleClientId(event) { + var body; + if (event.clientId !== null) { + body = 'Client ID Found: ' + event.clientId; + } else { + body = 'Client ID Not Found'; + } + event.respondWith(new Response(body)); +} + +function handleNullBody(event) { + event.respondWith(new Response()); +} + +function handleFetch(event) { + event.respondWith(fetch('other.html')); +} + +function handleFormPost(event) { + event.respondWith(new Promise(function(resolve) { + event.request.text() + .then(function(result) { + resolve(new Response(event.request.method + ':' + + event.request.headers.get('Content-Type') + ':' + + result)); + }); + })); +} + +function handleMultipleRespondWith(event) { + var logForMultipleRespondWith = ''; + for (var i = 0; i < 3; ++i) { + logForMultipleRespondWith += '(' + i + ')'; + try { + event.respondWith(new Promise(function(resolve) { + setTimeout(function() { + resolve(new Response(logForMultipleRespondWith)); + }, 0); + })); + } catch (e) { + logForMultipleRespondWith += '[' + e.name + ']'; + } + } +} + +var lastResponseForUsedCheck = undefined; + +function handleUsedCheck(event) { + if (!lastResponseForUsedCheck) { + event.respondWith(fetch('other.html').then(function(response) { + lastResponseForUsedCheck = response; + return response; + })); + } else { + event.respondWith(new Response( + 'bodyUsed: ' + lastResponseForUsedCheck.bodyUsed)); + } +} +function handleFragmentCheck(event) { + var body; + if (event.request.url.indexOf('#') === -1) { + body = 'Fragment Not Found'; + } else { + body = 'Fragment Found :' + + event.request.url.substring(event.request.url.indexOf('#')); + } + event.respondWith(new Response(body)); +} +function handleCache(event) { + event.respondWith(new Response(event.request.cache)); +} +function handleEventSource(event) { + if (event.request.mode === 'navigate') { + return; + } + var data = { + mode: event.request.mode, + cache: event.request.cache, + credentials: event.request.credentials + }; + var body = 'data:' + JSON.stringify(data) + '\n\n'; + event.respondWith(new Response(body, { + headers: { 'Content-Type': 'text/event-stream' } + } + )); +} + +function handleIntegrity(event) { + event.respondWith(new Response(event.request.integrity)); +} + +self.addEventListener('fetch', function(event) { + var url = event.request.url; + var handlers = [ + { pattern: '?string', fn: handleString }, + { pattern: '?blob', fn: handleBlob }, + { pattern: '?referrerFull', fn: handleReferrerFull }, + { pattern: '?referrerPolicy', fn: handleReferrerPolicy }, + { pattern: '?referrer', fn: handleReferrer }, + { pattern: '?clientId', fn: handleClientId }, + { pattern: '?ignore', fn: function() {} }, + { pattern: '?null', fn: handleNullBody }, + { pattern: '?fetch', fn: handleFetch }, + { pattern: '?form-post', fn: handleFormPost }, + { pattern: '?multiple-respond-with', fn: handleMultipleRespondWith }, + { pattern: '?used-check', fn: handleUsedCheck }, + { pattern: '?fragment-check', fn: handleFragmentCheck }, + { pattern: '?cache', fn: handleCache }, + { pattern: '?eventsource', fn: handleEventSource }, + { pattern: '?integrity', fn: handleIntegrity }, + ]; + + var handler = null; + for (var i = 0; i < handlers.length; ++i) { + if (url.indexOf(handlers[i].pattern) != -1) { + handler = handlers[i]; + break; + } + } + + if (handler) { + handler.fn(event); + } else { + event.respondWith(new Response(new Blob( + ['Service Worker got an unexpected request: ' + url]))); + } + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-header-visibility-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-header-visibility-iframe.html new file mode 100644 index 000000000..e0f32f754 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-header-visibility-iframe.html @@ -0,0 +1,66 @@ + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-mixed-content-iframe-inscope-to-inscope.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-mixed-content-iframe-inscope-to-inscope.html new file mode 100644 index 000000000..a7db229ce --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-mixed-content-iframe-inscope-to-inscope.html @@ -0,0 +1,71 @@ + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-mixed-content-iframe-inscope-to-outscope.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-mixed-content-iframe-inscope-to-outscope.html new file mode 100644 index 000000000..cec00cb25 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-mixed-content-iframe-inscope-to-outscope.html @@ -0,0 +1,80 @@ + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-mixed-content-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-mixed-content-iframe.html new file mode 100644 index 000000000..961fd2ab6 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-mixed-content-iframe.html @@ -0,0 +1,71 @@ + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-css-base-url-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-css-base-url-iframe.html new file mode 100644 index 000000000..0edf2e7f9 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-css-base-url-iframe.html @@ -0,0 +1 @@ + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-css-base-url-style.css b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-css-base-url-style.css new file mode 100644 index 000000000..7643f667a --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-css-base-url-style.css @@ -0,0 +1 @@ +body { background-image: url("./dummy.png");} diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-css-base-url-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-css-base-url-worker.js new file mode 100644 index 000000000..0d9244ec7 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-css-base-url-worker.js @@ -0,0 +1,27 @@ +importScripts('../resources/get-host-info.sub.js'); +importScripts('test-helpers.sub.js'); + +var port = undefined; + +self.onmessage = function(e) { + var message = e.data; + if ('port' in message) { + port = message.port; + port.postMessage({ready: true}); + } +}; + +self.addEventListener('fetch', function(event) { + var url = event.request.url; + if (url.indexOf('fetch-request-css-base-url-style.css') != -1) { + event.respondWith(fetch( + get_host_info()['HTTPS_REMOTE_ORIGIN'] + base_path() + + 'fetch-request-css-base-url-style.css', + {mode: 'no-cors'})); + } else if (url.indexOf('dummy.png') != -1) { + port.postMessage({ + url: event.request.url, + referrer: event.request.referrer + }); + } + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-fallback-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-fallback-iframe.html new file mode 100644 index 000000000..f00d24e37 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-fallback-iframe.html @@ -0,0 +1,15 @@ + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-fallback-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-fallback-worker.js new file mode 100644 index 000000000..3b028b24b --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-fallback-worker.js @@ -0,0 +1,13 @@ +var requests = []; + +self.addEventListener('message', function(event) { + event.data.port.postMessage({requests: requests}); + requests = []; + }); + +self.addEventListener('fetch', function(event) { + requests.push({ + url: event.request.url, + mode: event.request.mode + }); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-no-freshness-headers-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-no-freshness-headers-iframe.html new file mode 100644 index 000000000..68a1a8687 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-no-freshness-headers-iframe.html @@ -0,0 +1 @@ + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-no-freshness-headers-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-no-freshness-headers-worker.js new file mode 100644 index 000000000..2bd59d739 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-no-freshness-headers-worker.js @@ -0,0 +1,18 @@ +var requests = []; + +self.addEventListener('message', function(event) { + event.data.port.postMessage({requests: requests}); + }); + +self.addEventListener('fetch', function(event) { + var url = event.request.url; + var headers = []; + for (var header of event.request.headers) { + headers.push(header); + } + requests.push({ + url: url, + headers: headers + }); + event.respondWith(fetch(event.request)); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-redirect-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-redirect-iframe.html new file mode 100644 index 000000000..ffd76bfc4 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-redirect-iframe.html @@ -0,0 +1,35 @@ + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-resources-iframe.https.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-resources-iframe.https.html new file mode 100644 index 000000000..93b038dd6 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-resources-iframe.https.html @@ -0,0 +1,67 @@ + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-resources-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-resources-worker.js new file mode 100644 index 000000000..900b63c62 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-resources-worker.js @@ -0,0 +1,24 @@ +var requests = []; +var port = undefined; + +self.onmessage = function(e) { + var message = e.data; + if ('port' in message) { + port = message.port; + port.postMessage({ready: true}); + } +}; + +self.addEventListener('fetch', function(event) { + var url = event.request.url; + if (url.indexOf('dummy?test') == -1) { + return; + } + port.postMessage({ + url: url, + mode: event.request.mode, + credentials: event.request.credentials, + integrity: event.request.integrity + }); + event.respondWith(Promise.reject()); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html new file mode 100644 index 000000000..26c6b7344 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html @@ -0,0 +1,179 @@ + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-xhr-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-xhr-worker.js new file mode 100644 index 000000000..91b3abb14 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-request-xhr-worker.js @@ -0,0 +1,22 @@ +self.addEventListener('fetch', function(event) { + var url = event.request.url; + if (url.indexOf('dummy?test') == -1) { + return; + } + event.respondWith(new Promise(function(resolve) { + var headers = []; + for (var header of event.request.headers) { + headers.push(header); + } + event.request.text() + .then(function(result) { + resolve(new Response(JSON.stringify({ + method: event.request.method, + mode: event.request.mode, + credentials: event.request.credentials, + headers: headers, + body: result + }))); + }); + })); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-response-xhr-iframe.https.html b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-response-xhr-iframe.https.html new file mode 100644 index 000000000..3391381e3 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-response-xhr-iframe.https.html @@ -0,0 +1,35 @@ + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-response-xhr-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-response-xhr-worker.js new file mode 100644 index 000000000..465fbc91b --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-response-xhr-worker.js @@ -0,0 +1,12 @@ +self.addEventListener('fetch', function(event) { + var url = event.request.url; + if (url.indexOf('dummy?test') == -1) { + return; + } + event.respondWith(new Promise(function(resolve) { + var headers = new Headers; + headers.append('foo', 'foo'); + headers.append('foo', 'bar'); + resolve(new Response('hello world', {'headers': headers})); + })); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-rewrite-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-rewrite-worker.js new file mode 100644 index 000000000..9806f2b5b --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-rewrite-worker.js @@ -0,0 +1,149 @@ +function get_query_params(url) { + var search = (new URL(url)).search; + if (!search) { + return {}; + } + var ret = {}; + var params = search.substring(1).split('&'); + params.forEach(function(param) { + var element = param.split('='); + ret[decodeURIComponent(element[0])] = decodeURIComponent(element[1]); + }); + return ret; +} + +function get_request_init(base, params) { + var init = {}; + init['method'] = params['method'] || base['method']; + init['mode'] = params['mode'] || base['mode']; + if (init['mode'] == 'navigate') { + init['mode'] = 'same-origin'; + } + init['credentials'] = params['credentials'] || base['credentials']; + init['redirect'] = params['redirect-mode'] || base['redirect']; + return init; +} + +self.addEventListener('fetch', function(event) { + var params = get_query_params(event.request.url); + var init = get_request_init(event.request, params); + var url = params['url']; + if (params['ignore']) { + return; + } + if (params['throw']) { + throw new Error('boom'); + } + if (params['reject']) { + event.respondWith(new Promise(function(resolve, reject) { + reject(); + })); + return; + } + if (params['resolve-null']) { + event.respondWith(new Promise(function(resolve) { + resolve(null); + })); + return; + } + if (params['generate-png']) { + var binary = atob( + 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAA' + + 'RnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAhSURBVDhPY3wro/Kf' + + 'gQLABKXJBqMGjBoAAqMGDLwBDAwAEsoCTFWunmQAAAAASUVORK5CYII='); + var array = new Uint8Array(binary.length); + for(var i = 0; i < binary.length; i++) { + array[i] = binary.charCodeAt(i); + }; + event.respondWith(new Response(new Blob([array], {type: 'image/png'}))); + return; + } + if (params['check-ua-header']) { + var ua = event.request.headers.get('User-Agent'); + if (ua) { + // We have a user agent! + event.respondWith(new Response(new Blob([ua]))); + } else { + // We don't have a user-agent! + event.respondWith(new Response(new Blob(["NO_UA"]))); + } + return; + } + if (params['check-accept-header']) { + var accept = event.request.headers.get('Accept'); + if (accept) { + event.respondWith(new Response(accept)); + } else { + event.respondWith(new Response('NO_ACCEPT')); + } + return; + } + event.respondWith(new Promise(function(resolve, reject) { + var request = event.request; + if (url) { + request = new Request(url, init); + } + fetch(request).then(function(response) { + var expectedType = params['expected_type']; + if (expectedType && response.type !== expectedType) { + // Resolve a JSON object with a failure instead of rejecting + // in order to distinguish this from a NetworkError, which + // may be expected even if the type is correct. + resolve(new Response(JSON.stringify({ + result: 'failure', + detail: 'got ' + response.type + ' Response.type instead of ' + + expectedType + }))); + } + + var expectedRedirected = params['expected_redirected']; + if (typeof expectedRedirected !== 'undefined') { + var expected_redirected = (expectedRedirected === 'true'); + if(response.redirected !== expected_redirected) { + // This is simply determining how to pass an error to the outer + // test case(fetch-request-redirect.https.html). + var execptedResolves = params['expected_resolves']; + if (execptedResolves === 'true') { + // Reject a JSON object with a failure since promise is expected + // to be resolved. + reject(new Response(JSON.stringify({ + result: 'failure', + detail: 'got '+ response.redirected + + ' Response.redirected instead of ' + + expectedRedirected + }))); + } else { + // Resolve a JSON object with a failure since promise is + // expected to be rejected. + resolve(new Response(JSON.stringify({ + result: 'failure', + detail: 'got '+ response.redirected + + ' Response.redirected instead of ' + + expectedRedirected + }))); + } + } + } + + if (params['cache']) { + var cacheName = "cached-fetches-" + performance.now() + "-" + + event.request.url; + var cache; + var cachedResponse; + return self.caches.open(cacheName).then(function(opened) { + cache = opened; + return cache.put(request, response); + }).then(function() { + return cache.match(request); + }).then(function(cached) { + cachedResponse = cached; + return self.caches.delete(cacheName); + }).then(function() { + resolve(cachedResponse); + }); + } else { + resolve(response); + } + }, reject) + })); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-waits-for-activate-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-waits-for-activate-worker.js new file mode 100644 index 000000000..66f3e5936 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-waits-for-activate-worker.js @@ -0,0 +1,17 @@ +var activatePromiseResolve; + +addEventListener('activate', function(evt) { + evt.waitUntil(new Promise(function(resolve) { + activatePromiseResolve = resolve; + })); +}); + +addEventListener('message', function(evt) { + if (typeof activatePromiseResolve === 'function') { + activatePromiseResolve(); + } +}); + +addEventListener('fetch', function(evt) { + evt.respondWith(new Response('Hello world')); +}); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/frame-for-getregistrations.html b/testing/web-platform/tests/service-workers/service-worker/resources/frame-for-getregistrations.html new file mode 100644 index 000000000..7fc35f189 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/frame-for-getregistrations.html @@ -0,0 +1,19 @@ + +Service Worker: frame for getRegistrations() + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/get-host-info.sub.js b/testing/web-platform/tests/service-workers/service-worker/resources/get-host-info.sub.js new file mode 100644 index 000000000..b64334df6 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/get-host-info.sub.js @@ -0,0 +1,26 @@ +function get_host_info() { + var ORIGINAL_HOST = '127.0.0.1'; + var REMOTE_HOST = 'localhost'; + var UNAUTHENTICATED_HOST = 'example.test'; + var HTTP_PORT = 8000; + var HTTPS_PORT = 8443; + try { + // In W3C test, we can get the hostname and port number in config.json + // using wptserve's built-in pipe. + // http://wptserve.readthedocs.org/en/latest/pipes.html#built-in-pipes + HTTP_PORT = eval('{{ports[http][0]}}'); + HTTPS_PORT = eval('{{ports[https][0]}}'); + ORIGINAL_HOST = eval('\'{{host}}\''); + REMOTE_HOST = 'www1.' + ORIGINAL_HOST; + } catch (e) { + } + return { + HTTP_ORIGIN: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT, + HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT, + HTTPS_ORIGIN_WITH_CREDS: 'https://foo:bar@' + ORIGINAL_HOST + ':' + HTTPS_PORT, + HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT, + HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT, + HTTPS_REMOTE_ORIGIN_WITH_CREDS: 'https://foo:bar@' + REMOTE_HOST + ':' + HTTPS_PORT, + UNAUTHENTICATED_ORIGIN: 'http://' + UNAUTHENTICATED_HOST + ':' + HTTP_PORT + }; +} diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/indexeddb-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/indexeddb-worker.js new file mode 100644 index 000000000..ef89550b3 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/indexeddb-worker.js @@ -0,0 +1,26 @@ +var port; +self.addEventListener('message', function(e) { + var message = e.data; + if ('port' in message) + doIndexedDBTest(message.port); + }); + +function doIndexedDBTest(port) { + var delete_request = indexedDB.deleteDatabase('db'); + delete_request.onsuccess = function() { + var open_request = indexedDB.open('db'); + open_request.onupgradeneeded = function() { + var db = open_request.result; + db.createObjectStore('store'); + }; + open_request.onsuccess = function() { + var db = open_request.result; + var tx = db.transaction('store', 'readwrite'); + var store = tx.objectStore('store'); + store.put('value', 'key'); + tx.oncomplete = function() { + port.postMessage('done'); + }; + }; + }; +} diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/install-event-type-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/install-event-type-worker.js new file mode 100644 index 000000000..d729afa09 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/install-event-type-worker.js @@ -0,0 +1,8 @@ +importScripts('worker-testharness.js'); + +self.oninstall = function(event) { + assert_true(event instanceof ExtendableEvent); + assert_equals(event.type, 'install'); + assert_false(event.cancelable); + assert_false(event.bubbles); +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/interfaces-worker.sub.js b/testing/web-platform/tests/service-workers/service-worker/resources/interfaces-worker.sub.js new file mode 100644 index 000000000..e5ed36fce --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/interfaces-worker.sub.js @@ -0,0 +1,107 @@ +importScripts('interfaces.js'); +importScripts('worker-testharness.js'); +importScripts('../resources/testharness-helpers.js'); + +var EVENT_HANDLER = 'object'; + +test(function() { + verify_interface('ServiceWorkerGlobalScope', + self, + { + clients: 'object', + registration: 'object', + skipWaiting: 'function', + + onactivate: EVENT_HANDLER, + onfetch: EVENT_HANDLER, + oninstall: EVENT_HANDLER, + onmessage: EVENT_HANDLER + }); + }, 'ServiceWorkerGlobalScope'); + +test(function() { + verify_interface('Clients', + self.clients, + { + claim: 'function', + matchAll: 'function' + }); + }, 'Clients'); + +test(function() { + verify_interface('Client'); + // FIXME: Get an instance and test it, or ensure property exists on + // prototype. + }, 'Client'); + +test(function() { + verify_interface('WindowClient'); + // FIXME: Get an instance and test it, or ensure property exists on + // prototype. + }, 'WindowClient'); + +test(function() { + verify_interface('CacheStorage', + self.caches, + { + match: 'function', + has: 'function', + open: 'function', + delete: 'function', + keys: 'function' + }); + }, 'CacheStorage'); + +promise_test(function(t) { + return create_temporary_cache(t) + .then(function(cache) { + verify_interface('Cache', + cache, + { + match: 'function', + matchAll: 'function', + add: 'function', + addAll: 'function', + put: 'function', + delete: 'function', + keys: 'function' + }); + }); + }, 'Cache'); + +test(function() { + var req = new Request('http://{{host}}/', + {method: 'POST', + headers: [['Content-Type', 'Text/Html']]}); + assert_equals( + new ExtendableEvent('ExtendableEvent').type, + 'ExtendableEvent', 'Type of ExtendableEvent should be ExtendableEvent'); + assert_equals( + new FetchEvent('FetchEvent', {request: req}).type, + 'FetchEvent', 'Type of FetchEvent should be FetchEvent'); + assert_equals( + new FetchEvent('FetchEvent', {request: req}).cancelable, + false, 'Default FetchEvent.cancelable should be false'); + assert_equals( + new FetchEvent('FetchEvent', {request: req}).bubbles, + false, 'Default FetchEvent.bubbles should be false'); + assert_equals( + new FetchEvent('FetchEvent', {request: req}).clientId, + null, 'Default FetchEvent.clientId should be null'); + assert_equals( + new FetchEvent('FetchEvent', {request: req}).isReload, + false, 'Default FetchEvent.isReload should be false'); + assert_equals( + new FetchEvent('FetchEvent', {request: req, cancelable: false}).cancelable, + false, 'FetchEvent.cancelable should be false'); + assert_equals( + new FetchEvent('FetchEvent', {request: req, clientId : 'test-client-id'}).clientId, 'test-client-id', + 'FetchEvent.clientId with option {clientId : "test-client-id"} should be "test-client-id"'); + assert_equals( + new FetchEvent('FetchEvent', {request: req, isReload : true}).isReload, true, + 'FetchEvent.isReload with option {isReload : true} should be true'); + assert_equals( + new FetchEvent('FetchEvent', {request : req, isReload : true}).request.url, + 'http://{{host}}/', + 'FetchEvent.request.url should return the value it was initialized to'); + }, 'Event constructors'); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/interfaces.js b/testing/web-platform/tests/service-workers/service-worker/resources/interfaces.js new file mode 100644 index 000000000..eb00df65f --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/interfaces.js @@ -0,0 +1,15 @@ +function verify_interface(name, instance, attributes) { + assert_true(name in self, + name + ' should be an defined type'); + if (instance) { + assert_true(instance instanceof self[name], + instance + ' should be an instance of ' + name); + Object.keys(attributes || {}).forEach(function(attribute) { + var type = attributes[attribute]; + assert_true(attribute in instance, + attribute + ' should be an attribute of ' + name); + assert_equals(typeof instance[attribute], type, + attribute + ' should be of type ' + type); + }); + } +} diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/invalid-blobtype-iframe.https.html b/testing/web-platform/tests/service-workers/service-worker/resources/invalid-blobtype-iframe.https.html new file mode 100644 index 000000000..f111bd924 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/invalid-blobtype-iframe.https.html @@ -0,0 +1,29 @@ + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/invalid-blobtype-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/invalid-blobtype-worker.js new file mode 100644 index 000000000..93f496ef4 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/invalid-blobtype-worker.js @@ -0,0 +1,10 @@ +self.addEventListener('fetch', function(event) { + var url = event.request.url; + if (url.indexOf('dummy?test') == -1) { + return; + } + event.respondWith(new Promise(function(resolve) { + // null byte in blob type + resolve(new Response(new Blob([],{type: 'a\0b'}))); + })); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/invalid-chunked-encoding-with-flush.py b/testing/web-platform/tests/service-workers/service-worker/resources/invalid-chunked-encoding-with-flush.py new file mode 100644 index 000000000..c91250a9d --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/invalid-chunked-encoding-with-flush.py @@ -0,0 +1,11 @@ +import time +def main(request, response): + response.headers.set("Content-Type", "application/javascript") + response.headers.set("Transfer-encoding", "chunked") + response.write_status_headers() + + time.sleep(1) + response.explicit_flush = True + + response.writer.write("XX\r\n\r\n") + response.writer.flush() diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/invalid-chunked-encoding.py b/testing/web-platform/tests/service-workers/service-worker/resources/invalid-chunked-encoding.py new file mode 100644 index 000000000..ae2c1f21b --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/invalid-chunked-encoding.py @@ -0,0 +1,2 @@ +def main(request, response): + return [("Content-Type", "application/javascript"), ("Transfer-encoding", "chunked")], "XX\r\n\r\n" diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/invalid-header-iframe.https.html b/testing/web-platform/tests/service-workers/service-worker/resources/invalid-header-iframe.https.html new file mode 100644 index 000000000..19f302c35 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/invalid-header-iframe.https.html @@ -0,0 +1,26 @@ + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/invalid-header-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/invalid-header-worker.js new file mode 100644 index 000000000..31e7f29d0 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/invalid-header-worker.js @@ -0,0 +1,12 @@ +self.addEventListener('fetch', function(event) { + var url = event.request.url; + if (url.indexOf('dummy?test') == -1) { + return; + } + event.respondWith(new Promise(function(resolve) { + var headers = new Headers; + headers.append('foo', 'foo'); + headers.append('foo', 'b\0r'); // header value with a null byte + resolve(new Response('hello world', {'headers': headers})); + })); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/load_worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/load_worker.js new file mode 100644 index 000000000..2c80f25a3 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/load_worker.js @@ -0,0 +1,29 @@ +self.onmessage = function (evt) { + if (evt.data == "xhr") { + var xhr = new XMLHttpRequest(); + xhr.open("GET", "synthesized-response.txt", true); + xhr.responseType = "text"; + xhr.send(); + xhr.onload = function (evt) { + postMessage(xhr.responseText); + }; + xhr.onerror = function() { + postMessage("XHR failed!"); + }; + } else if (evt.data == "fetch") { + fetch("synthesized-response.txt") + .then(function(response) { + return response.text(); + }) + .then(function(data) { + postMessage(data); + }) + .catch(function(error) { + postMessage("Fetch failed!"); + }); + } else if (evt.data == "importScripts") { + importScripts("synthesized-response.js"); + } else { + throw "Unexpected message! " + evt.data; + } +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/loaded.html b/testing/web-platform/tests/service-workers/service-worker/resources/loaded.html new file mode 100644 index 000000000..0cabce69f --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/loaded.html @@ -0,0 +1,9 @@ + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/malformed-worker.py b/testing/web-platform/tests/service-workers/service-worker/resources/malformed-worker.py new file mode 100644 index 000000000..501521ff3 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/malformed-worker.py @@ -0,0 +1,10 @@ +def main(request, response): + headers = [("Content-Type", "application/javascript")] + + body = {'parse-error': 'var foo = function() {;', + 'undefined-error': 'foo.bar = 42;', + 'uncaught-exception': 'throw new DOMException("AbortError");', + 'caught-exception': 'try { throw new Error; } catch(e) {}', + 'import-malformed-script': 'importScripts("malformed-worker.py?parse-error");', + 'import-no-such-script': 'importScripts("no-such-script.js");'}[request.url_parts.query] + return headers, body diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/mime-type-worker.py b/testing/web-platform/tests/service-workers/service-worker/resources/mime-type-worker.py new file mode 100644 index 000000000..a16684de5 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/mime-type-worker.py @@ -0,0 +1,4 @@ +def main(request, response): + if 'mime' in request.GET: + return [('Content-Type', request.GET['mime'])], "" + return [], "" diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/mint-new-worker.py b/testing/web-platform/tests/service-workers/service-worker/resources/mint-new-worker.py new file mode 100644 index 000000000..cbe70304d --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/mint-new-worker.py @@ -0,0 +1,25 @@ +import time + +body = ''' +onactivate = (e) => e.waitUntil(clients.claim()); +var resolve_wait_until; +var wait_until = new Promise(resolve => { + resolve_wait_until = resolve; + }); +onmessage = (e) => { + if (e.data == 'wait') + e.waitUntil(wait_until); + if (e.data == 'go') + resolve_wait_until(); + };''' + +def main(request, response): + headers = [('Cache-Control', 'no-cache, must-revalidate'), + ('Pragma', 'no-cache'), + ('Content-Type', 'application/javascript')] + + skipWaiting = '' + if 'skip-waiting' in request.GET: + skipWaiting = 'skipWaiting();' + + return headers, '/* %s %s */ %s %s' % (time.time(), time.clock(), skipWaiting, body) diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/navigate-window-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/navigate-window-worker.js new file mode 100644 index 000000000..f9617439f --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/navigate-window-worker.js @@ -0,0 +1,21 @@ +addEventListener('message', function(evt) { + if (evt.data.type === 'GET_CLIENTS') { + clients.matchAll(evt.data.opts).then(function(clientList) { + var resultList = clientList.map(function(c) { + return { url: c.url, frameType: c.frameType, id: c.id }; + }); + evt.source.postMessage({ type: 'success', detail: resultList }); + }).catch(function(err) { + evt.source.postMessage({ + type: 'failure', + detail: 'matchAll() rejected with "' + err + '"' + }); + }); + return; + } + + evt.source.postMessage({ + type: 'failure', + detail: 'Unexpected message type "' + evt.data.type + '"' + }); +}); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-other-origin.html b/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-other-origin.html new file mode 100644 index 000000000..c1441ba68 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-other-origin.html @@ -0,0 +1,66 @@ + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-out-scope.py b/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-out-scope.py new file mode 100644 index 000000000..4b40762d8 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-out-scope.py @@ -0,0 +1,15 @@ +def main(request, response): + if "url" in request.GET: + headers = [("Location", request.GET["url"])] + return 302, headers, '' + + return [], ''' + + +''' diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-scope1.py b/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-scope1.py new file mode 100644 index 000000000..4b40762d8 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-scope1.py @@ -0,0 +1,15 @@ +def main(request, response): + if "url" in request.GET: + headers = [("Location", request.GET["url"])] + return 302, headers, '' + + return [], ''' + + +''' diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-scope2.py b/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-scope2.py new file mode 100644 index 000000000..4b40762d8 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-scope2.py @@ -0,0 +1,15 @@ +def main(request, response): + if "url" in request.GET: + headers = [("Location", request.GET["url"])] + return 302, headers, '' + + return [], ''' + + +''' diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-worker.js new file mode 100644 index 000000000..cb15b3ff1 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/navigation-redirect-worker.js @@ -0,0 +1,75 @@ +// We store an empty response for each fetch event request we see +// in this Cache object so we can get the list of urls in the +// message event. +var cacheName = 'urls-' + self.registration.scope; + +var waitUntilPromiseList = []; + +self.addEventListener('message', function(event) { + var urls; + event.waitUntil(Promise.all(waitUntilPromiseList).then(function() { + waitUntilPromiseList = []; + return caches.open(cacheName); + }).then(function(cache) { + return cache.keys(); + }).then(function(requestList) { + urls = requestList.map(function(request) { return request.url; }); + return caches.delete(cacheName); + }).then(function() { + event.data.port.postMessage({urls: urls}); + })); + }); + +function get_query_params(url) { + var search = (new URL(url)).search; + if (!search) { + return {}; + } + var ret = {}; + var params = search.substring(1).split('&'); + params.forEach(function(param) { + var element = param.split('='); + ret[decodeURIComponent(element[0])] = decodeURIComponent(element[1]); + }); + return ret; +} + +self.addEventListener('fetch', function(event) { + var waitUntilPromise = caches.open(cacheName).then(function(cache) { + return cache.put(event.request, new Response()); + }); + event.waitUntil(waitUntilPromise); + + var params = get_query_params(event.request.url); + if (!params['sw']) { + // To avoid races, add the waitUntil() promise to our global list. + // If we get a message event before we finish here, it will wait + // these promises to complete before proceeding to read from the + // cache. + waitUntilPromiseList.push(waitUntilPromise); + return; + } + + event.respondWith(waitUntilPromise.then(function() { + if (params['sw'] == 'gen') { + return Response.redirect(params['url']); + } else if (params['sw'] == 'fetch') { + return fetch(event.request); + } else if (params['sw'] == 'opaque') { + return fetch(new Request(event.request.url, {redirect: 'manual'})); + } else if (params['sw'] == 'opaqueThroughCache') { + var url = event.request.url; + var cache; + return caches.delete(url) + .then(function() { return self.caches.open(url); }) + .then(function(c) { + cache = c; + return fetch(new Request(url, {redirect: 'manual'})); + }) + .then(function(res) { return cache.put(event.request, res); }) + .then(function() { return cache.match(url); }); + } + + // unexpected... trigger an interception failure + })); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-from-nested-event-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-from-nested-event-worker.js new file mode 100644 index 000000000..7c97014fd --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-from-nested-event-worker.js @@ -0,0 +1,13 @@ +var max_nesting_level = 8; + +self.addEventListener('message', function(event) { + var level = event.data; + if (level < max_nesting_level) + dispatchEvent(new MessageEvent('message', { data: level + 1 })); + throw Error('error at level ' + level); + }); + +self.addEventListener('activate', function(event) { + dispatchEvent(new MessageEvent('message', { data: 1 })); + }); + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-then-cancel-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-then-cancel-worker.js new file mode 100644 index 000000000..0bd9d318b --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-then-cancel-worker.js @@ -0,0 +1,3 @@ +self.onerror = function(event) { return true; }; + +self.addEventListener('activate', function(event) { throw new Error(); }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-then-prevent-default-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-then-prevent-default-worker.js new file mode 100644 index 000000000..d56c95113 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-then-prevent-default-worker.js @@ -0,0 +1,7 @@ +// Ensure we can handle multiple error handlers. One error handler +// calling preventDefault should cause the event to be treated as +// handled. +self.addEventListener('error', function(event) {}); +self.addEventListener('error', function(event) { event.preventDefault(); }); +self.addEventListener('error', function(event) {}); +self.addEventListener('activate', function(event) { throw new Error(); }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-with-empty-onerror-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-with-empty-onerror-worker.js new file mode 100644 index 000000000..eb12ae862 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-with-empty-onerror-worker.js @@ -0,0 +1,2 @@ +self.addEventListener('error', function(event) {}); +self.addEventListener('activate', function(event) { throw new Error(); }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-worker.js new file mode 100644 index 000000000..1e88ac5c4 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/onactivate-throw-error-worker.js @@ -0,0 +1,7 @@ +// Ensure we can handle multiple activate handlers. One handler throwing an +// error should cause the event dispatch to be treated as having unhandled +// errors. +self.addEventListener('activate', function(event) {}); +self.addEventListener('activate', function(event) {}); +self.addEventListener('activate', function(event) { throw new Error(); }); +self.addEventListener('activate', function(event) {}); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-from-nested-event-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-from-nested-event-worker.js new file mode 100644 index 000000000..6729ab61a --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-from-nested-event-worker.js @@ -0,0 +1,12 @@ +var max_nesting_level = 8; + +self.addEventListener('message', function(event) { + var level = event.data; + if (level < max_nesting_level) + dispatchEvent(new MessageEvent('message', { data: level + 1 })); + throw Error('error at level ' + level); + }); + +self.addEventListener('install', function(event) { + dispatchEvent(new MessageEvent('message', { data: 1 })); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-then-cancel-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-then-cancel-worker.js new file mode 100644 index 000000000..c2c499ab1 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-then-cancel-worker.js @@ -0,0 +1,3 @@ +self.onerror = function(event) { return true; }; + +self.addEventListener('install', function(event) { throw new Error(); }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-then-prevent-default-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-then-prevent-default-worker.js new file mode 100644 index 000000000..7667c2781 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-then-prevent-default-worker.js @@ -0,0 +1,7 @@ +// Ensure we can handle multiple error handlers. One error handler +// calling preventDefault should cause the event to be treated as +// handled. +self.addEventListener('error', function(event) {}); +self.addEventListener('error', function(event) { event.preventDefault(); }); +self.addEventListener('error', function(event) {}); +self.addEventListener('install', function(event) { throw new Error(); }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-with-empty-onerror-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-with-empty-onerror-worker.js new file mode 100644 index 000000000..8f56d1bf1 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-with-empty-onerror-worker.js @@ -0,0 +1,2 @@ +self.addEventListener('error', function(event) {}); +self.addEventListener('install', function(event) { throw new Error(); }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-worker.js new file mode 100644 index 000000000..cc2f6d7e5 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/oninstall-throw-error-worker.js @@ -0,0 +1,7 @@ +// Ensure we can handle multiple install handlers. One handler throwing an +// error should cause the event dispatch to be treated as having unhandled +// errors. +self.addEventListener('install', function(event) {}); +self.addEventListener('install', function(event) {}); +self.addEventListener('install', function(event) { throw new Error(); }); +self.addEventListener('install', function(event) {}); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/other.html b/testing/web-platform/tests/service-workers/service-worker/resources/other.html new file mode 100644 index 000000000..b9f350438 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/other.html @@ -0,0 +1,3 @@ + +Other +Here's an other html file. diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/override_assert_object_equals.js b/testing/web-platform/tests/service-workers/service-worker/resources/override_assert_object_equals.js new file mode 100644 index 000000000..835046d47 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/override_assert_object_equals.js @@ -0,0 +1,58 @@ +// .body attribute of Request and Response object are experimental feture. It is +// enabled when --enable-experimental-web-platform-features flag is set. +// Touching this attribute can change the behavior of the objects. To avoid +// touching it while comparing the objects in LayoutTest, we overwrite +// assert_object_equals method. + +(function() { + var original_assert_object_equals = self.assert_object_equals; + function _brand(object) { + return Object.prototype.toString.call(object).match(/^\[object (.*)\]$/)[1]; + } + var assert_request_equals = function(actual, expected, prefix) { + if (typeof actual !== 'object') { + assert_equals(actual, expected, prefix); + return; + } + assert_true(actual instanceof Request, prefix); + assert_true(expected instanceof Request, prefix); + assert_equals(actual.bodyUsed, expected.bodyUsed, prefix + '.bodyUsed'); + assert_equals(actual.method, expected.method, prefix + '.method'); + assert_equals(actual.url, expected.url, prefix + '.url'); + original_assert_object_equals(actual.headers, expected.headers, + prefix + '.headers'); + assert_equals(actual.context, expected.context, prefix + '.context'); + assert_equals(actual.referrer, expected.referrer, prefix + '.referrer'); + assert_equals(actual.mode, expected.mode, prefix + '.mode'); + assert_equals(actual.credentials, expected.credentials, + prefix + '.credentials'); + assert_equals(actual.cache, expected.cache, prefix + '.cache'); + }; + var assert_response_equals = function(actual, expected, prefix) { + if (typeof actual !== 'object') { + assert_equals(actual, expected, prefix); + return; + } + assert_true(actual instanceof Response, prefix); + assert_true(expected instanceof Response, prefix); + assert_equals(actual.bodyUsed, expected.bodyUsed, prefix + '.bodyUsed'); + assert_equals(actual.type, expected.type, prefix + '.type'); + assert_equals(actual.url, expected.url, prefix + '.url'); + assert_equals(actual.status, expected.status, prefix + '.status'); + assert_equals(actual.statusText, expected.statusText, + prefix + '.statusText'); + original_assert_object_equals(actual.headers, expected.headers, + prefix + '.headers'); + }; + var assert_object_equals = function(actual, expected, description) { + var prefix = (description ? description + ': ' : '') + _brand(expected); + if (expected instanceof Request) { + assert_request_equals(actual, expected, prefix); + } else if (expected instanceof Response) { + assert_response_equals(actual, expected, prefix); + } else { + original_assert_object_equals(actual, expected, description); + } + }; + self.assert_object_equals = assert_object_equals; +})(); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/performance-timeline-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/performance-timeline-worker.js new file mode 100644 index 000000000..6f7df75e9 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/performance-timeline-worker.js @@ -0,0 +1,58 @@ +importScripts('/resources/testharness.js'); + +promise_test(function(test) { + var durationMsec = 100; + // There are limits to our accuracy here. Timers may fire up to a + // millisecond early due to platform-dependent rounding. In addition + // the performance API introduces some rounding as well to prevent + // timing attacks. + var accuracy = 1.5; + return new Promise(function(resolve) { + performance.mark('startMark'); + setTimeout(resolve, durationMsec); + }).then(function() { + performance.mark('endMark'); + performance.measure('measure', 'startMark', 'endMark'); + var startMark = performance.getEntriesByName('startMark')[0]; + var endMark = performance.getEntriesByName('endMark')[0]; + var measure = performance.getEntriesByType('measure')[0]; + assert_equals(measure.startTime, startMark.startTime); + assert_approx_equals(endMark.startTime - startMark.startTime, + measure.duration, 0.001); + assert_greater_than(measure.duration, durationMsec - accuracy); + assert_equals(performance.getEntriesByType('mark').length, 2); + assert_equals(performance.getEntriesByType('measure').length, 1); + performance.clearMarks('startMark'); + performance.clearMeasures('measure'); + assert_equals(performance.getEntriesByType('mark').length, 1); + assert_equals(performance.getEntriesByType('measure').length, 0); + }); + }, 'User Timing'); + +promise_test(function(test) { + return fetch('dummy.txt') + .then(function(resp) { + return resp.text(); + }) + .then(function(text) { + var expectedResources = ['testharness.js', 'dummy.txt']; + assert_equals(performance.getEntriesByType('resource').length, expectedResources.length); + for (var i = 0; i < expectedResources.length; i++) { + var entry = performance.getEntriesByType('resource')[i]; + assert_true(entry.name.endsWith(expectedResources[i])); + assert_equals(entry.workerStart, 0); + assert_greater_than(entry.startTime, 0); + assert_greater_than(entry.responseEnd, entry.startTime); + } + return new Promise(function(resolve) { + performance.onresourcetimingbufferfull = resolve; + performance.setResourceTimingBufferSize(expectedResources.length); + }); + }) + .then(function() { + performance.clearResourceTimings(); + assert_equals(performance.getEntriesByType('resource').length, 0); + }) + }, 'Resource Timing'); + +done(); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/postmessage-msgport-to-client-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/postmessage-msgport-to-client-worker.js new file mode 100644 index 000000000..3475321f4 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/postmessage-msgport-to-client-worker.js @@ -0,0 +1,20 @@ +self.onmessage = function(e) { + self.clients.matchAll().then(function(clients) { + clients.forEach(function(client) { + var messageChannel = new MessageChannel(); + messageChannel.port1.onmessage = + onMessageViaMessagePort.bind(null, client); + client.postMessage({port: messageChannel.port2}, + [messageChannel.port2]); + }); + }); +}; + +function onMessageViaMessagePort(client, e) { + var message = e.data; + if ('value' in message) { + client.postMessage({ack: 'Acking value: ' + message.value}); + } else if ('done' in message) { + client.postMessage({done: true}); + } +} diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/postmessage-to-client-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/postmessage-to-client-worker.js new file mode 100644 index 000000000..290a4a9b3 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/postmessage-to-client-worker.js @@ -0,0 +1,10 @@ +self.onmessage = function(e) { + self.clients.matchAll().then(function(clients) { + clients.forEach(function(client) { + client.postMessage('Sending message via clients'); + if (!Array.isArray(clients)) + client.postMessage('clients is not an array'); + client.postMessage('quit'); + }); + }); +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/postmessage-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/postmessage-worker.js new file mode 100644 index 000000000..858cf0426 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/postmessage-worker.js @@ -0,0 +1,19 @@ +var port; + +// Exercise the 'onmessage' handler: +self.onmessage = function(e) { + var message = e.data; + if ('port' in message) { + port = message.port; + } +}; + +// And an event listener: +self.addEventListener('message', function(e) { + var message = e.data; + if ('value' in message) { + port.postMessage('Acking value: ' + message.value); + } else if ('done' in message) { + port.postMessage('quit'); + } + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/redirect.py b/testing/web-platform/tests/service-workers/service-worker/resources/redirect.py new file mode 100644 index 000000000..20521b00c --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/redirect.py @@ -0,0 +1,25 @@ +def main(request, response): + if 'Status' in request.GET: + status = int(request.GET["Status"]) + else: + status = 302 + + headers = [] + + url = request.GET['Redirect'] + headers.append(("Location", url)) + + if "ACAOrigin" in request.GET: + for item in request.GET["ACAOrigin"].split(","): + headers.append(("Access-Control-Allow-Origin", item)) + + for suffix in ["Headers", "Methods", "Credentials"]: + query = "ACA%s" % suffix + header = "Access-Control-Allow-%s" % suffix + if query in request.GET: + headers.append((header, request.GET[query])) + + if "ACEHeaders" in request.GET: + headers.append(("Access-Control-Expose-Headers", request.GET["ACEHeaders"])) + + return status, headers, "" diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/referer-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/referer-iframe.html new file mode 100644 index 000000000..491262e9d --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/referer-iframe.html @@ -0,0 +1,39 @@ + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/register-closed-window-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/register-closed-window-iframe.html new file mode 100644 index 000000000..ed743ea05 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/register-closed-window-iframe.html @@ -0,0 +1,16 @@ + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/registration-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/registration-worker.js new file mode 100644 index 000000000..44d1d2774 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/registration-worker.js @@ -0,0 +1 @@ +// empty for now diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/reject-install-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/reject-install-worker.js new file mode 100644 index 000000000..41f07fd5d --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/reject-install-worker.js @@ -0,0 +1,3 @@ +self.oninstall = function(event) { + event.waitUntil(Promise.reject()); +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/request-end-to-end-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/request-end-to-end-worker.js new file mode 100644 index 000000000..323c7f243 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/request-end-to-end-worker.js @@ -0,0 +1,32 @@ +var port = undefined; + +onmessage = function(e) { + var message = e.data; + if (typeof message === 'object' && 'port' in message) { + port = message.port; + } +}; + +onfetch = function(e) { + var headers = {}; + var errorNameWhileAppendingHeader; + for (var header of e.request.headers) { + var key = header[0], value = header[1]; + headers[key] = value; + } + var errorNameWhileAddingHeader = ''; + try { + e.request.headers.append('Test-Header', 'TestValue'); + } catch (e) { + errorNameWhileAppendingHeader = e.name; + } + port.postMessage({ + url: e.request.url, + mode: e.request.mode, + method: e.request.method, + referrer: e.request.referrer, + headers: headers, + headerSize: e.request.headers.size, + errorNameWhileAppendingHeader: errorNameWhileAppendingHeader + }); +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/request-headers.py b/testing/web-platform/tests/service-workers/service-worker/resources/request-headers.py new file mode 100644 index 000000000..29897f4ec --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/request-headers.py @@ -0,0 +1,6 @@ +import json + +def main(request, response): + data = {key:request.headers[key] for key,value in request.headers.iteritems()} + + return [("Content-Type", "application/json")], json.dumps(data) diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-iframe.html b/testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-iframe.html new file mode 100644 index 000000000..2af679369 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-iframe.html @@ -0,0 +1,4 @@ + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-worker.js new file mode 100644 index 000000000..481a6536a --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-worker.js @@ -0,0 +1,5 @@ +self.addEventListener('fetch', function(event) { + if (event.request.url.indexOf('dummy.js') != -1) { + event.respondWith(new Response()); + } + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/service-worker-csp-worker.py b/testing/web-platform/tests/service-workers/service-worker/resources/service-worker-csp-worker.py new file mode 100644 index 000000000..4e5c6f3b6 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/service-worker-csp-worker.py @@ -0,0 +1,153 @@ +bodyDefault = ''' +importScripts('worker-testharness.js'); +importScripts('test-helpers.sub.js'); +importScripts('../resources/get-host-info.sub.js'); + +var host_info = get_host_info(); + +test(function() { + var import_script_failed = false; + try { + importScripts(host_info.HTTPS_REMOTE_ORIGIN + + base_path() + 'empty.js'); + } catch(e) { + import_script_failed = true; + } + assert_true(import_script_failed, + 'Importing the other origins script should fail.'); + }, 'importScripts test for default-src'); + +async_test(function(t) { + fetch(host_info.HTTPS_REMOTE_ORIGIN + + base_path() + 'fetch-access-control.py?ACAOrigin=*', + {mode: 'cors'}) + .then(function(response){ + assert_unreached('fetch should fail.'); + }, function(){ + t.done(); + }) + .catch(unreached_rejection(t)); + }, 'Fetch test for default-src'); + +async_test(function(t) { + var REDIRECT_URL = host_info.HTTPS_ORIGIN + + base_path() + 'redirect.py?Redirect='; + var OTHER_BASE_URL = host_info.HTTPS_REMOTE_ORIGIN + + base_path() + 'fetch-access-control.py?' + fetch(REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*'), + {mode: 'cors'}) + .then(function(response){ + assert_unreached('Redirected fetch should fail.'); + }, function(){ + t.done(); + }) + .catch(unreached_rejection(t)); + }, 'Redirected fetch test for default-src');''' + +bodyScript = ''' +importScripts('worker-testharness.js'); +importScripts('test-helpers.sub.js'); +importScripts('../resources/get-host-info.sub.js'); + +var host_info = get_host_info(); + +test(function() { + var import_script_failed = false; + try { + importScripts(host_info.HTTPS_REMOTE_ORIGIN + + base_path() + 'empty.js'); + } catch(e) { + import_script_failed = true; + } + assert_true(import_script_failed, + 'Importing the other origins script should fail.'); + }, 'importScripts test for script-src'); + +async_test(function(t) { + fetch(host_info.HTTPS_REMOTE_ORIGIN + + base_path() + 'fetch-access-control.py?ACAOrigin=*', + {mode: 'cors'}) + .then(function(response){ + t.done(); + }, function(){ + assert_unreached('fetch should not fail.'); + }) + .catch(unreached_rejection(t)); + }, 'Fetch test for script-src'); + +async_test(function(t) { + var REDIRECT_URL = host_info.HTTPS_ORIGIN + + base_path() + 'redirect.py?Redirect='; + var OTHER_BASE_URL = host_info.HTTPS_REMOTE_ORIGIN + + base_path() + 'fetch-access-control.py?' + fetch(REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*'), + {mode: 'cors'}) + .then(function(response){ + t.done(); + }, function(){ + assert_unreached('Redirected fetch should not fail.'); + }) + .catch(unreached_rejection(t)); + }, 'Redirected fetch test for script-src');''' + +bodyConnect = ''' +importScripts('worker-testharness.js'); +importScripts('test-helpers.sub.js'); +importScripts('../resources/get-host-info.sub.js'); + +var host_info = get_host_info(); + +test(function() { + var import_script_failed = false; + try { + importScripts(host_info.HTTPS_REMOTE_ORIGIN + + base_path() + 'empty.js'); + } catch(e) { + import_script_failed = true; + } + assert_false(import_script_failed, + 'Importing the other origins script should not fail.'); + }, 'importScripts test for connect-src'); + +async_test(function(t) { + fetch(host_info.HTTPS_REMOTE_ORIGIN + + base_path() + 'fetch-access-control.py?ACAOrigin=*', + {mode: 'cors'}) + .then(function(response){ + assert_unreached('fetch should fail.'); + }, function(){ + t.done(); + }) + .catch(unreached_rejection(t)); + }, 'Fetch test for connect-src'); + +async_test(function(t) { + var REDIRECT_URL = host_info.HTTPS_ORIGIN + + base_path() + 'redirect.py?Redirect='; + var OTHER_BASE_URL = host_info.HTTPS_REMOTE_ORIGIN + + base_path() + 'fetch-access-control.py?' + fetch(REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*'), + {mode: 'cors'}) + .then(function(response){ + assert_unreached('Redirected fetch should fail.'); + }, function(){ + t.done(); + }) + .catch(unreached_rejection(t)); + }, 'Redirected fetch test for connect-src');''' + +def main(request, response): + headers = [] + headers.append(('Content-Type', 'application/javascript')) + directive = request.GET['directive'] + body = 'ERROR: Unknown directive' + if directive == 'default': + headers.append(('Content-Security-Policy', "default-src 'self'")) + body = bodyDefault + elif directive == 'script': + headers.append(('Content-Security-Policy', "script-src 'self'")) + body = bodyScript + elif directive == 'connect': + headers.append(('Content-Security-Policy', "connect-src 'self'")) + body = bodyConnect + return headers, body diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/shared-worker-controlled.js b/testing/web-platform/tests/service-workers/service-worker/resources/shared-worker-controlled.js new file mode 100644 index 000000000..1ccc2fe3b --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/shared-worker-controlled.js @@ -0,0 +1,8 @@ +onconnect = function(e) { + var port = e.ports[0]; + var xhr = new XMLHttpRequest(); + xhr.onload = function() { port.postMessage(this.responseText); }; + xhr.onerror = function(e) { port.postMessage(e); }; + xhr.open('GET', 'dummy.txt?simple', true); + xhr.send(); +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/shared-worker-import.js b/testing/web-platform/tests/service-workers/service-worker/resources/shared-worker-import.js new file mode 100644 index 000000000..7c554bd74 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/shared-worker-import.js @@ -0,0 +1 @@ +importScripts('import-dummy-shared-worker.js'); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/silence.oga b/testing/web-platform/tests/service-workers/service-worker/resources/silence.oga new file mode 100644 index 000000000..af5918804 Binary files /dev/null and b/testing/web-platform/tests/service-workers/service-worker/resources/silence.oga differ diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/simple-intercept-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/simple-intercept-worker.js new file mode 100644 index 000000000..f8b5f8c5c --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/simple-intercept-worker.js @@ -0,0 +1,5 @@ +self.onfetch = function(event) { + if (event.request.url.indexOf('simple') != -1) + event.respondWith( + new Response(new Blob(['intercepted by service worker']))); +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/simple.html b/testing/web-platform/tests/service-workers/service-worker/resources/simple.html new file mode 100644 index 000000000..0c3e3e787 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/simple.html @@ -0,0 +1,3 @@ + +Simple +Here's a simple html file. diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/simple.txt b/testing/web-platform/tests/service-workers/service-worker/resources/simple.txt new file mode 100644 index 000000000..9e3cb91fb --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/simple.txt @@ -0,0 +1 @@ +a simple text file diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/skip-waiting-installed-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/skip-waiting-installed-worker.js new file mode 100644 index 000000000..bf582c770 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/skip-waiting-installed-worker.js @@ -0,0 +1,24 @@ +self.state = 'starting'; + +self.addEventListener('install', function() { + self.state = 'installing'; + }); + +self.addEventListener('message', function(event) { + var port = event.data.port; + if (self.state !== 'installing') { + port.postMessage('FAIL: Worker should be waiting in installed state'); + return; + } + self.skipWaiting() + .then(function(result) { + if (result !== undefined) { + port.postMessage('FAIL: Promise should be resolved with undefined'); + return; + } + port.postMessage('PASS'); + }) + .catch(function(e) { + port.postMessage('FAIL: unexpected exception: ' + e); + }); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/skip-waiting-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/skip-waiting-worker.js new file mode 100644 index 000000000..3fc1d1e23 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/skip-waiting-worker.js @@ -0,0 +1,21 @@ +importScripts('worker-testharness.js'); + +promise_test(function() { + return skipWaiting() + .then(function(result) { + assert_equals(result, undefined, + 'Promise should be resolved with undefined'); + }) + .then(function() { + var promises = []; + for (var i = 0; i < 8; ++i) + promises.push(self.skipWaiting()); + return Promise.all(promises); + }) + .then(function(results) { + results.forEach(function(r) { + assert_equals(r, undefined, + 'Promises should be resolved with undefined'); + }); + }); + }, 'skipWaiting'); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/square.png b/testing/web-platform/tests/service-workers/service-worker/resources/square.png new file mode 100644 index 000000000..01c9666a8 Binary files /dev/null and b/testing/web-platform/tests/service-workers/service-worker/resources/square.png differ diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/success.py b/testing/web-platform/tests/service-workers/service-worker/resources/success.py new file mode 100644 index 000000000..bcbb487d2 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/success.py @@ -0,0 +1,8 @@ +def main(request, response): + headers = [] + + if "ACAOrigin" in request.GET: + for item in request.GET["ACAOrigin"].split(","): + headers.append(("Access-Control-Allow-Origin", item)) + + return headers, "{ \"result\": \"success\" }" diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/test-helpers.sub.js b/testing/web-platform/tests/service-workers/service-worker/resources/test-helpers.sub.js new file mode 100644 index 000000000..b0ffbd406 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/test-helpers.sub.js @@ -0,0 +1,227 @@ +// Adapter for testharness.js-style tests with Service Workers + +function service_worker_unregister_and_register(test, url, scope) { + if (!scope || scope.length == 0) + return Promise.reject(new Error('tests must define a scope')); + + var options = { scope: scope }; + return service_worker_unregister(test, scope) + .then(function() { + return navigator.serviceWorker.register(url, options); + }) + .catch(unreached_rejection(test, + 'unregister and register should not fail')); +} + +// This unregisters the registration that precisely matches scope. Use this +// when unregistering by scope. If no registration is found, it just resolves. +function service_worker_unregister(test, scope) { + var absoluteScope = (new URL(scope, window.location).href); + return navigator.serviceWorker.getRegistration(scope) + .then(function(registration) { + if (registration && registration.scope === absoluteScope) + return registration.unregister(); + }) + .catch(unreached_rejection(test, 'unregister should not fail')); +} + +function service_worker_unregister_and_done(test, scope) { + return service_worker_unregister(test, scope) + .then(test.done.bind(test)); +} + +function unreached_fulfillment(test, prefix) { + return test.step_func(function(result) { + var error_prefix = prefix || 'unexpected fulfillment'; + assert_unreached(error_prefix + ': ' + result); + }); +} + +// Rejection-specific helper that provides more details +function unreached_rejection(test, prefix) { + return test.step_func(function(error) { + var reason = error.message || error.name || error; + var error_prefix = prefix || 'unexpected rejection'; + assert_unreached(error_prefix + ': ' + reason); + }); +} + +// Adds an iframe to the document and returns a promise that resolves to the +// iframe when it finishes loading. The caller is responsible for removing the +// iframe later if needed. +function with_iframe(url) { + return new Promise(function(resolve) { + var frame = document.createElement('iframe'); + frame.src = url; + frame.onload = function() { resolve(frame); }; + document.body.appendChild(frame); + }); +} + +function normalizeURL(url) { + return new URL(url, self.location).toString().replace(/#.*$/, ''); +} + +function wait_for_update(test, registration) { + if (!registration || registration.unregister == undefined) { + return Promise.reject(new Error( + 'wait_for_update must be passed a ServiceWorkerRegistration')); + } + + return new Promise(test.step_func(function(resolve) { + registration.addEventListener('updatefound', test.step_func(function() { + resolve(registration.installing); + })); + })); +} + +function wait_for_state(test, worker, state) { + if (!worker || worker.state == undefined) { + return Promise.reject(new Error( + 'wait_for_state must be passed a ServiceWorker')); + } + if (worker.state === state) + return Promise.resolve(state); + + if (state === 'installing') { + switch (worker.state) { + case 'installed': + case 'activating': + case 'activated': + case 'redundant': + return Promise.reject(new Error( + 'worker is ' + worker.state + ' but waiting for ' + state)); + } + } + + if (state === 'installed') { + switch (worker.state) { + case 'activating': + case 'activated': + case 'redundant': + return Promise.reject(new Error( + 'worker is ' + worker.state + ' but waiting for ' + state)); + } + } + + if (state === 'activating') { + switch (worker.state) { + case 'activated': + case 'redundant': + return Promise.reject(new Error( + 'worker is ' + worker.state + ' but waiting for ' + state)); + } + } + + if (state === 'activated') { + switch (worker.state) { + case 'redundant': + return Promise.reject(new Error( + 'worker is ' + worker.state + ' but waiting for ' + state)); + } + } + + return new Promise(test.step_func(function(resolve) { + worker.addEventListener('statechange', test.step_func(function() { + if (worker.state === state) + resolve(state); + })); + })); +} + +// Declare a test that runs entirely in the ServiceWorkerGlobalScope. The |url| +// is the service worker script URL. This function: +// - Instantiates a new test with the description specified in |description|. +// The test will succeed if the specified service worker can be successfully +// registered and installed. +// - Creates a new ServiceWorker registration with a scope unique to the current +// document URL. Note that this doesn't allow more than one +// service_worker_test() to be run from the same document. +// - Waits for the new worker to begin installing. +// - Imports tests results from tests running inside the ServiceWorker. +function service_worker_test(url, description) { + // If the document URL is https://example.com/document and the script URL is + // https://example.com/script/worker.js, then the scope would be + // https://example.com/script/scope/document. + var scope = new URL('scope' + window.location.pathname, + new URL(url, window.location)).toString(); + promise_test(function(test) { + return service_worker_unregister_and_register(test, url, scope) + .then(function(registration) { + add_completion_callback(function() { + registration.unregister(); + }); + return wait_for_update(test, registration) + .then(function(worker) { + return fetch_tests_from_worker(worker); + }); + }); + }, description); +} + +function base_path() { + return location.pathname.replace(/\/[^\/]*$/, '/'); +} + +function test_login(test, origin, username, password, cookie) { + return new Promise(function(resolve, reject) { + with_iframe( + origin + base_path() + + 'resources/fetch-access-control-login.html') + .then(test.step_func(function(frame) { + var channel = new MessageChannel(); + channel.port1.onmessage = test.step_func(function() { + frame.remove(); + resolve(); + }); + frame.contentWindow.postMessage( + {username: username, password: password, cookie: cookie}, + origin, [channel.port2]); + })); + }); +} + +function test_websocket(test, frame, url) { + return new Promise(function(resolve, reject) { + var ws = new frame.contentWindow.WebSocket(url, ['echo', 'chat']); + var openCalled = false; + ws.addEventListener('open', test.step_func(function(e) { + assert_equals(ws.readyState, 1, "The WebSocket should be open"); + openCalled = true; + ws.close(); + }), true); + + ws.addEventListener('close', test.step_func(function(e) { + assert_true(openCalled, "The WebSocket should be closed after being opened"); + resolve(); + }), true); + + ws.addEventListener('error', reject); + }); +} + +function login(test) { + return test_login(test, 'http://{{domains[www1]}}:{{ports[http][0]}}', + 'username1', 'password1', 'cookie1') + .then(function() { + return test_login(test, 'http://{{host}}:{{ports[http][0]}}', + 'username2', 'password2', 'cookie2'); + }); +} + +function login_https(test) { + return test_login(test, 'https://{{domains[www1]}}:{{ports[https][0]}}', + 'username1s', 'password1s', 'cookie1') + .then(function() { + return test_login(test, 'https://{{host}}:{{ports[https][0]}}', + 'username2s', 'password2s', 'cookie2'); + }); +} + +function websocket(test, frame) { + return test_websocket(test, frame, get_websocket_url()); +} + +function get_websocket_url() { + return 'wss://{{host}}:{{ports[wss][0]}}/echo'; +} diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/testharness-helpers.js b/testing/web-platform/tests/service-workers/service-worker/resources/testharness-helpers.js new file mode 100644 index 000000000..4d7af1ff9 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/testharness-helpers.js @@ -0,0 +1,163 @@ +/* + * testharness-helpers contains various useful extensions to testharness.js to + * allow them to be used across multiple tests before they have been + * upstreamed. This file is intended to be usable from both document and worker + * environments, so code should for example not rely on the DOM. + */ + +// Returns a promise that fulfills after the provided |promise| is fulfilled. +// The |test| succeeds only if |promise| rejects with an exception matching +// |code|. Accepted values for |code| follow those accepted for assert_throws(). +// The optional |description| describes the test being performed. +// +// E.g.: +// assert_promise_rejects( +// new Promise(...), // something that should throw an exception. +// 'NotFoundError', +// 'Should throw NotFoundError.'); +// +// assert_promise_rejects( +// new Promise(...), +// new TypeError(), +// 'Should throw TypeError'); +function assert_promise_rejects(promise, code, description) { + return promise.then( + function() { + throw 'assert_promise_rejects: ' + description + ' Promise did not reject.'; + }, + function(e) { + if (code !== undefined) { + assert_throws(code, function() { throw e; }, description); + } + }); +} + +// Asserts that two objects |actual| and |expected| are weakly equal under the +// following definition: +// +// |a| and |b| are weakly equal if any of the following are true: +// 1. If |a| is not an 'object', and |a| === |b|. +// 2. If |a| is an 'object', and all of the following are true: +// 2.1 |a.p| is weakly equal to |b.p| for all own properties |p| of |a|. +// 2.2 Every own property of |b| is an own property of |a|. +// +// This is a replacement for the the version of assert_object_equals() in +// testharness.js. The latter doesn't handle own properties correctly. I.e. if +// |a.p| is not an own property, it still requires that |b.p| be an own +// property. +// +// Note that |actual| must not contain cyclic references. +self.assert_object_equals = function(actual, expected, description) { + var object_stack = []; + + function _is_equal(actual, expected, prefix) { + if (typeof actual !== 'object') { + assert_equals(actual, expected, prefix); + return; + } + assert_true(typeof expected === 'object', prefix); + assert_equals(object_stack.indexOf(actual), -1, + prefix + ' must not contain cyclic references.'); + + object_stack.push(actual); + + Object.getOwnPropertyNames(expected).forEach(function(property) { + assert_own_property(actual, property, prefix); + _is_equal(actual[property], expected[property], + prefix + '.' + property); + }); + Object.getOwnPropertyNames(actual).forEach(function(property) { + assert_own_property(expected, property, prefix); + }); + + object_stack.pop(); + } + + function _brand(object) { + return Object.prototype.toString.call(object).match(/^\[object (.*)\]$/)[1]; + } + + _is_equal(actual, expected, + (description ? description + ': ' : '') + _brand(expected)); +}; + +// Equivalent to assert_in_array, but uses a weaker equivalence relation +// (assert_object_equals) than '==='. +function assert_object_in_array(actual, expected_array, description) { + assert_true(expected_array.some(function(element) { + try { + assert_object_equals(actual, element); + return true; + } catch (e) { + return false; + } + }), description); +} + +// Assert that the two arrays |actual| and |expected| contain the same set of +// elements as determined by assert_object_equals. The order is not significant. +// +// |expected| is assumed to not contain any duplicates as determined by +// assert_object_equals(). +function assert_array_equivalent(actual, expected, description) { + assert_true(Array.isArray(actual), description); + assert_equals(actual.length, expected.length, description); + expected.forEach(function(expected_element) { + // assert_in_array treats the first argument as being 'actual', and the + // second as being 'expected array'. We are switching them around because + // we want to be resilient against the |actual| array containing + // duplicates. + assert_object_in_array(expected_element, actual, description); + }); +} + +// Asserts that two arrays |actual| and |expected| contain the same set of +// elements as determined by assert_object_equals(). The corresponding elements +// must occupy corresponding indices in their respective arrays. +function assert_array_objects_equals(actual, expected, description) { + assert_true(Array.isArray(actual), description); + assert_equals(actual.length, expected.length, description); + actual.forEach(function(value, index) { + assert_object_equals(value, expected[index], + description + ' : object[' + index + ']'); + }); +} + +// Asserts that |object| that is an instance of some interface has the attribute +// |attribute_name| following the conditions specified by WebIDL, but it's +// acceptable that the attribute |attribute_name| is an own property of the +// object because we're in the middle of moving the attribute to a prototype +// chain. Once we complete the transition to prototype chains, +// assert_will_be_idl_attribute must be replaced with assert_idl_attribute +// defined in testharness.js. +// +// FIXME: Remove assert_will_be_idl_attribute once we complete the transition +// of moving the DOM attributes to prototype chains. (http://crbug.com/43394) +function assert_will_be_idl_attribute(object, attribute_name, description) { + assert_true(typeof object === "object", description); + + assert_true("hasOwnProperty" in object, description); + + // Do not test if |attribute_name| is not an own property because + // |attribute_name| is in the middle of the transition to a prototype + // chain. (http://crbug.com/43394) + + assert_true(attribute_name in object, description); +} + +// Stringifies a DOM object. This function stringifies not only own properties +// but also DOM attributes which are on a prototype chain. Note that +// JSON.stringify only stringifies own properties. +function stringifyDOMObject(object) +{ + function deepCopy(src) { + if (typeof src != "object") + return src; + var dst = Array.isArray(src) ? [] : {}; + for (var property in src) { + dst[property] = deepCopy(src[property]); + } + return dst; + } + return JSON.stringify(deepCopy(object)); +} diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/unregister-controller-page.html b/testing/web-platform/tests/service-workers/service-worker/resources/unregister-controller-page.html new file mode 100644 index 000000000..18a95ee89 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/unregister-controller-page.html @@ -0,0 +1,16 @@ + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/update-nocookie-worker.py b/testing/web-platform/tests/service-workers/service-worker/resources/update-nocookie-worker.py new file mode 100644 index 000000000..0f09b7e32 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/update-nocookie-worker.py @@ -0,0 +1,15 @@ +import time + +def main(request, response): + # no-cache itself to ensure the user agent finds a new version for each update. + headers = [('Cache-Control', 'no-cache, must-revalidate'), + ('Pragma', 'no-cache')] + + # Set a normal mimetype. + content_type = 'application/javascript' + + headers.append(('Content-Type', content_type)) + # Return a different script for each access. Use .time() and .clock() for + # best time resolution across different platforms. + return headers, '// %s %s' % (time.time(), time.clock()) + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/update-recovery-worker.py b/testing/web-platform/tests/service-workers/service-worker/resources/update-recovery-worker.py new file mode 100644 index 000000000..8aaa5ca93 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/update-recovery-worker.py @@ -0,0 +1,25 @@ +def main(request, response): + # Set mode to 'init' for initial fetch. + mode = 'init' + if 'update-recovery-mode' in request.cookies: + mode = request.cookies['update-recovery-mode'].value + + # no-cache itself to ensure the user agent finds a new version for each update. + headers = [('Cache-Control', 'no-cache, must-revalidate'), + ('Pragma', 'no-cache')] + + extra_body = '' + + if mode == 'init': + # Install a bad service worker that will break the controlled + # document navigation. + response.set_cookie('update-recovery-mode', 'bad') + extra_body = "addEventListener('fetch', function(e) { e.respondWith(Promise.reject()); });" + elif mode == 'bad': + # When the update tries to pull the script again, update to + # a worker service worker that does not break document + # navigation. Serve the same script from then on. + response.delete_cookie('update-recovery-mode') + + headers.append(('Content-Type', 'application/javascript')) + return headers, '%s' % (extra_body) diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/update-worker.py b/testing/web-platform/tests/service-workers/service-worker/resources/update-worker.py new file mode 100644 index 000000000..bc9b32ad3 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/update-worker.py @@ -0,0 +1,46 @@ +import time + +def main(request, response): + # Set mode to 'init' for initial fetch. + mode = 'init' + if 'mode' in request.cookies: + mode = request.cookies['mode'].value + + # no-cache itself to ensure the user agent finds a new version for each update. + headers = [('Cache-Control', 'no-cache, must-revalidate'), + ('Pragma', 'no-cache')] + + content_type = '' + extra_body = '' + + if mode == 'init': + # Set a normal mimetype. + # Set cookie value to 'normal' so the next fetch will work in 'normal' mode. + content_type = 'application/javascript' + response.set_cookie('mode', 'normal') + elif mode == 'normal': + # Set a normal mimetype. + # Set cookie value to 'error' so the next fetch will work in 'error' mode. + content_type = 'application/javascript' + response.set_cookie('mode', 'error'); + elif mode == 'error': + # Set a disallowed mimetype. + # Set cookie value to 'syntax-error' so the next fetch will work in 'syntax-error' mode. + content_type = 'text/html' + response.set_cookie('mode', 'syntax-error'); + elif mode == 'syntax-error': + # Set cookie value to 'throw-install' so the next fetch will work in 'throw-install' mode. + content_type = 'application/javascript' + response.set_cookie('mode', 'throw-install'); + extra_body = 'badsyntax(isbad;' + elif mode == 'throw-install': + # Unset and delete cookie to clean up the test setting. + content_type = 'application/javascript' + response.delete_cookie('mode') + extra_body = "addEventListener('install', function(e) { throw new Error('boom'); });" + + headers.append(('Content-Type', content_type)) + # Return a different script for each access. Use .time() and .clock() for + # best time resolution across different platforms. + return headers, '/* %s %s */ %s' % (time.time(), time.clock(), extra_body) + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/update/update-after-oneday.https.html b/testing/web-platform/tests/service-workers/service-worker/resources/update/update-after-oneday.https.html new file mode 100644 index 000000000..9d4c98272 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/update/update-after-oneday.https.html @@ -0,0 +1,8 @@ + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/wait-forever-in-install-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/wait-forever-in-install-worker.js new file mode 100644 index 000000000..af85a73ad --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/wait-forever-in-install-worker.js @@ -0,0 +1,12 @@ +var waitUntilResolve; +self.addEventListener('install', function(event) { + event.waitUntil(new Promise(function(resolve) { + waitUntilResolve = resolve; + })); + }); + +self.addEventListener('message', function(event) { + if (event.data === 'STOP_WAITING') { + waitUntilResolve(); + } + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/websocket.js b/testing/web-platform/tests/service-workers/service-worker/resources/websocket.js new file mode 100644 index 000000000..fc6abd283 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/websocket.js @@ -0,0 +1,7 @@ +self.urls = []; +self.addEventListener('fetch', function(event) { + self.urls.push(event.request.url); + }); +self.addEventListener('message', function(event) { + event.data.port.postMessage({urls: self.urls}); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/worker-interception-iframe.https.html b/testing/web-platform/tests/service-workers/service-worker/resources/worker-interception-iframe.https.html new file mode 100644 index 000000000..12a461ea5 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/worker-interception-iframe.https.html @@ -0,0 +1,39 @@ + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/worker-load-interceptor.js b/testing/web-platform/tests/service-workers/service-worker/resources/worker-load-interceptor.js new file mode 100644 index 000000000..960c6328c --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/worker-load-interceptor.js @@ -0,0 +1,13 @@ +importScripts('get-host-info.sub.js'); + +var response_text = "This load was successfully intercepted."; +var response_script = "postMessage(\"This load was successfully intercepted.\");"; + +self.onfetch = function(event) { + var url = event.request.url; + if (url.indexOf("synthesized-response.txt") != -1) { + event.respondWith(new Response(response_text)); + } else if (url.indexOf("synthesized-response.js") != -1) { + event.respondWith(new Response(response_script)); + } +}; diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/worker-testharness.js b/testing/web-platform/tests/service-workers/service-worker/resources/worker-testharness.js new file mode 100644 index 000000000..fdf5868e3 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/worker-testharness.js @@ -0,0 +1,49 @@ +/* + * worker-test-harness should be considered a temporary polyfill around + * testharness.js for supporting Service Worker based tests. It should not be + * necessary once the test harness is able to drive worker based tests natively. + * See https://github.com/w3c/testharness.js/pull/82 for status of effort to + * update upstream testharness.js. Once the upstreaming is complete, tests that + * reference worker-test-harness should be updated to directly import + * testharness.js. + */ + +importScripts('/resources/testharness.js'); + +(function() { + var next_cache_index = 1; + + // Returns a promise that resolves to a newly created Cache object. The + // returned Cache will be destroyed when |test| completes. + function create_temporary_cache(test) { + var uniquifier = String(++next_cache_index); + var cache_name = self.location.pathname + '/' + uniquifier; + + test.add_cleanup(function() { + self.caches.delete(cache_name); + }); + + return self.caches.delete(cache_name) + .then(function() { + return self.caches.open(cache_name); + }); + } + + self.create_temporary_cache = create_temporary_cache; +})(); + +// Runs |test_function| with a temporary unique Cache passed in as the only +// argument. The function is run as a part of Promise chain owned by +// promise_test(). As such, it is expected to behave in a manner identical (with +// the exception of the argument) to a function passed into promise_test(). +// +// E.g.: +// cache_test(function(cache) { +// // Do something with |cache|, which is a Cache object. +// }, "Some Cache test"); +function cache_test(test_function, description) { + promise_test(function(test) { + return create_temporary_cache(test) + .then(test_function); + }, description); +} diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/xhr.js b/testing/web-platform/tests/service-workers/service-worker/resources/xhr.js new file mode 100644 index 000000000..387c4a48e --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/xhr.js @@ -0,0 +1,6 @@ +self.addEventListener('activate', function(event) { + event.waitUntil(clients.claim()); + }); +self.addEventListener('message', function(event) { + event.data.port.postMessage({xhr: !!("XMLHttpRequest" in self)}); + }); diff --git a/testing/web-platform/tests/service-workers/service-worker/service-worker-csp-connect.https.html b/testing/web-platform/tests/service-workers/service-worker/service-worker-csp-connect.https.html new file mode 100644 index 000000000..226f4a40e --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/service-worker-csp-connect.https.html @@ -0,0 +1,10 @@ + +Service Worker: CSP connect directive for ServiceWorker script + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/service-worker-csp-default.https.html b/testing/web-platform/tests/service-workers/service-worker/service-worker-csp-default.https.html new file mode 100644 index 000000000..1d4e7624d --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/service-worker-csp-default.https.html @@ -0,0 +1,10 @@ + +Service Worker: CSP default directive for ServiceWorker script + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/service-worker-csp-script.https.html b/testing/web-platform/tests/service-workers/service-worker/service-worker-csp-script.https.html new file mode 100644 index 000000000..14c2eb72b --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/service-worker-csp-script.https.html @@ -0,0 +1,10 @@ + +Service Worker: CSP script directive for ServiceWorker script + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/serviceworkerobject-scripturl.https.html b/testing/web-platform/tests/service-workers/service-worker/serviceworkerobject-scripturl.https.html new file mode 100644 index 000000000..95587a5a4 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/serviceworkerobject-scripturl.https.html @@ -0,0 +1,26 @@ + +ServiceWorker object: scriptURL property + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/shared-worker-controlled.https.html b/testing/web-platform/tests/service-workers/service-worker/shared-worker-controlled.https.html new file mode 100644 index 000000000..33d52e011 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/shared-worker-controlled.https.html @@ -0,0 +1,77 @@ + +Service Worker: controlling a SharedWorker + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/skip-waiting-installed.https.html b/testing/web-platform/tests/service-workers/service-worker/skip-waiting-installed.https.html new file mode 100644 index 000000000..42e4000b1 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/skip-waiting-installed.https.html @@ -0,0 +1,67 @@ + +Service Worker: Skip waiting installed worker + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/skip-waiting-using-registration.https.html b/testing/web-platform/tests/service-workers/service-worker/skip-waiting-using-registration.https.html new file mode 100644 index 000000000..5f84f0b8e --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/skip-waiting-using-registration.https.html @@ -0,0 +1,60 @@ + +Service Worker: Skip waiting using registration + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/skip-waiting-without-client.https.html b/testing/web-platform/tests/service-workers/service-worker/skip-waiting-without-client.https.html new file mode 100644 index 000000000..38fca1726 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/skip-waiting-without-client.https.html @@ -0,0 +1,13 @@ + +Service Worker: Skip waiting without client + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/skip-waiting-without-using-registration.https.html b/testing/web-platform/tests/service-workers/service-worker/skip-waiting-without-using-registration.https.html new file mode 100644 index 000000000..2535ffe09 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/skip-waiting-without-using-registration.https.html @@ -0,0 +1,42 @@ + +Service Worker: Skip waiting without using registration + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/skip-waiting.https.html b/testing/web-platform/tests/service-workers/service-worker/skip-waiting.https.html new file mode 100644 index 000000000..7c1c41f3f --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/skip-waiting.https.html @@ -0,0 +1,54 @@ + +Service Worker: Skip waiting + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/state.https.html b/testing/web-platform/tests/service-workers/service-worker/state.https.html new file mode 100644 index 000000000..3810362e0 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/state.https.html @@ -0,0 +1,69 @@ + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/synced-state.https.html b/testing/web-platform/tests/service-workers/service-worker/synced-state.https.html new file mode 100644 index 000000000..d842378be --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/synced-state.https.html @@ -0,0 +1,64 @@ + +ServiceWorker: worker objects have synced state + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/uncontrolled-page.https.html b/testing/web-platform/tests/service-workers/service-worker/uncontrolled-page.https.html new file mode 100644 index 000000000..a9523a54c --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/uncontrolled-page.https.html @@ -0,0 +1,39 @@ + +Service Worker: Registration + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/unregister-controller.https.html b/testing/web-platform/tests/service-workers/service-worker/unregister-controller.https.html new file mode 100644 index 000000000..3bf4cff72 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/unregister-controller.https.html @@ -0,0 +1,108 @@ + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/unregister-then-register-new-script.https.html b/testing/web-platform/tests/service-workers/service-worker/unregister-then-register-new-script.https.html new file mode 100644 index 000000000..385430c2d --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/unregister-then-register-new-script.https.html @@ -0,0 +1,159 @@ + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/unregister-then-register.https.html b/testing/web-platform/tests/service-workers/service-worker/unregister-then-register.https.html new file mode 100644 index 000000000..d75904d15 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/unregister-then-register.https.html @@ -0,0 +1,129 @@ + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/unregister.https.html b/testing/web-platform/tests/service-workers/service-worker/unregister.https.html new file mode 100644 index 000000000..492aecb21 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/unregister.https.html @@ -0,0 +1,40 @@ + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/update-after-navigation-fetch-event.https.html b/testing/web-platform/tests/service-workers/service-worker/update-after-navigation-fetch-event.https.html new file mode 100644 index 000000000..04cd9960f --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/update-after-navigation-fetch-event.https.html @@ -0,0 +1,34 @@ + +Service Worker: Update should be triggered after a navigation fetch event. + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/update-after-oneday.https.html b/testing/web-platform/tests/service-workers/service-worker/update-after-oneday.https.html new file mode 100644 index 000000000..151a59ebc --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/update-after-oneday.https.html @@ -0,0 +1,50 @@ + + +Service Worker: Functional events should trigger update if last update time is over 24 hours + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/update-recovery.https.html b/testing/web-platform/tests/service-workers/service-worker/update-recovery.https.html new file mode 100644 index 000000000..3b3d955b1 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/update-recovery.https.html @@ -0,0 +1,71 @@ + +Service Worker: recovery by navigation update + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/update.https.html b/testing/web-platform/tests/service-workers/service-worker/update.https.html new file mode 100644 index 000000000..213b72ac8 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/update.https.html @@ -0,0 +1,123 @@ + +Service Worker: Registration update() + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/waiting.https.html b/testing/web-platform/tests/service-workers/service-worker/waiting.https.html new file mode 100644 index 000000000..eff9c80a4 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/waiting.https.html @@ -0,0 +1,44 @@ + +ServiceWorker: navigator.serviceWorker.waiting + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/websocket.https.html b/testing/web-platform/tests/service-workers/service-worker/websocket.https.html new file mode 100644 index 000000000..3dfa6e514 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/websocket.https.html @@ -0,0 +1,46 @@ + +Service Worker: WebSocket handshake channel is not intercepted + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/worker-interception.https.html b/testing/web-platform/tests/service-workers/service-worker/worker-interception.https.html new file mode 100644 index 000000000..3ec66a54b --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/worker-interception.https.html @@ -0,0 +1,155 @@ + +Service Worker: intercepting Worker script loads + + + + + + diff --git a/testing/web-platform/tests/service-workers/service-worker/xhr.https.html b/testing/web-platform/tests/service-workers/service-worker/xhr.https.html new file mode 100644 index 000000000..776e61db1 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/xhr.https.html @@ -0,0 +1,35 @@ + +Service Worker: XHR doesn't exist + + + + + diff --git a/testing/web-platform/tests/service-workers/specgen.json b/testing/web-platform/tests/service-workers/specgen.json new file mode 100644 index 000000000..88c36ed04 --- /dev/null +++ b/testing/web-platform/tests/service-workers/specgen.json @@ -0,0 +1,658 @@ +{ + "sections": [ + { + "href": "#introduction", + "id": "introduction", + "hash": "da39a3ee5e6b4b0d3255bfef95601890afd80709", + "secno": "1", + "testable": false + }, + { + "href": "#about", + "id": "about", + "hash": "8d3cf149aa73cff52328509ebbaffd933e8fb6af", + "secno": "1.1", + "testable": false + }, + { + "href": "#dependencies", + "id": "dependencies", + "hash": "1355f2d7ec9bf4e617ee632c0db44f834c96435b", + "secno": "1.2", + "testable": false + }, + { + "href": "#motivations", + "id": "motivations", + "hash": "92d899bc1e63a170d2324638d16f580b97b4f4d6", + "secno": "1.3", + "testable": false + }, + { + "href": "#concepts", + "id": "concepts", + "hash": "589023372dc033b0a77be1cd01f54f5f8c3ebfa8", + "secno": "2", + "testable": false + }, + { + "href": "#document-context", + "id": "document-context", + "hash": "34feeb18dea978349a2f76e6b17c127123b3db74", + "secno": "3", + "testable": false + }, + { + "href": "#service-worker-obj", + "id": "service-worker-obj", + "hash": "6cbd0107199072ab86b36e72d08d5465b42e6da8", + "secno": "3.1", + "testPageHash": "8dbbc9aa4300f0203524f3e405dbf7ca462e7164", + "testPagePath": "stub-3.1-service-worker-obj.html", + "testable": true + }, + { + "href": "#service-worker-scope", + "id": "service-worker-scope", + "hash": "136f25ef227515a7be9b32c44967f68b34ad8924", + "secno": "3.1.1", + "testPageHash": "965a00b32d56192330aa9f6337072bb3633ad382", + "testPagePath": "stub-3.1.1-service-worker-scope.html", + "testable": true + }, + { + "href": "#service-worker-url", + "id": "service-worker-url", + "hash": "df66a1b4b3bfa3e7ab96fd491a6829fab1d18a88", + "secno": "3.1.2", + "testPageHash": "92f6aed1437bb39c5941b495ac6c5f342c025b38", + "testPagePath": "stub-3.1.2-service-worker-url.html", + "testable": true + }, + { + "href": "#service-worker-state", + "id": "service-worker-state", + "hash": "8f80f2b4cbb1c228867c9dd90c05cbecfc92dd77", + "secno": "3.1.3", + "testPageHash": "4aad1dc47572879fdc2c79a814ad21e1ef9a64ec", + "testPagePath": "stub-3.1.3-service-worker-state.html", + "testable": true + }, + { + "href": "#service-worker-on-state-change", + "id": "service-worker-on-state-change", + "hash": "0f8fd9d1431deacea72fe739f42992ab5a396bf2", + "secno": "3.1.4", + "testPageHash": "6bb309bccc1e7c74ade7fc4c6e400bafb60daceb", + "testPagePath": "stub-3.1.4-service-worker-on-state-change.html", + "testable": true + }, + { + "href": "#navigator-service-worker", + "id": "navigator-service-worker", + "hash": "22f1ebbafca6976d0f4814b0fbb8f173bf919f06", + "secno": "3.2", + "testPageHash": "6d597735816a09ec774150029ed5136198f52ab7", + "testPagePath": "stub-3.2-navigator-service-worker.html", + "testable": true + }, + { + "href": "#navigator-service-worker-installing", + "id": "navigator-service-worker-installing", + "hash": "9675c3cdf5ba4b4155284e06a19e4de631645509", + "secno": "3.2.1", + "testPageHash": "2c8e56e74c130104e395de46bad20fb5d3021d95", + "testPagePath": "stub-3.2.1-navigator-service-worker-installing.html", + "testable": true + }, + { + "href": "#navigator-service-worker-waiting", + "id": "navigator-service-worker-waiting", + "hash": "88b4db92cc49109e6a15ddebdd219690d9648e76", + "secno": "3.2.2", + "testPageHash": "1cf6ed58bf5ecf963fed8c3d9211b853dab564e2", + "testPagePath": "stub-3.2.2-navigator-service-worker-waiting.html", + "testable": true + }, + { + "href": "#navigator-service-worker-active", + "id": "navigator-service-worker-active", + "hash": "0da48e885c77da60d1837197780049904789e3cb", + "secno": "3.2.3", + "testPageHash": "f5dca8c6eb5f29a0f9a5f06e25861e7f3106cc67", + "testPagePath": "stub-3.2.3-navigator-service-worker-active.html", + "testable": true + }, + { + "href": "#navigator-service-worker-controller", + "id": "navigator-service-worker-controller", + "hash": "293433ccb7bb2a22d8d5a81e788892e071b25e65", + "secno": "3.2.4", + "testPageHash": "6452f431d0765d7aa3135d18fee43e6664dcbb12", + "testPagePath": "stub-3.2.4-navigator-service-worker-controller.html", + "testable": true + }, + { + "href": "#navigator-service-worker-ready", + "id": "navigator-service-worker-ready", + "hash": "6240fde8d7168beeb95f4f36aa9e143319b2061b", + "secno": "3.2.5", + "testPageHash": "ae4fd694c88bab72f338d97bf96b7d23e2e83e87", + "testPagePath": "stub-3.2.5-navigator-service-worker-ready.html", + "testable": true + }, + { + "href": "#navigator-service-worker-getAll", + "id": "navigator-service-worker-getAll", + "hash": "292ee3af2cc8fadc24302446809d04bf2e9811a5", + "secno": "3.2.6", + "testPageHash": "4096ae712cc3e753456fbe05bb4d0cfc4399d2c9", + "testPagePath": "stub-3.2.6-navigator-service-worker-getAll.html", + "testable": true + }, + { + "href": "#navigator-service-worker-register", + "id": "navigator-service-worker-register", + "hash": "c999dc5f67126c9f0f02b25fd943a34b48cff618", + "secno": "3.2.7", + "testPageHash": "bde900b97dbb08b053ff8115775ea3b79a124b6e", + "testPagePath": "stub-3.2.7-navigator-service-worker-register.html", + "testable": true + }, + { + "href": "#navigator-service-worker-unregister", + "id": "navigator-service-worker-unregister", + "hash": "fd196f926f181563855e4683cc995405c1e611d0", + "secno": "3.2.8", + "testPageHash": "dbd99a1dcbcb629431617790a305e840495049eb", + "testPagePath": "stub-3.2.8-navigator-service-worker-unregister.html", + "testable": true + }, + { + "href": "#navigator-service-worker-onupdatefound", + "id": "navigator-service-worker-onupdatefound", + "hash": "2bb5aabaca24a68f9e6b4c4443968178eb1ccfe8", + "secno": "3.2.9", + "testPageHash": "eef0c1c39577abefb3654a6e9917ff2da657871b", + "testPagePath": "stub-3.2.9-navigator-service-worker-onupdatefound.html", + "testable": true + }, + { + "href": "#navigator-service-worker-oncontrollerchange", + "id": "navigator-service-worker-oncontrollerchange", + "hash": "c89a4ffba10d9285e07c38c28718719d87053994", + "secno": "3.2.10", + "testPageHash": "35e0ce2b8f4527ebbd75d4dfa3436fd7f8c79792", + "testPagePath": "stub-3.2.10-navigator-service-worker-oncontrollerchange.html", + "testable": true + }, + { + "href": "#navigator-service-worker-onreloadpage", + "id": "navigator-service-worker-onreloadpage", + "hash": "424441910abf2e1bdc3db658fe46827f7abe60a4", + "secno": "3.2.11", + "testPageHash": "ae614de17e5f339b65f77cafa6e0f5625491abfb", + "testPagePath": "stub-3.2.11-navigator-service-worker-onreloadpage.html", + "testable": true + }, + { + "href": "#navigator-service-worker-onerror", + "id": "navigator-service-worker-onerror", + "hash": "710f7fcd2f5340147b9e030bc5932b8242cef828", + "secno": "3.2.12", + "testPageHash": "cd62779e27151d55f14ac6ab7aa41dcf723e0ac7", + "testPagePath": "stub-3.2.12-navigator-service-worker-onerror.html", + "testable": true + }, + { + "href": "#execution-context", + "id": "execution-context", + "hash": "ddf24f0adf58237e264c3c43cb7ab07af3013c9d", + "secno": "4", + "testable": false + }, + { + "href": "#service-worker-global-scope", + "id": "service-worker-global-scope", + "hash": "e6b8bb7f99c125f4226fc5b6c51cf03a7437f2ef", + "secno": "4.1", + "testPageHash": "2f596b6b07bcfb71c01d75f725eb52c84e9c69dd", + "testPagePath": "stub-4.1-service-worker-global-scope.html", + "testable": true + }, + { + "href": "#service-worker-global-scope-caches", + "id": "service-worker-global-scope-caches", + "hash": "43d3c9f441b3a7abd0d3a7f55d93faaceeb7d97d", + "secno": "4.1.1", + "testPageHash": "f19b91c887f6312688b66b1988147a599cd9470f", + "testPagePath": "stub-4.1.1-service-worker-global-scope-caches.html", + "testable": true + }, + { + "href": "#service-worker-global-scope-clients", + "id": "service-worker-global-scope-clients", + "hash": "cb83230107645229da9776ed0fc9f7bc6fcce747", + "secno": "4.1.2", + "testPageHash": "45b3aae572f7161748fa98e97b4f2b738c3dcfef", + "testPagePath": "stub-4.1.2-service-worker-global-scope-clients.html", + "testable": true + }, + { + "href": "#service-worker-global-scope-scope", + "id": "service-worker-global-scope-scope", + "hash": "08c808048b647aa9d4cc0b0a0f70b06ca89af4a3", + "secno": "4.1.3", + "testPageHash": "bfe7eaf8deb8de7d2ccfbba97640478b1c81d6c7", + "testPagePath": "stub-4.1.3-service-worker-global-scope-scope.html", + "testable": true + }, + { + "href": "#service-worker-global-scope-fetch", + "id": "service-worker-global-scope-fetch", + "hash": "b66133d8a2c67f9b10c274d5b05383ff76d2cd42", + "secno": "4.1.4", + "testPageHash": "2b1ffa915afddeb099dfff23f4ecf555b0710ed4", + "testPagePath": "stub-4.1.4-service-worker-global-scope-fetch.html", + "testable": true + }, + { + "href": "#service-worker-global-scope-update", + "id": "service-worker-global-scope-update", + "hash": "3ddf48cecb4d4a67a329248787dd220ce17f4eff", + "secno": "4.1.5", + "testPageHash": "15879bf45f460c0ab0c02793655096c1bca418a7", + "testPagePath": "stub-4.1.5-service-worker-global-scope-update.html", + "testable": true + }, + { + "href": "#service-worker-global-scope-unregister", + "id": "service-worker-global-scope-unregister", + "hash": "fff9ef2daa5689b38a17eeb9a6bd7071098ca778", + "secno": "4.1.6", + "testPageHash": "c4bf327228628b794db9c6f2eb17519e37cea6b9", + "testPagePath": "stub-4.1.6-service-worker-global-scope-unregister.html", + "testable": true + }, + { + "href": "#service-worker-global-scope-onmessage", + "id": "service-worker-global-scope-onmessage", + "hash": "bc8f6aed2d515dc7f6b0757afa02f37899082668", + "secno": "4.1.7", + "testPageHash": "9e6f2732d21871ec06e9541ea881baf962f7cdf4", + "testPagePath": "stub-4.1.7-service-worker-global-scope-onmessage.html", + "testable": true + }, + { + "href": "#client", + "id": "client", + "hash": "47a1c10cd9e4db9a5c86d9bcf80477f771ea954c", + "secno": "4.2", + "testPageHash": "21d74c1af0b3176b029c9b62b37fe73436e0f197", + "testPagePath": "stub-4.2-client.html", + "testable": true + }, + { + "href": "#service-worker-clients", + "id": "service-worker-clients", + "hash": "c2c6f4873f07b53705a46b2bd44ba10f84dd2b56", + "secno": "4.3", + "testPageHash": "9c0366e6cfd28caaeaf940bad2b3c7ace93037f6", + "testPagePath": "stub-4.3-service-worker-clients.html", + "testable": true + }, + { + "href": "#get-serviced-method", + "id": "get-serviced-method", + "hash": "299abaa21cf096e423edfa19755987986f742a1f", + "secno": "4.3.1", + "testPageHash": "efeb1c2dc8144c30e6628cb56b3e532531ee1e88", + "testPagePath": "stub-4.3.1-get-serviced-method.html", + "testable": true + }, + { + "href": "#reloadall-method", + "id": "reloadall-method", + "hash": "bb4d775d261e69cbeaf65c123e949c24cf542ae7", + "secno": "4.3.2", + "testPageHash": "d1a4dde873b77201b4de745d2083bf63549b0b8b", + "testPagePath": "stub-4.3.2-reloadall-method.html", + "testable": true + }, + { + "href": "#request-objects", + "id": "request-objects", + "hash": "65ae6c08f720a2eedb7b140f5635a5ac46ddadfc", + "secno": "4.4", + "testPageHash": "ec493c70e8a0d8d3eeb0ecaef59610aed97d298e", + "testPagePath": "stub-4.4-request-objects.html", + "testable": true + }, + { + "href": "#response-objects", + "id": "response-objects", + "hash": "2efbff63c70ab92f93e4acd021409b9df4776882", + "secno": "4.5", + "testPageHash": "8340b69d62f111f56095c5fe9047d9215fa7aefc", + "testPagePath": "stub-4.5-response-objects.html", + "testable": true + }, + { + "href": "#abstract-response", + "id": "abstract-response", + "hash": "bddc306a9892c0bca43e8b361c1ee22b87759e23", + "secno": "4.5.1", + "testable": false + }, + { + "href": "#response", + "id": "response", + "hash": "6471d25755bdab0d4f72413f9367b7bb36c53a6f", + "secno": "4.5.2", + "testPageHash": "346d63cc7eb8ee412f5f704ba241205c8d437540", + "testPagePath": "stub-4.5.2-response.html", + "testable": true + }, + { + "href": "#header", + "id": "header", + "hash": "da39a3ee5e6b4b0d3255bfef95601890afd80709", + "secno": "4.5.3", + "testable": false + }, + { + "href": "#opaque-response", + "id": "opaque-response", + "hash": "df5431f4fbd26d81f2d4f567309c6a7a26dbfd4a", + "secno": "4.5.4", + "testPageHash": "85373f290cf594f0f09eb0a76bc6ef6299be595f", + "testPagePath": "stub-4.5.4-opaque-response.html", + "testable": true + }, + { + "href": "#cors-response", + "id": "cors-response", + "hash": "da39a3ee5e6b4b0d3255bfef95601890afd80709", + "secno": "4.5.5", + "testable": false + }, + { + "href": "#cache-objects", + "id": "cache-objects", + "hash": "001d0dfb8fbcbcb6443d1be2b722c9a84d6fd95b", + "secno": "4.6", + "testPageHash": "c1ef341d15a8c76d015eef57842ed10e62c02927", + "testPagePath": "stub-4.6-cache-objects.html", + "testable": true + }, + { + "href": "#cache-lifetimes", + "id": "cache-lifetimes", + "hash": "7c73698ca9b686a0314ddf368bf8ad4ca6af392f", + "secno": "4.6.1", + "testPageHash": "f3524320a98f2fbdc5d711de82770957a7f5ec4b", + "testPagePath": "stub-4.6.1-cache-lifetimes.html", + "testable": true + }, + { + "href": "#cache", + "id": "cache", + "hash": "bf1fe844577ab57a60eb550be24335a3321ca2ee", + "secno": "4.6.2", + "testPageHash": "c55b7b05c8e2f4b65722e16cdbcd78ffdfe1e4bf", + "testPagePath": "stub-4.6.2-cache.html", + "testable": true + }, + { + "href": "#cache-storage", + "id": "cache-storage", + "hash": "9cdaac070f56e55d66a89cd4b6e669a04aa73b82", + "secno": "4.6.3", + "testPageHash": "ee6902f170d94cc1e3a4a00f4c90e7e19c4dff95", + "testPagePath": "stub-4.6.3-cache-storage.html", + "testable": true + }, + { + "href": "#events", + "id": "events", + "hash": "da39a3ee5e6b4b0d3255bfef95601890afd80709", + "secno": "4.7", + "testable": false + }, + { + "href": "#install-phase-event", + "id": "install-phase-event", + "hash": "8495382b418adbbed436b2002ab0155a3a295ef2", + "secno": "4.7.1", + "testPageHash": "e48e98d51936bd57d21903615203f2b78d3f4b12", + "testPagePath": "stub-4.7.1-install-phase-event.html", + "testable": true + }, + { + "href": "#wait-until-method", + "id": "wait-until-method", + "hash": "295fb5d4932396fd13365ed2fe57aa672f1f2a56", + "secno": "4.7.1.1", + "testPageHash": "c3769e51852b8438a97c39c50fa62351a73c4ee6", + "testPagePath": "stub-4.7.1.1-wait-until-method.html", + "testable": true + }, + { + "href": "#install-event", + "id": "install-event", + "hash": "3a0f6da1771c22ab21ddc00729433a4d95ac6782", + "secno": "4.7.2", + "testPageHash": "9a103cc461eaca3da75db583ce08f13ecd2b1a98", + "testPagePath": "stub-4.7.2-install-event.html", + "testable": true + }, + { + "href": "#install-event-section", + "id": "install-event-section", + "hash": "4631577df2efc1a4350000461629bc1ca93dbd14", + "secno": "4.7.2.1", + "testPageHash": "32f54e74bef784d2f0ac772b44abeee06573062d", + "testPagePath": "stub-4.7.2.1-install-event-section.html", + "testable": true + }, + { + "href": "#replace-method", + "id": "replace-method", + "hash": "b9093b05204d09748311023b4c737ede02ff8115", + "secno": "4.7.2.2", + "testPageHash": "372bed923f8c35c4923634ae27fa121919ac0fec", + "testPagePath": "stub-4.7.2.2-replace-method.html", + "testable": true + }, + { + "href": "#activate-event", + "id": "activate-event", + "hash": "ac3d03aa0ed961fb1122850aeab92c302c55ecd0", + "secno": "4.7.3", + "testPageHash": "6241762ab1d6f430fa9b7cc8f02a00e6591c6bc6", + "testPagePath": "stub-4.7.3-activate-event.html", + "testable": true + }, + { + "href": "#fetch-event", + "id": "fetch-event", + "hash": "da39a3ee5e6b4b0d3255bfef95601890afd80709", + "secno": "4.7.4", + "testable": false + }, + { + "href": "#fetch-event-section", + "id": "fetch-event-section", + "hash": "ae24fda9664a3bd7b7fe2a8712ac469c3ee7128e", + "secno": "4.7.4.1", + "testPageHash": "393fc7b65e9f5afd18da666b6b206ccd639397cd", + "testPagePath": "stub-4.7.4.1-fetch-event-section.html", + "testable": true + }, + { + "href": "#respond-with-method", + "id": "respond-with-method", + "hash": "7e4f010e2ec1ea0500b435cf599ba58942164457", + "secno": "4.7.4.2", + "testPageHash": "31e0acd058b9a5b722ae9f405b50bc94d31596b8", + "testPagePath": "stub-4.7.4.2-respond-with-method.html", + "testable": true + }, + { + "href": "#default-method", + "id": "default-method", + "hash": "4d6f8f93b2e10ab0e486dbf464ff107ec1a6aa4c", + "secno": "4.7.4.3", + "testPageHash": "34e015c973887e2b3bf8b6db62f75d5d417a43cc", + "testPagePath": "stub-4.7.4.3-default-method.html", + "testable": true + }, + { + "href": "#is-reload-attribute", + "id": "is-reload-attribute", + "hash": "6e1afd9e8940e9cd38aa7de1ed57e8c5b1a60e3d", + "secno": "4.7.4.4", + "testPageHash": "703a6469782d37be3c25e2214f897d1064acca47", + "testPagePath": "stub-4.7.4.4-is-reload-attribute.html", + "testable": true + }, + { + "href": "#security-considerations", + "id": "security-considerations", + "hash": "5b02b143172647dd7f74f0464dffa7ec7d0e8f94", + "secno": "5", + "testable": false + }, + { + "href": "#origin-relativity", + "id": "origin-relativity", + "hash": "72bbbd7d3d43a859af6ff9f19353210ddfcc26de", + "secno": "5.1", + "testPageHash": "1c92607dfac57b0f59654d059a4a67e0f984b84d", + "testPagePath": "stub-5.1-origin-relativity.html", + "testable": true + }, + { + "href": "#cross-origin-resources", + "id": "cross-origin-resources", + "hash": "6176879ecfb5ae769679ceef4ee1e8889be8df92", + "secno": "5.2", + "testPageHash": "bcf85ba278c70c086645c416cee729ce753bc528", + "testPagePath": "stub-5.2-cross-origin-resources.html", + "testable": true + }, + { + "href": "#storage-considerations", + "id": "storage-considerations", + "hash": "e101cee2062749b1a73086492377458251a5e875", + "secno": "6", + "testable": false + }, + { + "href": "#extensibility", + "id": "extensibility", + "hash": "ef1b382bb89c52e01edad421b02b237765a21ce7", + "secno": "7", + "testable": false + }, + { + "href": "#algorithms", + "id": "algorithms", + "hash": "d130247eab1d368efea646ff369e65f6c0c19481", + "secno": "8", + "testable": false + }, + { + "href": "#registration-algorithm", + "id": "registration-algorithm", + "hash": "b688d090671c08ca17ea7cadc561e6d471ee099e", + "secno": "8.1", + "testable": false + }, + { + "href": "#update-algorithm", + "id": "update-algorithm", + "hash": "679a19fef428affc83103c1eec0dbd3be40c4e2a", + "secno": "8.2", + "testable": false + }, + { + "href": "#soft-update-algorithm", + "id": "soft-update-algorithm", + "hash": "8eb103f5cd0e595ee5e25f075e8c6239211e482a", + "secno": "8.3", + "testable": false + }, + { + "href": "#installation-algorithm", + "id": "installation-algorithm", + "hash": "5874d9247d979009b67aedf964ae097837cfb3d9", + "secno": "8.4", + "testable": false + }, + { + "href": "#activation-algorithm", + "id": "activation-algorithm", + "hash": "648b34baf6e7c2096a842e6d367949117843108e", + "secno": "8.5", + "testable": false + }, + { + "href": "#on-fetch-request-algorithm", + "id": "on-fetch-request-algorithm", + "hash": "e1da43671071ec307f99cd781fc9b46353f3adfd", + "secno": "8.6", + "testable": false + }, + { + "href": "#on-document-unload-algorithm", + "id": "on-document-unload-algorithm", + "hash": "8a7196b5dd04ad4fb9b96e16a52f4f7ac1906763", + "secno": "8.7", + "testable": false + }, + { + "href": "#unregistration-algorithm", + "id": "unregistration-algorithm", + "hash": "0114db166d42211d0d7ab4b8e77de64a9fc97517", + "secno": "8.8", + "testable": false + }, + { + "href": "#update-state-algorithm", + "id": "update-state-algorithm", + "hash": "2ed8a1e7479f1a8ad038aa44ccdd5e4f6b65cf05", + "secno": "8.9", + "testable": false + }, + { + "href": "#scope-match-algorithm", + "id": "scope-match-algorithm", + "hash": "a2117fb34a8fa4ca3e832d9276477cfc1318dd1a", + "secno": "8.10", + "testable": false + }, + { + "href": "#get-registration-algorithm", + "id": "get-registration-algorithm", + "hash": "b20332db952ba8f4b7e5f65b740a18da4a199c2e", + "secno": "8.11", + "testable": false + }, + { + "href": "#get-newest-worker-algorithm", + "id": "get-newest-worker-algorithm", + "hash": "72dc1cbee8c98501931c411018fd1cad4376142b", + "secno": "8.12", + "testable": false + }, + { + "href": "#acknowledgements", + "id": "acknowledgements", + "hash": "6347067ca5a574f8cc80c76d95dee568042d059b", + "secno": "9", + "testable": false + } + ], + "specUrl": "https://w3c.github.io/ServiceWorker/" +} \ No newline at end of file diff --git a/testing/web-platform/tests/service-workers/stub-3.1-service-worker-obj.html b/testing/web-platform/tests/service-workers/stub-3.1-service-worker-obj.html new file mode 100644 index 000000000..b1c7f1ad0 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.1-service-worker-obj.html @@ -0,0 +1,63 @@ + + +Service Workers: ServiceWorker + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.1.1-service-worker-scope.html b/testing/web-platform/tests/service-workers/stub-3.1.1-service-worker-scope.html new file mode 100644 index 000000000..8c75c6082 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.1.1-service-worker-scope.html @@ -0,0 +1,46 @@ + + +Service Workers: scope + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.1.2-service-worker-url.html b/testing/web-platform/tests/service-workers/stub-3.1.2-service-worker-url.html new file mode 100644 index 000000000..5674df7fc --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.1.2-service-worker-url.html @@ -0,0 +1,43 @@ + + +Service Workers: url + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.1.3-service-worker-state.html b/testing/web-platform/tests/service-workers/stub-3.1.3-service-worker-state.html new file mode 100644 index 000000000..8e729baf8 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.1.3-service-worker-state.html @@ -0,0 +1,76 @@ + + +Service Workers: state + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.1.4-service-worker-on-state-change.html b/testing/web-platform/tests/service-workers/stub-3.1.4-service-worker-on-state-change.html new file mode 100644 index 000000000..c87dce601 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.1.4-service-worker-on-state-change.html @@ -0,0 +1,35 @@ + + +Service Workers: onstatechange + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2-navigator-service-worker.html b/testing/web-platform/tests/service-workers/stub-3.2-navigator-service-worker.html new file mode 100644 index 000000000..2654c60f0 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2-navigator-service-worker.html @@ -0,0 +1,84 @@ + + +Service Workers: navigator.serviceWorker + + + + + + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2.1-navigator-service-worker-installing.html b/testing/web-platform/tests/service-workers/stub-3.2.1-navigator-service-worker-installing.html new file mode 100644 index 000000000..59e4f3d6a --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2.1-navigator-service-worker-installing.html @@ -0,0 +1,43 @@ + + +Service Workers: installing + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2.10-navigator-service-worker-oncontrollerchange.html b/testing/web-platform/tests/service-workers/stub-3.2.10-navigator-service-worker-oncontrollerchange.html new file mode 100644 index 000000000..478860146 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2.10-navigator-service-worker-oncontrollerchange.html @@ -0,0 +1,45 @@ + + +Service Workers: oncontrollerchange + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2.11-navigator-service-worker-onreloadpage.html b/testing/web-platform/tests/service-workers/stub-3.2.11-navigator-service-worker-onreloadpage.html new file mode 100644 index 000000000..e2207db10 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2.11-navigator-service-worker-onreloadpage.html @@ -0,0 +1,41 @@ + + +Service Workers: onreloadpage + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2.12-navigator-service-worker-onerror.html b/testing/web-platform/tests/service-workers/stub-3.2.12-navigator-service-worker-onerror.html new file mode 100644 index 000000000..313f0bdfc --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2.12-navigator-service-worker-onerror.html @@ -0,0 +1,37 @@ + + +Service Workers: onerror + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2.2-navigator-service-worker-waiting.html b/testing/web-platform/tests/service-workers/stub-3.2.2-navigator-service-worker-waiting.html new file mode 100644 index 000000000..663ce82f9 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2.2-navigator-service-worker-waiting.html @@ -0,0 +1,34 @@ + + +Service Workers: waiting + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2.3-navigator-service-worker-active.html b/testing/web-platform/tests/service-workers/stub-3.2.3-navigator-service-worker-active.html new file mode 100644 index 000000000..f7406f590 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2.3-navigator-service-worker-active.html @@ -0,0 +1,40 @@ + + +Service Workers: active + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2.4-navigator-service-worker-controller.html b/testing/web-platform/tests/service-workers/stub-3.2.4-navigator-service-worker-controller.html new file mode 100644 index 000000000..1a26cce6d --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2.4-navigator-service-worker-controller.html @@ -0,0 +1,37 @@ + + +Service Workers: controller + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2.5-navigator-service-worker-ready.html b/testing/web-platform/tests/service-workers/stub-3.2.5-navigator-service-worker-ready.html new file mode 100644 index 000000000..67a690ddc --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2.5-navigator-service-worker-ready.html @@ -0,0 +1,67 @@ + + +Service Workers: ready + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2.6-navigator-service-worker-getAll.html b/testing/web-platform/tests/service-workers/stub-3.2.6-navigator-service-worker-getAll.html new file mode 100644 index 000000000..3c2afe99c --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2.6-navigator-service-worker-getAll.html @@ -0,0 +1,30 @@ + + +Service Workers: getAll() + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2.7-navigator-service-worker-register.html b/testing/web-platform/tests/service-workers/stub-3.2.7-navigator-service-worker-register.html new file mode 100644 index 000000000..df469de42 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2.7-navigator-service-worker-register.html @@ -0,0 +1,32 @@ + + +Service Workers: register() + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2.8-navigator-service-worker-unregister.html b/testing/web-platform/tests/service-workers/stub-3.2.8-navigator-service-worker-unregister.html new file mode 100644 index 000000000..6f1b43b6b --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2.8-navigator-service-worker-unregister.html @@ -0,0 +1,31 @@ + + +Service Workers: unregister() + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-3.2.9-navigator-service-worker-onupdatefound.html b/testing/web-platform/tests/service-workers/stub-3.2.9-navigator-service-worker-onupdatefound.html new file mode 100644 index 000000000..7babe7c24 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-3.2.9-navigator-service-worker-onupdatefound.html @@ -0,0 +1,42 @@ + + +Service Workers: onupdatefound + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.1-service-worker-global-scope.html b/testing/web-platform/tests/service-workers/stub-4.1-service-worker-global-scope.html new file mode 100644 index 000000000..48697f01e --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.1-service-worker-global-scope.html @@ -0,0 +1,75 @@ + + +Service Workers: ServiceWorkerGlobalScope + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.1.1-service-worker-global-scope-caches.html b/testing/web-platform/tests/service-workers/stub-4.1.1-service-worker-global-scope-caches.html new file mode 100644 index 000000000..f1fce5036 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.1.1-service-worker-global-scope-caches.html @@ -0,0 +1,36 @@ + + +Service Workers: caches + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.1.2-service-worker-global-scope-clients.html b/testing/web-platform/tests/service-workers/stub-4.1.2-service-worker-global-scope-clients.html new file mode 100644 index 000000000..cd5d28353 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.1.2-service-worker-global-scope-clients.html @@ -0,0 +1,33 @@ + + +Service Workers: clients + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.1.3-service-worker-global-scope-scope.html b/testing/web-platform/tests/service-workers/stub-4.1.3-service-worker-global-scope-scope.html new file mode 100644 index 000000000..7b6ce78fa --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.1.3-service-worker-global-scope-scope.html @@ -0,0 +1,36 @@ + + +Service Workers: scope + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.1.4-service-worker-global-scope-fetch.html b/testing/web-platform/tests/service-workers/stub-4.1.4-service-worker-global-scope-fetch.html new file mode 100644 index 000000000..98345471f --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.1.4-service-worker-global-scope-fetch.html @@ -0,0 +1,55 @@ + + +Service Workers: fetch(request) + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.1.5-service-worker-global-scope-update.html b/testing/web-platform/tests/service-workers/stub-4.1.5-service-worker-global-scope-update.html new file mode 100644 index 000000000..26e255dd4 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.1.5-service-worker-global-scope-update.html @@ -0,0 +1,36 @@ + + +Service Workers: update() + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.1.6-service-worker-global-scope-unregister.html b/testing/web-platform/tests/service-workers/stub-4.1.6-service-worker-global-scope-unregister.html new file mode 100644 index 000000000..de1d64a6e --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.1.6-service-worker-global-scope-unregister.html @@ -0,0 +1,31 @@ + + +Service Workers: unregister() + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.1.7-service-worker-global-scope-onmessage.html b/testing/web-platform/tests/service-workers/stub-4.1.7-service-worker-global-scope-onmessage.html new file mode 100644 index 000000000..b93043948 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.1.7-service-worker-global-scope-onmessage.html @@ -0,0 +1,45 @@ + + +Service Workers: onmessage + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.2-client.html b/testing/web-platform/tests/service-workers/stub-4.2-client.html new file mode 100644 index 000000000..4e8c3639d --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.2-client.html @@ -0,0 +1,61 @@ + + +Service Workers: Client + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.3-service-worker-clients.html b/testing/web-platform/tests/service-workers/stub-4.3-service-worker-clients.html new file mode 100644 index 000000000..c8a967a73 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.3-service-worker-clients.html @@ -0,0 +1,48 @@ + + +Service Workers: ServiceWorkerClients + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.3.1-get-serviced-method.html b/testing/web-platform/tests/service-workers/stub-4.3.1-get-serviced-method.html new file mode 100644 index 000000000..b3cd06fdf --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.3.1-get-serviced-method.html @@ -0,0 +1,34 @@ + + +Service Workers: getServiced() + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.3.2-reloadall-method.html b/testing/web-platform/tests/service-workers/stub-4.3.2-reloadall-method.html new file mode 100644 index 000000000..c5a9dd454 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.3.2-reloadall-method.html @@ -0,0 +1,37 @@ + + +Service Workers: reloadAll() + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.4-request-objects.html b/testing/web-platform/tests/service-workers/stub-4.4-request-objects.html new file mode 100644 index 000000000..bad4ea159 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.4-request-objects.html @@ -0,0 +1,72 @@ + + +Service Workers: Request Objects + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.5-response-objects.html b/testing/web-platform/tests/service-workers/stub-4.5-response-objects.html new file mode 100644 index 000000000..5ebf34314 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.5-response-objects.html @@ -0,0 +1,75 @@ + + +Service Workers: Response Objects + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.5.2-response.html b/testing/web-platform/tests/service-workers/stub-4.5.2-response.html new file mode 100644 index 000000000..fbc72f30a --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.5.2-response.html @@ -0,0 +1,36 @@ + + +Service Workers: Response + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.5.4-opaque-response.html b/testing/web-platform/tests/service-workers/stub-4.5.4-opaque-response.html new file mode 100644 index 000000000..a91306f4c --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.5.4-opaque-response.html @@ -0,0 +1,36 @@ + + +Service Workers: OpaqueResponse + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.6-cache-objects.html b/testing/web-platform/tests/service-workers/stub-4.6-cache-objects.html new file mode 100644 index 000000000..befd67cb3 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.6-cache-objects.html @@ -0,0 +1,37 @@ + + +Service Workers: Caches + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.6.1-cache-lifetimes.html b/testing/web-platform/tests/service-workers/stub-4.6.1-cache-lifetimes.html new file mode 100644 index 000000000..f6c9ecbd1 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.6.1-cache-lifetimes.html @@ -0,0 +1,38 @@ + + +Service Workers: Understanding Cache Lifetimes + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.6.2-cache.html b/testing/web-platform/tests/service-workers/stub-4.6.2-cache.html new file mode 100644 index 000000000..8999a4dd5 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.6.2-cache.html @@ -0,0 +1,64 @@ + + +Service Workers: Cache + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.6.3-cache-storage.html b/testing/web-platform/tests/service-workers/stub-4.6.3-cache-storage.html new file mode 100644 index 000000000..3f9e9b438 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.6.3-cache-storage.html @@ -0,0 +1,62 @@ + + +Service Workers: CacheStorage + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.7.1-install-phase-event.html b/testing/web-platform/tests/service-workers/stub-4.7.1-install-phase-event.html new file mode 100644 index 000000000..994da0200 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.7.1-install-phase-event.html @@ -0,0 +1,51 @@ + + +Service Workers: InstallPhaseEvent + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.7.1.1-wait-until-method.html b/testing/web-platform/tests/service-workers/stub-4.7.1.1-wait-until-method.html new file mode 100644 index 000000000..318318b13 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.7.1.1-wait-until-method.html @@ -0,0 +1,39 @@ + + +Service Workers: event.waitUntil(f) + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.7.2-install-event.html b/testing/web-platform/tests/service-workers/stub-4.7.2-install-event.html new file mode 100644 index 000000000..77702ed02 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.7.2-install-event.html @@ -0,0 +1,35 @@ + + +Service Workers: install Event + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.7.2.1-install-event-section.html b/testing/web-platform/tests/service-workers/stub-4.7.2.1-install-event-section.html new file mode 100644 index 000000000..17d52c6b0 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.7.2.1-install-event-section.html @@ -0,0 +1,47 @@ + + +Service Workers: InstallEvent + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.7.2.2-replace-method.html b/testing/web-platform/tests/service-workers/stub-4.7.2.2-replace-method.html new file mode 100644 index 000000000..6981d3079 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.7.2.2-replace-method.html @@ -0,0 +1,38 @@ + + +Service Workers: event.replace() + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.7.3-activate-event.html b/testing/web-platform/tests/service-workers/stub-4.7.3-activate-event.html new file mode 100644 index 000000000..2a0162e5f --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.7.3-activate-event.html @@ -0,0 +1,41 @@ + + +Service Workers: activate Event + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.7.4.1-fetch-event-section.html b/testing/web-platform/tests/service-workers/stub-4.7.4.1-fetch-event-section.html new file mode 100644 index 000000000..84d8c3880 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.7.4.1-fetch-event-section.html @@ -0,0 +1,71 @@ + + +Service Workers: FetchEvent + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.7.4.2-respond-with-method.html b/testing/web-platform/tests/service-workers/stub-4.7.4.2-respond-with-method.html new file mode 100644 index 000000000..416b8ef51 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.7.4.2-respond-with-method.html @@ -0,0 +1,46 @@ + + +Service Workers: event.respondWith(r) + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.7.4.3-default-method.html b/testing/web-platform/tests/service-workers/stub-4.7.4.3-default-method.html new file mode 100644 index 000000000..deff7ac42 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.7.4.3-default-method.html @@ -0,0 +1,52 @@ + + +Service Workers: event.default() + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-4.7.4.4-is-reload-attribute.html b/testing/web-platform/tests/service-workers/stub-4.7.4.4-is-reload-attribute.html new file mode 100644 index 000000000..fffe5d5b2 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-4.7.4.4-is-reload-attribute.html @@ -0,0 +1,32 @@ + + +Service Workers: event.isReload + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-5.1-origin-relativity.html b/testing/web-platform/tests/service-workers/stub-5.1-origin-relativity.html new file mode 100644 index 000000000..469ce2975 --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-5.1-origin-relativity.html @@ -0,0 +1,35 @@ + + +Service Workers: Origin Relativity + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/stub-5.2-cross-origin-resources.html b/testing/web-platform/tests/service-workers/stub-5.2-cross-origin-resources.html new file mode 100644 index 000000000..42c685b1d --- /dev/null +++ b/testing/web-platform/tests/service-workers/stub-5.2-cross-origin-resources.html @@ -0,0 +1,48 @@ + + +Service Workers: Cross-Origin Resources & CORS + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/service-workers/tools/blink-import.py b/testing/web-platform/tests/service-workers/tools/blink-import.py new file mode 100644 index 000000000..355df0796 --- /dev/null +++ b/testing/web-platform/tests/service-workers/tools/blink-import.py @@ -0,0 +1,204 @@ +import os +import re +import shutil +import glob +import tempfile +import sys +from collections import defaultdict + +here = os.path.abspath(os.path.split(__file__)[0]) + +def get_extra_files(chromium_root): + return [(os.path.join(chromium_root, "LayoutTests", "http", "tests", "resources", "testharness-helpers.js"), + os.path.join("resources", "testharness-helpers.js"))] + +resources_re = re.compile("/?(?:\.\./)*resources/(testharness(?:report)?)\.js") + +def resources_path(line, depth): + return False, resources_re.sub(r"/resources/\1.js", line) + +php_re = re.compile("\.php") + +def python_to_php(line, depth): + return False, php_re.sub(".py", line) + +abs_testharness_helpers_re = re.compile("([\"'])/resources/testharness-helpers.js") +testharness_helpers_re = re.compile("\.\./((?:\.\./)*)resources/testharness-helpers.js") + +def testharness_helpers(line, depth): + if abs_testharness_helpers_re.findall(line): + return False, abs_testharness_helpers_re.sub(r"\1%sresources/testharness-helpers.js" % ("../" * (depth - 1)), line) + return False, testharness_helpers_re.sub(r"\1resources/testharness-helpers.js", line) + +serviceworker_path_re = re.compile("/serviceworker/") +def service_worker_path(line, depth): + return False, serviceworker_path_re.sub("/service-workers/", line) + +localhost_re = re.compile("localhost") +alt_host_re = re.compile("127\.0\.0\.1") +port_http_re = re.compile("8000") +port_https_re = re.compile("8000") + + +def server_names(line, depth): + line, count_0 = localhost_re.subn("{{host}}", line) + line, count_1 = alt_host_re.subn("{{domains[www]}}", line) + line, count_2 = port_http_re.subn("{{ports[http][0]}}", line) + line, count_3 = port_https_re.subn("{{ports[https][0]}}", line) + + count = count_0 + count_1 + count_2 + count_3 + + return bool(count), line + + +def source_paths(chromium_root): + for dirpath, dirnames, filenames in os.walk(chromium_root): + if "chromium" in dirnames: + dirnames.remove("chromium") + for filename in filenames: + if filename.endswith("-expected.txt") or filename.endswith(".php"): + continue + yield os.path.relpath(os.path.join(dirpath, filename), chromium_root) + + +def do_subs(path, line): + depth = len(os.path.split(os.path.sep)) + subs = [resources_path, python_to_php, testharness_helpers, service_worker_path, server_names] + file_is_template = False + for sub in subs: + added_template, line = sub(line, depth) + if added_template: + file_is_template = True + return file_is_template, line + +def get_head(git): + return git("rev-parse", "HEAD") + +def get_changes(git, path, old, new): + data = git("diff", "--name-status", "-z", "--no-renames", "%s..%s" % (old, new), "--", path) + items = data.split("\0") + rv = defaultdict(list) + for status, path in items: + rv[status].append(path) + + return rv + +def copy(src_path, out_dir, rel_path): + dest = os.path.normpath(os.path.join(out_dir, rel_path)) + dest_dir = os.path.split(dest)[0] + if not os.path.exists(dest_dir): + os.makedirs(dest_dir) + shutil.copy2(src_path, dest) + +def copy_local_files(local_files, out_root, tmp_dir): + for path in local_files: + rel_path = os.path.relpath(path, out_root) + copy(path, tmp_dir, rel_path) + +def copy_extra_files(chromium_root, tmp_dir): + for in_path, rel_path in get_extra_files(chromium_root): + copy(in_path, tmp_dir, rel_path) + +def sub_changed_filenames(filename_changes, f): + rv = [] + for line in f: + for in_name, out_name in filename_changes.iteritems(): + line = line.replace(in_name, out_name) + rv.append(line) + return "".join(rv) + +testharness_re = re.compile("]*src=[\"']?/resources/testharness.js[\"' ][^>]*>") + +def is_top_level_test(path, data): + if os.path.splitext(path)[1] != ".html": + return False + for line in data: + if testharness_re.findall(line): + return True + return False + +def add_suffix(path, suffix): + root, ext = os.path.splitext(path) + return root + ".%s" % suffix + ext + +def main(): + if "--cache-tests" in sys.argv: + sw_path = os.path.join("LayoutTests", "http", "tests", "cachestorage") + out_root = os.path.abspath(os.path.join(here, "..", "cache-storage")) + elif "--sw-tests" in sys.argv: + sw_path = os.path.join("LayoutTests", "http", "tests", "serviceworkers") + out_root = os.path.abspath(os.path.join(here, "..", "service-worker")) + else: + raise ValueError("Must supply either --cache-tests or --sw-tests") + + chromium_root = os.path.abspath(sys.argv[1]) + + work_path = tempfile.mkdtemp() + + test_path = os.path.join(chromium_root, sw_path) + + local_files = glob.glob(os.path.normpath(os.path.join(here, "..", "resources", "*.py"))) + + if not os.path.exists(out_root): + os.mkdir(out_root) + + copy_local_files(local_files, out_root, work_path) + copy_extra_files(chromium_root, work_path) + + path_changes = {} + + for path in source_paths(test_path): + out_path = os.path.join(work_path, path) + out_dir = os.path.dirname(out_path) + if not os.path.exists(out_dir): + os.makedirs(out_dir) + with open(os.path.join(test_path, path), "r") as in_f: + data = [] + sub = False + for line in in_f: + sub_flag, output_line = do_subs(path, line) + data.append(output_line) + if sub_flag: + sub = True + is_test = is_top_level_test(out_path, data) + + initial_path = out_path + + if is_test: + path_1 = add_suffix(out_path, "https") + else: + path_1 = out_path + + if sub: + path_2 = add_suffix(out_path, "sub") + else: + path_2 = path_1 + + if path_2 != initial_path: + path_changes[initial_path] = path_2 + + with open(path_2, "w") as out_f: + out_f.write("".join(data)) + + filename_changes = {} + + for k, v in path_changes.iteritems(): + if os.path.basename(k) in filename_changes: + print "Got duplicate name:" + os.path.basename(k) + filename_changes[os.path.basename(k)] = os.path.basename(v) + + for path in source_paths(work_path): + full_path = os.path.join(work_path, path) + with open(full_path, "r") as f: + data = sub_changed_filenames(filename_changes, f) + with open(full_path, "w") as f: + f.write(data) + + for dirpath, dirnames, filenames in os.walk(work_path): + for filename in filenames: + in_path = os.path.join(dirpath, filename) + rel_path = os.path.relpath(in_path, work_path) + copy(in_path, out_root, rel_path) + +if __name__ == "__main__": + main() -- cgit v1.2.3