Bug 1561194 [wpt PR 17347] - [Background Sync] Periodic Background Sync idl, a=testonly

Automatic update from web-platform-tests
[Background Sync] Periodic Background Sync idl

changes + few WPT and web_tests.

Bug: 925297

Change-Id: I5c8833e236f7cf9b2993e69494ec4dc9797f7120
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1660446
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Rayan Kanso <rayankans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#671726}

--

wpt-commits: 38ca23981b8b2227e47a497d5952503202350e38
wpt-pr: 17347
This commit is contained in:
Mugdha Lakhani 2019-07-19 14:07:41 +00:00 коммит произвёл James Graham
Родитель 7272ca0c98
Коммит cebe583a38
2 изменённых файлов: 43 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,23 @@
// META: script=/common/get-host-info.sub.js
// META: script=/service-workers/service-worker/resources/test-helpers.sub.js
'use strict'
promise_test(async test => {
const script = 'service_workers/sw.js';
const scope = 'service_workers/' + location.pathname;
const serviceWorkerRegistration =
await service_worker_unregister_and_register(test, script, scope);
assert_equals(
serviceWorkerRegistration.active, null,
'There must not be an activated worker');
await promise_rejects(
test, new DOMException('', 'InvalidStateError'),
serviceWorkerRegistration.periodicSync.register(
'test_tag'),
'register() must reject on pending and installing workers');
}, 'Periodic Background Sync requires an activated Service Worker');

Просмотреть файл

@ -0,0 +1,20 @@
// The source to post setup and completion results to.
let source = null;
function sendMessageToDocument(msg) {
source.postMessage(msg);
}
// Notify the document that the SW is registered and ready.
self.addEventListener('message', event => {
source = event.source;
sendMessageToDocument('ready');
});
self.addEventListener('sync', event => {
sendMessageToDocument('sync event received!');
});
self.addEventListener('periodicsync', event => {
sendMessageToDocument('periodicsync event received!');
});