| Index: content/test/data/service_worker/sync.js
|
| diff --git a/content/test/data/service_worker/sync.js b/content/test/data/service_worker/sync.js
|
| index 993e771778a505bc5ff78dedbe29a9d5655026fd..4f16b995fcbb15ac05217b775e19627e7cd2cb5a 100644
|
| --- a/content/test/data/service_worker/sync.js
|
| +++ b/content/test/data/service_worker/sync.js
|
| @@ -2,9 +2,20 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -var code = 404;
|
| +var sawSyncEvent = false;
|
| +var fetchCount = 0;
|
| +
|
| +// onfetch is a state machine:
|
| +// 1st call returns 404 and calls requestSyncEvents()
|
| +// .. sync doesn't fire ..
|
| +// 2nd call returns 404 and calls requestSyncEvents(true)
|
| +// .. sync fires ..
|
| +// 3rd call returns 200 and calls requestSyncEvents(false)
|
| +// .. sync doesn't fire ..
|
| +// 4th call returns 404
|
|
|
| this.onfetch = function(event) {
|
| + var code = sawSyncEvent ? 200 : 404;
|
| response = new Response({
|
| statusCode: code,
|
| statusText: 'OK',
|
| @@ -18,8 +29,19 @@ this.onfetch = function(event) {
|
| event.respondWith(new Promise(function(r) {
|
| setTimeout(function() { r(response); }, 5);
|
| }));
|
| +
|
| + if (fetchCount == 0) {
|
| + requestSyncEvents();
|
| + } else if (fetchCount == 1) {
|
| + requestSyncEvents(true);
|
| + } else if (fetchCount == 2) {
|
| + requestSyncEvents(false);
|
| + }
|
| +
|
| + fetchCount += 1;
|
| + sawSyncEvent = false;
|
| };
|
|
|
| this.onsync = function(event) {
|
| - code = 200;
|
| + sawSyncEvent = true;
|
| };
|
|
|