| OLD | NEW |
| 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 function initialize() { | 5 function initialize() { |
| 6 navigator.serviceWorker.register('service_worker.js'); | 6 navigator.serviceWorker.register('service_worker.js'); |
| 7 | 7 |
| 8 window.addEventListener('appinstalled', () => { | 8 window.addEventListener('appinstalled', () => { |
| 9 window.document.title = 'Got appinstalled'; | 9 window.document.title = 'Got appinstalled'; |
| 10 }); | 10 }); |
| 11 } | 11 } |
| 12 | 12 |
| 13 function addManifestLinkTag() { | 13 function addManifestLinkTag() { |
| 14 var url = window.location.href; | 14 var url = window.location.href; |
| 15 var manifestIndex = url.indexOf("?manifest="); | 15 var manifestIndex = url.indexOf("?manifest="); |
| 16 var manifestUrl = | 16 var manifestUrl = |
| 17 (manifestIndex >= 0) ? url.slice(manifestIndex + 10) : 'manifest.json'; | 17 (manifestIndex >= 0) ? url.slice(manifestIndex + 10) : 'manifest.json'; |
| 18 var linkTag = document.createElement("link"); | 18 var linkTag = document.createElement("link"); |
| 19 linkTag.rel = "manifest"; | 19 linkTag.rel = "manifest"; |
| 20 linkTag.href = manifestUrl; | 20 linkTag.href = manifestUrl; |
| 21 document.head.append(linkTag); | 21 document.head.append(linkTag); |
| 22 } | 22 } |
| 23 |
| 24 function getSwDelay() { |
| 25 // Allow the test page to set a custom delay (required since desktop is |
| 26 // faster than Android and hence needs a longer delay). |
| 27 var url = window.location.href; |
| 28 var swDelayIndex = url.indexOf("?swdelay="); |
| 29 return (swDelayIndex >= 0) ? url.slice(swDelayIndex + 9) : 300; |
| 30 } |
| OLD | NEW |