Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Unified Diff: LayoutTests/http/tests/serviceworker/update.html

Issue 1268663003: Service Worker: Make ServiceWorkerRegistration.update() return a promise. (Blink Layout 3/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/serviceworker/update.html
diff --git a/LayoutTests/http/tests/serviceworker/update.html b/LayoutTests/http/tests/serviceworker/update.html
index 9eb392a9898336b51f14b1d476611b9d50b2046c..61a8a2dfba6db07c3e7c9bf7f93ddae77365578d 100644
--- a/LayoutTests/http/tests/serviceworker/update.html
+++ b/LayoutTests/http/tests/serviceworker/update.html
@@ -17,42 +17,59 @@ promise_test(function(t) {
})
.then(function() {
assert_equals(registration.installing, null,
- 'installing should be null in the initial state');
+ 'installing should be null in the initial state.');
assert_equals(registration.waiting, null,
- 'waiting should be null in the initial state');
+ 'waiting should be null in the initial state.');
assert_equals(registration.active.scriptURL, expected_url,
- 'active should exist in the initial state');
+ 'active should exist in the initial state.');
- // A new worker should be found.
- registration.update();
- return wait_for_update(t, registration);
+ // A new worker (generated by update-worker.php) should be found.
+ // The returned promise should resolve when a new worker script is
+ // fetched and starts installing.
+ 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 updatefound');
+ 'new installing should be set after update resolves.');
assert_equals(registration.waiting, null,
- 'waiting should still be null after updatefound');
+ 'waiting should still be null after update resolves.');
assert_equals(registration.active.scriptURL, expected_url,
- 'active should still exist after update found');
+ 'active should still exist after update found.');
return wait_for_state(t, registration.installing, 'installed');
})
.then(function() {
assert_equals(registration.installing, null,
- 'installing should be null after installing');
+ 'installing should be null after installing.');
assert_equals(registration.waiting.scriptURL, expected_url,
- 'waiting should be set after installing');
+ 'waiting should be set after installing.');
assert_equals(registration.active.scriptURL, expected_url,
- 'active should still exist after installing');
+ 'active should still exist after installing.');
return wait_for_state(t, registration.waiting, 'activated');
})
.then(function() {
assert_equals(registration.installing, null,
- 'installing should be null after activated');
+ 'installing should be null after activated.');
assert_equals(registration.waiting, null,
- 'waiting should be null after activated');
+ 'waiting should be null after activated.');
assert_equals(registration.active.scriptURL, expected_url,
- 'new worker should be promoted to active');
- return service_worker_unregister_and_done(t, scope);
+ 'new worker should be promoted to active.');
+ })
+ .then(function() {
+ // A new worker(generated by update-worker.php) should be found.
+ // The returned promise should reject as update-worker.php sets the
+ // mimetype to a disallowed value for this attempt.
+ return registration.update();
})
- }, 'Update a registration');
+ .then(
+ function() { assert_unreached("update() should reject."); },
+ function(e) {
+ assert_throws('SecurityError', function() { throw e; },
+ 'Using a disallowed mimetype should make update() ' +
+ '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);
+ });
+ }, 'Update a registration.');
</script>

Powered by Google App Engine
This is Rietveld 408576698