| <!doctype html> |
| <html> |
| <head> |
| <meta charset="utf-8" /> |
| <title>BackgroundFetchBrowserTest helper page</title> |
| <script src="../format_error.js"></script> |
| <script> |
| const kBackgroundFetchId = 'bg-fetch-id'; |
| const kBackgroundFetchResource = [ '/background_fetch/types_of_cheese.txt' ]; |
| |
| function RegisterServiceWorker() { |
| return navigator.serviceWorker.register('sw.js').then(() => { |
| return 'ok - service worker registered'; |
| }).catch(formatError); |
| } |
| |
| // Starts a Background Fetch request for a single to-be-downloaded file. |
| function StartSingleFileDownload() { |
| return navigator.serviceWorker.ready.then(swRegistration => { |
| const options = { |
| title: 'Single-file Background Fetch' |
| }; |
| return swRegistration.backgroundFetch.fetch( |
| kBackgroundFetchId, kBackgroundFetchResource, options); |
| }).then(bgFetchRegistration => { |
| return 'ok'; |
| }).catch(formatError); |
| } |
| </script> |
| </head> |
| <body> |
| </body> |
| </html> |