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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/registration-service-worker-attributes.https.html

Issue 2893743003: Upstream service wrkr "registration" tests to WPT (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/registration-end-to-end.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="/resources/testharness.js"></script> 2 <script src="/resources/testharness.js"></script>
3 <script src="/resources/testharnessreport.js"></script> 3 <script src="/resources/testharnessreport.js"></script>
4 <script src="resources/test-helpers.sub.js"></script> 4 <script src="resources/test-helpers.sub.js"></script>
5 <script> 5 <script>
6 async_test(function(t) { 6 'use strict';
falken 2017/05/18 02:26:13 Are we going to add this to all the tests from now
7 promise_test(function(t) {
7 var scope = 'resources/scope/installing-waiting-active-after-registration'; 8 var scope = 'resources/scope/installing-waiting-active-after-registration';
8 var worker_url = 'resources/empty-worker.js'; 9 var worker_url = 'resources/empty-worker.js';
9 var expected_url = normalizeURL(worker_url); 10 var expected_url = normalizeURL(worker_url);
11 var newest_worker;
12 var registration;
10 13
11 service_worker_unregister_and_register(t, worker_url, scope) 14 return service_worker_unregister_and_register(t, worker_url, scope)
12 .then(function(r) { 15 .then(function(r) {
16 t.add_cleanup(function() {
17 r.unregister();
18 });
13 registration = r; 19 registration = r;
20 newest_worker = registration.installing;
14 assert_equals(registration.installing.scriptURL, expected_url, 21 assert_equals(registration.installing.scriptURL, expected_url,
15 'installing before updatefound'); 22 'installing before updatefound');
16 assert_equals(registration.waiting, null, 23 assert_equals(registration.waiting, null,
17 'waiting before updatefound'); 24 'waiting before updatefound');
18 assert_equals(registration.active, null, 25 assert_equals(registration.active, null,
19 'active before updatefound'); 26 'active before updatefound');
20 return wait_for_update(t, registration); 27 return wait_for_update(t, registration);
21 }) 28 })
22 .then(function(worker) { 29 .then(function() {
23 assert_equals(registration.installing.scriptURL, expected_url, 30 assert_equals(registration.installing, newest_worker,
24 'installing after updatefound'); 31 'installing after updatefound');
25 assert_equals(registration.waiting, null, 32 assert_equals(registration.waiting, null,
26 'waiting after updatefound'); 33 'waiting after updatefound');
27 assert_equals(registration.active, null, 34 assert_equals(registration.active, null,
28 'active after updatefound'); 35 'active after updatefound');
29 return wait_for_state(t, registration.installing, 'installed'); 36 return wait_for_state(t, registration.installing, 'installed');
30 }) 37 })
31 .then(function() { 38 .then(function() {
32 assert_equals(registration.installing, null, 39 assert_equals(registration.installing, null,
33 'installing after installed'); 40 'installing after installed');
34 var newest = registration.waiting || registration.active; 41 assert_equals(registration.waiting, newest_worker,
35 assert_equals(newest.scriptURL, expected_url, 42 'waiting after installed');
36 'waiting or active after installed'); 43 assert_equals(registration.active, null,
37 if (registration.waiting) { 44 'active after installed');
38 return wait_for_state(t, registration.waiting, 'activated') 45 return wait_for_state(t, registration.waiting, 'activated');
39 .then(function() {
40 assert_equals(registration.installing, null,
41 'installing after activated');
42 assert_equals(registration.waiting, null,
43 'waiting after activated');
44 assert_equals(registration.active.scriptURL, expected_url,
45 'active after activated');
46 });
47 }
48 }) 46 })
49 .then(function() { 47 .then(function() {
48 assert_equals(registration.installing, null,
49 'installing after activated');
50 assert_equals(registration.waiting, null,
51 'waiting after activated');
52 assert_equals(registration.active, newest_worker,
53 'active after activated');
50 return Promise.all([ 54 return Promise.all([
51 wait_for_state(t, registration.active, 'redundant'), 55 wait_for_state(t, registration.active, 'redundant'),
52 registration.unregister() 56 registration.unregister()
53 ]); 57 ]);
54 }) 58 })
55 .then(function() { 59 .then(function() {
56 assert_equals(registration.installing, null, 60 assert_equals(registration.installing, null,
57 'installing after redundant'); 61 'installing after redundant');
58 assert_equals(registration.waiting, null, 62 assert_equals(registration.waiting, null,
59 'waiting after redundant'); 63 'waiting after redundant');
60 // According to spec, Clear Registration runs Update State which is 64 // According to spec, Clear Registration runs Update State which is
61 // immediately followed by setting active to null, which means by the 65 // immediately followed by setting active to null, which means by the
62 // time the event loop turns and the Promise for statechange is 66 // time the event loop turns and the Promise for statechange is
63 // resolved, this will be gone. 67 // resolved, this will be gone.
64 assert_equals(registration.active, null, 68 assert_equals(registration.active, null,
65 'active should be null after redundant'); 69 'active should be null after redundant');
66 t.done(); 70 });
67 })
68 .catch(unreached_rejection(t));
69 }, 'installing/waiting/active after registration'); 71 }, 'installing/waiting/active after registration');
70 </script> 72 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/registration-end-to-end.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698