OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // The ResultQueue is a mechanism for passing messages back to the test | 7 // The ResultQueue is a mechanism for passing messages back to the test |
8 // framework. | 8 // framework. |
9 var resultQueue = new ResultQueue(); | 9 var resultQueue = new ResultQueue(); |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 function replaceServiceWorker() { | 62 function replaceServiceWorker() { |
63 navigator.serviceWorker.register('service_worker_with_skipWaiting_claim.js', { | 63 navigator.serviceWorker.register('service_worker_with_skipWaiting_claim.js', { |
64 scope: './' | 64 scope: './' |
65 }).then(swRegistrationReady).then(() => { | 65 }).then(swRegistrationReady).then(() => { |
66 sendResultToTest('ok - service worker replaced'); | 66 sendResultToTest('ok - service worker replaced'); |
67 }).catch(sendErrorToTest); | 67 }).catch(sendErrorToTest); |
68 } | 68 } |
69 | 69 |
70 function removeManifest() { | 70 function removeManifest() { |
71 var element = document.querySelector('link[rel="manifest"]'); | 71 var element = document.querySelector('link[rel="manifest"]'); |
72 if (element) { | 72 if (element) |
73 element.parentNode.removeChild(element); | 73 element.parentNode.removeChild(element); |
74 sendResultToTest('manifest removed'); | 74 sendResultToTest('manifest removed'); |
75 } else { | |
76 sendResultToTest('unable to find manifest element'); | |
77 } | |
78 } | 75 } |
79 | 76 |
80 function swapManifestNoSenderId() { | 77 function swapManifestNoSenderId() { |
81 var element = document.querySelector('link[rel="manifest"]'); | 78 var element = document.querySelector('link[rel="manifest"]'); |
82 if (element) { | 79 if (element) { |
83 element.href = 'manifest_no_sender_id.json'; | 80 element.href = 'manifest_no_sender_id.json'; |
84 sendResultToTest('sender id removed from manifest'); | 81 sendResultToTest('sender id removed from manifest'); |
85 } else { | 82 } else { |
86 sendResultToTest('unable to find manifest element'); | 83 sendResultToTest('unable to find manifest element'); |
87 } | 84 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 }).catch(sendErrorToTest); | 221 }).catch(sendErrorToTest); |
225 } | 222 } |
226 | 223 |
227 navigator.serviceWorker.addEventListener('message', function(event) { | 224 navigator.serviceWorker.addEventListener('message', function(event) { |
228 var message = JSON.parse(event.data); | 225 var message = JSON.parse(event.data); |
229 if (message.type == 'push') | 226 if (message.type == 'push') |
230 resultQueue.push(message.data); | 227 resultQueue.push(message.data); |
231 else | 228 else |
232 sendResultToTest(message.data); | 229 sendResultToTest(message.data); |
233 }, false); | 230 }, false); |
OLD | NEW |