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

Side by Side 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: Remove output set before setcookie. 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: Registration update()</title> 2 <title>Service Worker: Registration update()</title>
3 <script src="../resources/testharness.js"></script> 3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script> 5 <script src="resources/test-helpers.js"></script>
6 <script> 6 <script>
7 promise_test(function(t) { 7 promise_test(function(t) {
8 var scope = 'resources/scope/update'; 8 var scope = 'resources/scope/update';
9 var worker_url = 'resources/update-worker.php'; 9 var worker_url = 'resources/update-worker.php';
10 var expected_url = normalizeURL(worker_url); 10 var expected_url = normalizeURL(worker_url);
11 var registration; 11 var registration;
12 12
13 return service_worker_unregister_and_register(t, worker_url, scope) 13 return service_worker_unregister_and_register(t, worker_url, scope)
14 .then(function(r) { 14 .then(function(r) {
15 registration = r; 15 registration = r;
16 return wait_for_state(t, registration.installing, 'activated'); 16 return wait_for_state(t, registration.installing, 'activated');
17 }) 17 })
18 .then(function() { 18 .then(function() {
19 assert_equals(registration.installing, null, 19 assert_equals(registration.installing, null,
20 'installing should be null in the initial state'); 20 'installing should be null in the initial state.');
21 assert_equals(registration.waiting, null, 21 assert_equals(registration.waiting, null,
22 'waiting should be null in the initial state'); 22 'waiting should be null in the initial state.');
23 assert_equals(registration.active.scriptURL, expected_url, 23 assert_equals(registration.active.scriptURL, expected_url,
24 'active should exist in the initial state'); 24 'active should exist in the initial state.');
25 25
26 // A new worker should be found. 26 // A new worker (generated by update-worker.php) should be found.
27 registration.update(); 27 // The returned promise should resolve when a new worker script is
28 return wait_for_update(t, registration); 28 // fetched and starts installing.
29 return registration.update();
nhiroki 2015/08/10 02:32:42 To make sure that the updatefound event is correct
jungkees 2015/08/10 03:20:41 Addressed.
29 }) 30 })
30 .then(function() { 31 .then(function() {
31 assert_equals(registration.installing.scriptURL, expected_url, 32 assert_equals(registration.installing.scriptURL, expected_url,
32 'new installing should be set after updatefound'); 33 'new installing should be set after update resolves.');
33 assert_equals(registration.waiting, null, 34 assert_equals(registration.waiting, null,
34 'waiting should still be null after updatefound'); 35 'waiting should still be null after update resolves.');
35 assert_equals(registration.active.scriptURL, expected_url, 36 assert_equals(registration.active.scriptURL, expected_url,
36 'active should still exist after update found'); 37 'active should still exist after update found.');
37 return wait_for_state(t, registration.installing, 'installed'); 38 return wait_for_state(t, registration.installing, 'installed');
38 }) 39 })
39 .then(function() { 40 .then(function() {
40 assert_equals(registration.installing, null, 41 assert_equals(registration.installing, null,
41 'installing should be null after installing'); 42 'installing should be null after installing.');
42 assert_equals(registration.waiting.scriptURL, expected_url, 43 assert_equals(registration.waiting.scriptURL, expected_url,
43 'waiting should be set after installing'); 44 'waiting should be set after installing.');
44 assert_equals(registration.active.scriptURL, expected_url, 45 assert_equals(registration.active.scriptURL, expected_url,
45 'active should still exist after installing'); 46 'active should still exist after installing.');
46 return wait_for_state(t, registration.waiting, 'activated'); 47 return wait_for_state(t, registration.waiting, 'activated');
47 }) 48 })
48 .then(function() { 49 .then(function() {
49 assert_equals(registration.installing, null, 50 assert_equals(registration.installing, null,
50 'installing should be null after activated'); 51 'installing should be null after activated.');
51 assert_equals(registration.waiting, null, 52 assert_equals(registration.waiting, null,
52 'waiting should be null after activated'); 53 'waiting should be null after activated.');
53 assert_equals(registration.active.scriptURL, expected_url, 54 assert_equals(registration.active.scriptURL, expected_url,
54 'new worker should be promoted to active'); 55 'new worker should be promoted to active.');
56 })
57 .then(function() {
58 // A new worker(generated by update-worker.php) should be found.
59 // The returned promise should reject as update-worker.php sets the
60 // mimetype to a disallowed value for this attempt.
61 return registration.update();
62 })
63 .then(
64 function() { assert_unreached("update() should reject."); },
65 function(e) {
66 assert_throws('SecurityError', function() { throw e; },
67 'Using a disallowed mimetype should make update() ' +
68 'promise reject with a SecurityError.');
69 assert_equals(registration.active.scriptURL, expected_url,
70 'active should still exist after update failure.');
55 return service_worker_unregister_and_done(t, scope); 71 return service_worker_unregister_and_done(t, scope);
56 }) 72 })
57 }, 'Update a registration'); 73 .catch(unreached_rejection(t));;
nhiroki 2015/08/10 02:32:42 promise_test() does not have to have a 'catch' blo
jungkees 2015/08/10 03:20:41 Removed it. Thanks.
74 }, 'Update a registration.');
58 </script> 75 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698