Bug 1597685 [wpt PR 20319] - [Background Sync] Update WPT tests., a=testonly

Automatic update from web-platform-tests
[Background Sync] Update WPT tests.

This CL:
1. Factors out Periodic Background Sync WPT tests in a separate directory
2. Adds a separate idl harness test for Periodic Background Sync,
3. Fixes a bug in periodicsync.https.window.js, in the setting of the scope.

Bug: 996664

Change-Id: I8653e8030880aa893d5d01e053b248828f88bbfc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1924196
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Rayan Kanso <rayankans@chromium.org>
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Auto-Submit: Mugdha Lakhani <nator@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717007}

--

wpt-commits: c42db5468b46bbf47b52a74fbcc9073980a39560
wpt-pr: 20319
This commit is contained in:
Mugdha Lakhani 2019-11-26 11:26:05 +00:00 коммит произвёл moz-wptsync-bot
Родитель 68951b2f38
Коммит 5de4d9ba20
5 изменённых файлов: 58 добавлений и 11 удалений

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

@ -11,13 +11,11 @@ idl_test(
idlArray => {
const isServiceWorker = location.pathname.includes('.serviceworker.');
if (isServiceWorker) {
idl_array.add_objects({
ServiceWorkerGlobalScope: ['self', 'onsync', 'onperiodicsync'],
idlArray.add_objects({
ServiceWorkerGlobalScope: ['self', 'onsync'],
ServiceWorkerRegistration: ['registration'],
SyncManager: ['registration.sync'],
PeriodicSyncManager: ['registration.periodicSync'],
SyncEevnt: ['new SyncEvent("tag", "lastChance")'],
PeriodicSyncEevnt: ['new PeriodicSyncEvent("tag")'],
SyncEvent: ['new SyncEvent("tag", "lastChance")'],
});
}
}

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

@ -14,7 +14,3 @@ self.addEventListener('message', event => {
self.addEventListener('sync', event => {
sendMessageToDocument('sync event received!');
});
self.addEventListener('periodicsync', event => {
sendMessageToDocument('periodicsync event received!');
});

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

@ -0,0 +1,38 @@
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
'use strict';
// https://github.com/WICG/BackgroundSync/blob/master/spec/PeriodicBackgroundSync-index.html
const idl = `
partial interface ServiceWorkerGlobalScope {
attribute EventHandler onperiodicsync;
};
[
Exposed=(Window,Worker)
] partial interface ServiceWorkerRegistration {
readonly attribute PeriodicSyncManager periodicSync;
readonly attribute SyncManager sync;
};
dictionary PeriodicSyncEventInit : ExtendableEventInit {
required DOMString tag;
};
[
Constructor(DOMString type, PeriodicSyncEventInit init),
Exposed=ServiceWorker
] interface PeriodicSyncEvent : ExtendableEvent {
readonly attribute DOMString tag;
};
`;
test(t => {
const idlArray = new IdlArray();
idlArray.add_idls(idl);
idlArray.add_objects({
ServiceWorkerGlobalScope: ['self', 'onperiodicsync'],
ServiceWorkerRegistration: ['registration'],
PeriodicSyncManager: ['registration.periodicSync'],
PeriodicSyncEvent: ['new PeriodicSyncEvent("tag")'],
});
}, 'IDL test for Periodic Background Sync');

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

@ -5,7 +5,7 @@
promise_test(async test => {
const script = 'service_workers/sw.js';
const scope = 'service_workers/' + location.pathname;
const scope = 'service_workers' + location.pathname;
const serviceWorkerRegistration =
await service_worker_unregister_and_register(test, script, scope);
@ -20,4 +20,3 @@ promise_test(async test => {
'test_tag'),
'register() must reject on pending and installing workers');
}, 'Periodic Background Sync requires an activated Service Worker');

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

@ -0,0 +1,16 @@
// 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('periodicsync', event => {
sendMessageToDocument('periodicsync event received!');
});