OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script> | 2 <script> |
3 // See ServiceWorkerBrowserTest ImportsBustMemcache. | 3 // See ServiceWorkerBrowserTest CrossSiteTransfer. |
4 // Content-Shell data persists so unregister first to clear old data. | 4 // Content-Shell data persists so unregister first to clear old data. |
5 // Register, unregister, then reregister. The browsertest examines the | 5 // Register, unregister, then reregister. The browsertest examines the |
6 // state of the scriptcache to ensure the script and import are cached. | 6 // state of the scriptcache to ensure the script and import are cached. |
7 | 7 |
8 var scope = 'imports_bust_memcache_scope/'; | 8 var scope = 'cross_site_xfer_scope/'; |
9 var script = 'worker_with_one_import.js'; | 9 var script = 'cross_site_xfer.js'; |
10 | 10 |
11 navigator.serviceWorker.getRegistration(scope) | 11 navigator.serviceWorker.getRegistration(scope) |
12 .then(function(registration) { | 12 .then(function(registration) { |
13 if (registration) | 13 if (registration) |
14 return registration.unregister(); | 14 return registration.unregister(); |
15 }) | 15 }) |
16 .then(function(_) { | 16 .then(function(_) { |
17 console.log('initial unregistration done'); | 17 console.log('initial unregistration done'); |
18 return navigator.serviceWorker.register(script, {scope: scope}); | 18 return navigator.serviceWorker.register(script, {scope: scope}); |
19 }) | 19 }) |
20 .then(function(registration) { | 20 .then(function(registration) { |
21 console.log('initial registration done'); | 21 console.log('initial registration done'); |
22 return registration.unregister(); | 22 return registration.unregister(); |
23 }) | 23 }) |
24 .then(function(_) { | 24 .then(function(_) { |
25 console.log('unregistration done'); | 25 console.log('unregistration done'); |
26 return navigator.serviceWorker.register(script, {scope: scope}); | 26 return navigator.serviceWorker.register(script, {scope: scope}); |
27 }) | 27 }) |
28 .then(function(_) { | 28 .then(function(_) { |
29 console.log('second registration done'); | 29 console.log('second registration done'); |
30 document.title = 'OK'; // Titlewatcher looks for this. | 30 document.title = 'OK_1'; // TitleWatcher looks for this. |
31 }) | 31 }) |
32 .catch(function(e) { | 32 .catch(function(e) { |
33 document.title = 'FAILED'; | 33 document.title = 'FAIL_1'; |
34 }); | 34 }); |
35 </script> | 35 </script> |
OLD | NEW |