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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/update.html

Issue 2054203002: service worker: Fix the type of an update promise reject value (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Error handling unification Created 4 years, 6 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 var iframe;
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.');
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return registration.update(); 62 return registration.update();
63 }) 63 })
64 .then( 64 .then(
65 function() { assert_unreached("update() should reject."); }, 65 function() { assert_unreached("update() should reject."); },
66 function(e) { 66 function(e) {
67 assert_throws('SecurityError', function() { throw e; }, 67 assert_throws('SecurityError', function() { throw e; },
68 'Using a disallowed mimetype should make update() ' + 68 'Using a disallowed mimetype should make update() ' +
69 'promise reject with a SecurityError.'); 69 'promise reject with a SecurityError.');
70 assert_equals(registration.active.scriptURL, expected_url, 70 assert_equals(registration.active.scriptURL, expected_url,
71 'active should still exist after update failure.'); 71 'active should still exist after update failure.');
72 return service_worker_unregister_and_done(t, scope); 72
73 // A new worker(generated by update-worker.py) should be found.
74 // The returned promise should reject as update-worker.py returns
75 // a worker script with a syntax error.
76 return registration.update();
77 })
78 .then(
79 function() { assert_unreached("update() should reject."); },
80 function(e) {
81 assert_throws({name: 'TypeError'}, function () { throw e; },
82 'A script syntax error should make update() ' +
83 'promise reject with a TypeError.');
84 assert_equals(registration.active.scriptURL, expected_url,
85 'active should still exist after update failure.');
86
87 // A new worker(generated by update-worker.py) should be found.
88 // The returned promise should not reject, even though
89 // update-worker.py returns a worker script that throws in the
90 // install event handler.
91 return Promise.all([registration.update(),
92 wait_for_update(t, registration)]);
93 })
94 .then(function() {
95 assert_equals(registration.installing.scriptURL, expected_url,
96 '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.
97 assert_equals(registration.waiting, null,
98 '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.
99 assert_equals(registration.active.scriptURL, expected_url,
100 'active should still exist after update found.');
101
102 // We need to hold a client alive so that unregister() below doesn't
103 // remove the registration before update() has had a chance to look
104 // at the pending uninstall flag.
105 return with_iframe(scope);
106 })
107 .then(function(frame) {
108 iframe = frame;
109
110 return Promise.all([registration.unregister(),
111 registration.update()]);
112 })
113 .then(
114 function() { assert_unreached("update() should reject."); },
115 function(e) {
116 assert_throws({name: 'TypeError'}, function () { throw e; },
117 'Calling update() while the uninstalling flag is ' +
118 'set should return a promise that rejects with an ' +
119 'TypeError.');
120 })
121 .then(function() {
122 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.
123 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.
73 }); 124 });
74 }, 'Update a registration.'); 125 }, 'Update a registration.');
75 </script> 126 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698