Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: content/test/data/background_sync/background_sync_test_helpers.js

Issue 1282013004: BackgroundSyncManager tracks client registrations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed test Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 var resultQueue = new ResultQueue(); 7 var resultQueue = new ResultQueue();
8 8
9 // Sends data back to the test. This must be in response to an earlier 9 // Sends data back to the test. This must be in response to an earlier
10 // request, but it's ok to respond asynchronously. The request blocks until 10 // request, but it's ok to respond asynchronously. The request blocks until
(...skipping 24 matching lines...) Expand all
35 navigator.serviceWorker.ready 35 navigator.serviceWorker.ready
36 .then(function(swRegistration) { 36 .then(function(swRegistration) {
37 return swRegistration.sync.register({'tag': tag}); 37 return swRegistration.sync.register({'tag': tag});
38 }) 38 })
39 .then(function(syncRegistration) { 39 .then(function(syncRegistration) {
40 sendResultToTest('ok - ' + tag + ' registered'); 40 sendResultToTest('ok - ' + tag + ' registered');
41 }) 41 })
42 .catch(sendErrorToTest); 42 .catch(sendErrorToTest);
43 } 43 }
44 44
45 function unregisterOneShot(tag) {
46 navigator.serviceWorker.ready
47 .then(function(swRegistration) {
48 return swRegistration.sync.getRegistration(tag);
49 })
50 .then(function(syncRegistration) {
51 if (!syncRegistration) {
52 sendResultToTest('error - ' + tag + ' not found');
53 return;
54 }
55 return syncRegistration.unregister();
56 })
57 .then(function() {
58 sendResultToTest('ok - ' + tag + ' unregistered');
59 })
60 .catch(sendErrorToTest);
61 }
62
63 function unregisterOneShotTwice(tag) {
64 navigator.serviceWorker.ready
65 .then(function(swRegistration) {
66 return swRegistration.sync.getRegistration(tag);
67 })
68 .then(function(syncRegistration) {
69 if (!syncRegistration) {
70 sendResultToTest('error - ' + tag + ' not found');
71 return;
72 }
73 return syncRegistration.unregister();
74 })
75 .then(function() {
76 return syncRegistration.unregister();
77 })
78 .then(sendErrorToTest, function() {
79 sendResultToTest('ok - ' + tag + ' failed to unregister twice');
80 })
81 .catch(sendErrorToTest);
82 }
83
45 function getRegistrationOneShot(tag) { 84 function getRegistrationOneShot(tag) {
46 navigator.serviceWorker.ready 85 navigator.serviceWorker.ready
47 .then(function(swRegistration) { 86 .then(function(swRegistration) {
48 return swRegistration.sync.getRegistration(tag); 87 return swRegistration.sync.getRegistration(tag);
49 }) 88 })
50 .then(function(syncRegistration) { 89 .then(function(syncRegistration) {
51 if (!syncRegistration) { 90 if (!syncRegistration) {
52 sendResultToTest('error - ' + tag + ' not found'); 91 sendResultToTest('error - ' + tag + ' not found');
53 return; 92 return;
54 } 93 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // available, otherwise sends null. 161 // available, otherwise sends null.
123 ResultQueue.prototype.popImmediately = function() { 162 ResultQueue.prototype.popImmediately = function() {
124 sendResultToTest(this.queue.length ? this.queue.pop() : null); 163 sendResultToTest(this.queue.length ? this.queue.pop() : null);
125 }; 164 };
126 165
127 navigator.serviceWorker.addEventListener('message', function(event) { 166 navigator.serviceWorker.addEventListener('message', function(event) {
128 var message = event.data; 167 var message = event.data;
129 if (message.type == 'sync') 168 if (message.type == 'sync')
130 resultQueue.push(message.data); 169 resultQueue.push(message.data);
131 }, false); 170 }, false);
OLDNEW
« no previous file with comments | « content/renderer/service_worker/service_worker_context_client.cc ('k') | content/test/data/background_sync/service_worker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698