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" | |
| 12 | |
| 13 var resolve_install_appcache = undefined; | |
| 14 var reject_install_appcache = undefined; | |
| 15 | |
| 16 function notifyAppCacheInstalled(success) { | |
|
falken
2014/10/21 01:28:30
should be snake_case
michaeln
2014/10/21 02:30:12
Done.
| |
| 17 if (success) | |
| 18 resolve_install_appcache(); | |
| 19 else | |
| 20 reject_install_appcache(); | |
| 21 } | |
| 22 | |
| 23 function install_appcache() { | |
| 24 return new Promise(function(resolve, reject) { | |
|
falken
2014/10/21 01:28:30
nit: this line should be a two-space indent, as it
michaeln
2014/10/21 02:30:12
Done.
| |
| 25 resolve_install_appcache = resolve; | |
| 26 reject_install_appcache = reject; | |
| 27 var frame = document.createElement('iframe'); | |
| 28 frame.src = INSTALL_APPCACHE_URL; | |
| 29 document.body.appendChild(frame); | |
| 30 }); | |
| 31 } | |
| 32 | |
| 33 var resolve_is_appcached = undefined; | |
| 34 var reject_is_appcached = undefined; | |
| 35 | |
| 36 function notifyIsAppCached(is) { | |
|
falken
2014/10/21 01:28:31
snake_case
michaeln
2014/10/21 02:30:12
Done.
| |
| 37 if (is) | |
| 38 resolve_is_appcached(); | |
| 39 else | |
| 40 reject_is_appcached(); | |
| 41 } | |
| 42 | |
| 43 function is_appcached() { | |
|
falken
2014/10/21 01:28:31
Would it be an improvement for is_appcached and is
michaeln
2014/10/21 02:14:10
duh... sure would ;)
michaeln
2014/10/21 02:30:12
Done.
| |
| 44 return new Promise(function(resolve, reject) { | |
| 45 resolve_is_appcached = resolve; | |
| 46 reject_is_appcached = reject; | |
| 47 var frame = document.createElement('iframe'); | |
| 48 frame.src = IS_APPCACHED_URL; | |
| 49 document.body.appendChild(frame); | |
| 50 }); | |
| 51 } | |
| 52 | |
| 53 function is_not_appcached() { | |
| 54 return new Promise(function(resolve, reject) { | |
| 55 resolve_is_appcached = reject; | |
| 56 reject_is_appcached = resolve; | |
| 57 var frame = document.createElement('iframe'); | |
| 58 frame.src = IS_APPCACHED_URL; | |
| 59 document.body.appendChild(frame); | |
| 60 }); | |
| 61 } | |
| 62 | |
| 63 async_test(function(t) { | |
| 64 install_appcache() | |
| 65 .then(function () { | |
|
falken
2014/10/21 01:28:31
nit: no space before parens
michaeln
2014/10/21 02:30:12
Done.
| |
| 66 return is_appcached(); | |
| 67 }) | |
| 68 .then(function (f) { | |
| 69 return service_worker_unregister_and_register( | |
| 70 t, SERVICE_WORKER_SCRIPT, SERVICE_WORKER_SCOPE); | |
| 71 }) | |
| 72 .then(function (r) { | |
| 73 return is_not_appcached(); | |
| 74 }) | |
| 75 .then(function (f) { | |
| 76 service_worker_unregister_and_done(t, SERVICE_WORKER_SCOPE); | |
| 77 }); | |
|
falken
2014/10/21 01:28:30
need a .catch(unreached_rejection(t)) at the end
michaeln
2014/10/21 02:14:10
why cleanup iframes?
michaeln
2014/10/21 02:30:12
Done
falken
2014/10/21 02:30:22
I think it's a principle of W3C web platform tests
| |
| 78 }, 'serviceworkers take priority over appcaches'); | |
| 79 | |
| 80 </script> | |
| 81 </body> | |
| OLD | NEW |