Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/update.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/update.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/update.html |
| index 61a8a2dfba6db07c3e7c9bf7f93ddae77365578d..b43168f2bdfd5e50a4555b9582f2fbf67aa4199a 100644 |
| --- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/update.html |
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/update.html |
| @@ -9,7 +9,7 @@ promise_test(function(t) { |
| var worker_url = 'resources/update-worker.php'; |
| var expected_url = normalizeURL(worker_url); |
| var registration; |
| - |
| + var iframe; |
| return service_worker_unregister_and_register(t, worker_url, scope) |
| .then(function(r) { |
| registration = r; |
| @@ -69,7 +69,58 @@ promise_test(function(t) { |
| 'promise reject with a SecurityError.'); |
| assert_equals(registration.active.scriptURL, expected_url, |
| 'active should still exist after update failure.'); |
| - return service_worker_unregister_and_done(t, scope); |
| + |
| + // A new worker(generated by update-worker.py) should be found. |
| + // The returned promise should reject as update-worker.py returns |
| + // a worker script with a syntax error. |
| + return registration.update(); |
| + }) |
| + .then( |
| + function() { assert_unreached("update() should reject."); }, |
| + function(e) { |
| + assert_throws({name: 'TypeError'}, function () { throw e; }, |
| + 'A script syntax error should make update() ' + |
| + 'promise reject with a TypeError.'); |
| + assert_equals(registration.active.scriptURL, expected_url, |
| + 'active should still exist after update failure.'); |
| + |
| + // A new worker(generated by update-worker.py) should be found. |
| + // The returned promise should not reject, even though |
| + // update-worker.py returns a worker script that throws in the |
| + // install event handler. |
| + return Promise.all([registration.update(), |
| + wait_for_update(t, registration)]); |
| + }) |
| + .then(function() { |
| + assert_equals(registration.installing.scriptURL, expected_url, |
| + 'new installing should be set after update resolves.'); |
|
falken
2016/06/20 08:41:14
nit: it's better to make description strings uniqu
e_hakkinen
2016/07/05 18:28:59
Done.
|
| + assert_equals(registration.waiting, null, |
| + 'waiting should be null after activated.'); |
|
falken
2016/06/20 08:41:14
ditto, the "activated" part also seems inaccurate
e_hakkinen
2016/07/05 18:28:59
Done.
|
| + assert_equals(registration.active.scriptURL, expected_url, |
| + 'active should still exist after update found.'); |
| + |
| + // We need to hold a client alive so that unregister() below doesn't |
| + // remove the registration before update() has had a chance to look |
| + // at the pending uninstall flag. |
| + return with_iframe(scope); |
| + }) |
| + .then(function(frame) { |
| + iframe = frame; |
| + |
| + return Promise.all([registration.unregister(), |
| + registration.update()]); |
| + }) |
| + .then( |
| + function() { assert_unreached("update() should reject."); }, |
| + function(e) { |
| + assert_throws({name: 'TypeError'}, function () { throw e; }, |
| + 'Calling update() while the uninstalling flag is ' + |
| + 'set should return a promise that rejects with an ' + |
| + 'TypeError.'); |
| + }) |
| + .then(function() { |
| + iframe.remove(); |
|
falken
2016/06/20 08:41:14
nit: this can be removed since with_iframe automat
e_hakkinen
2016/07/05 18:28:59
Done.
|
| + return t.done(); |
|
falken
2016/06/20 08:41:14
nit: t.done() isn't needed since this is a promise
e_hakkinen
2016/07/05 18:29:00
Done.
|
| }); |
| }, 'Update a registration.'); |
| </script> |