Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <script src="resources/test-helpers.js"></script> | |
| 5 <body> | |
| 6 <script> | |
| 7 | |
| 8 var INSTALL_APPCACHE_URL = "resources/appcache-ordering.install.html"; | |
| 9 var IS_APPCACHED_URL = "resources/appcache-ordering.is-appcached.html"; | |
| 10 var SERVICE_WORKER_SCOPE = "resources/appcache-ordering" | |
| 11 var SERVICE_WORKER_SCRIPT = "resources/empty-worker.js" | |
|
falken
2014/10/21 01:28:31
nit: missing semi-colons in lines 10-11
| |
| 12 | |
| 13 var resolve_install_appcache = undefined; | |
| 14 var reject_install_appcache = undefined; | |
| 15 | |
| 16 // Called by the INSTALL_APPCACHE_URL child frame. | |
| 17 function notifyAppCacheInstalled(success) { | |
| 18 if (success) | |
| 19 resolve_install_appcache(); | |
| 20 else | |
| 21 reject_install_appcache(); | |
| 22 } | |
| 23 | |
| 24 function install_appcache() { | |
| 25 return new Promise(function(resolve, reject) { | |
| 26 resolve_install_appcache = resolve; | |
| 27 reject_install_appcache = reject; | |
| 28 var frame = document.createElement('iframe'); | |
| 29 frame.src = INSTALL_APPCACHE_URL; | |
| 30 document.body.appendChild(frame); | |
| 31 }); | |
| 32 } | |
| 33 | |
| 34 var resolve_is_appcached = undefined; | |
| 35 var reject_is_appcached = undefined; | |
| 36 | |
| 37 // Called by the IS_APPCACHED_URL child frame. | |
| 38 function notifyIsAppCached(is) { | |
| 39 if (is) | |
| 40 resolve_is_appcached(); | |
| 41 else | |
| 42 reject_is_appcached(); | |
| 43 } | |
| 44 | |
| 45 function is_appcached() { | |
| 46 return new Promise(function(resolve, reject) { | |
| 47 resolve_is_appcached = resolve; | |
| 48 reject_is_appcached = reject; | |
| 49 var frame = document.createElement('iframe'); | |
| 50 frame.src = IS_APPCACHED_URL; | |
| 51 document.body.appendChild(frame); | |
| 52 }); | |
| 53 } | |
| 54 | |
| 55 function is_not_appcached() { | |
| 56 return new Promise(function(resolve, reject) { | |
| 57 // Reversed to test for the not cached condition. | |
| 58 resolve_is_appcached = reject; | |
| 59 reject_is_appcached = resolve; | |
| 60 var frame = document.createElement('iframe'); | |
| 61 frame.src = IS_APPCACHED_URL; | |
| 62 document.body.appendChild(frame); | |
| 63 }); | |
| 64 } | |
| 65 | |
| 66 async_test(function(t) { | |
| 67 install_appcache() | |
| 68 .then(function () { | |
| 69 return is_appcached(); | |
| 70 }) | |
| 71 .then(function () { | |
| 72 return service_worker_unregister_and_register( | |
| 73 t, SERVICE_WORKER_SCRIPT, SERVICE_WORKER_SCOPE); | |
| 74 }) | |
| 75 .then(function () { | |
| 76 return is_not_appcached(); | |
| 77 }) | |
| 78 .then(function () { | |
| 79 service_worker_unregister_and_done(t, SERVICE_WORKER_SCOPE); | |
| 80 }); | |
| 81 }, 'serviceworkers take priority over appcaches'); | |
| 82 | |
| 83 </script> | |
| 84 </body> | |
| OLD | NEW |