Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/appcache-ordering-main.html |
| diff --git a/LayoutTests/http/tests/serviceworker/appcache-ordering-main.html b/LayoutTests/http/tests/serviceworker/appcache-ordering-main.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a4a1b253d890c1ed9c7af19a6bb6ecfd8b773f70 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/serviceworker/appcache-ordering-main.html |
| @@ -0,0 +1,81 @@ |
| +<!DOCTYPE html> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="resources/test-helpers.js"></script> |
| +<body> |
| +<script> |
| + |
| +var INSTALL_APPCACHE_URL = "resources/appcache-ordering.install.html"; |
| +var IS_APPCACHED_URL = "resources/appcache-ordering.is-appcached.html"; |
| +var SERVICE_WORKER_SCOPE = "resources/appcache-ordering" |
| +var SERVICE_WORKER_SCRIPT = "resources/empty-worker.js" |
| + |
| +var resolve_install_appcache = undefined; |
| +var reject_install_appcache = undefined; |
| + |
| +function notifyAppCacheInstalled(success) { |
|
falken
2014/10/21 01:28:30
should be snake_case
michaeln
2014/10/21 02:30:12
Done.
|
| + if (success) |
| + resolve_install_appcache(); |
| + else |
| + reject_install_appcache(); |
| +} |
| + |
| +function install_appcache() { |
| + 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.
|
| + resolve_install_appcache = resolve; |
| + reject_install_appcache = reject; |
| + var frame = document.createElement('iframe'); |
| + frame.src = INSTALL_APPCACHE_URL; |
| + document.body.appendChild(frame); |
| + }); |
| +} |
| + |
| +var resolve_is_appcached = undefined; |
| +var reject_is_appcached = undefined; |
| + |
| +function notifyIsAppCached(is) { |
|
falken
2014/10/21 01:28:31
snake_case
michaeln
2014/10/21 02:30:12
Done.
|
| + if (is) |
| + resolve_is_appcached(); |
| + else |
| + reject_is_appcached(); |
| +} |
| + |
| +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.
|
| + return new Promise(function(resolve, reject) { |
| + resolve_is_appcached = resolve; |
| + reject_is_appcached = reject; |
| + var frame = document.createElement('iframe'); |
| + frame.src = IS_APPCACHED_URL; |
| + document.body.appendChild(frame); |
| + }); |
| +} |
| + |
| +function is_not_appcached() { |
| + return new Promise(function(resolve, reject) { |
| + resolve_is_appcached = reject; |
| + reject_is_appcached = resolve; |
| + var frame = document.createElement('iframe'); |
| + frame.src = IS_APPCACHED_URL; |
| + document.body.appendChild(frame); |
| + }); |
| +} |
| + |
| +async_test(function(t) { |
| + install_appcache() |
| + .then(function () { |
|
falken
2014/10/21 01:28:31
nit: no space before parens
michaeln
2014/10/21 02:30:12
Done.
|
| + return is_appcached(); |
| + }) |
| + .then(function (f) { |
| + return service_worker_unregister_and_register( |
| + t, SERVICE_WORKER_SCRIPT, SERVICE_WORKER_SCOPE); |
| + }) |
| + .then(function (r) { |
| + return is_not_appcached(); |
| + }) |
| + .then(function (f) { |
| + service_worker_unregister_and_done(t, SERVICE_WORKER_SCOPE); |
| + }); |
|
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
|
| + }, 'serviceworkers take priority over appcaches'); |
| + |
| +</script> |
| +</body> |