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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/multiple-update.https.html

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 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
(Empty)
1 <!DOCTYPE html>
2 <!-- In Bug 1217367, we will try to merge update events for same registration
3 if possible. This testcase is used to make sure the optimization algorithm
4 doesn't go wrong. -->
5 <title>Service Worker: Trigger multiple updates</title>
6 <script src="/resources/testharness.js"></script>
7 <script src="/resources/testharnessreport.js"></script>
8 <script src="resources/test-helpers.sub.js"></script>
9 <script>
10 promise_test(function(t) {
11 var script = 'resources/update-nocookie-worker.py';
12 var scope = 'resources/scope/update';
13 var expected_url = normalizeURL(script);
14 var registration;
15
16 return service_worker_unregister_and_register(t, expected_url, scope)
17 .then(function(r) {
18 registration = r;
19 return wait_for_state(t, registration.installing, 'activated');
20 })
21 .then(function() {
22 // Test single update works before triggering multiple update events
23 return Promise.all([registration.update(),
24 wait_for_update(t, registration)]);
25 })
26 .then(function() {
27 assert_equals(registration.installing.scriptURL, expected_url,
28 'new installing should be set after update resolves.');
29 assert_equals(registration.waiting, null,
30 'waiting should still be null after update resolves.');
31 assert_equals(registration.active.scriptURL, expected_url,
32 'active should still exist after update found.');
33 return wait_for_state(t, registration.installing, 'installed');
34 })
35 .then(function() {
36 assert_equals(registration.installing, null,
37 'installing should be null after installing.');
38 if (registration.waiting) {
39 assert_equals(registration.waiting.scriptURL, expected_url,
40 'waiting should be set after installing.');
41 assert_equals(registration.active.scriptURL, expected_url,
42 'active should still exist after installing.');
43 return wait_for_state(t, registration.waiting, 'activated');
44 }
45 })
46 .then(function() {
47 // Test triggering multiple update events at the same time.
48 var promiseList = [];
49 const burstUpdateCount = 10;
50 for (var i = 0; i < burstUpdateCount; i++) {
51 promiseList.push(registration.update());
52 }
53 promiseList.push(wait_for_update(t, registration));
54 return Promise.all(promiseList);
55 })
56 .then(function() {
57 assert_equals(registration.installing.scriptURL, expected_url,
58 'new installing should be set after update resolves.');
59 assert_equals(registration.waiting, null,
60 'waiting should still be null after update resolves.');
61 assert_equals(registration.active.scriptURL, expected_url,
62 'active should still exist after update found.');
63 return wait_for_state(t, registration.installing, 'installed');
64 })
65 .then(function() {
66 assert_equals(registration.installing, null,
67 'installing should be null after installing.');
68 if (registration.waiting) {
69 assert_equals(registration.waiting.scriptURL, expected_url,
70 'waiting should be set after installing.');
71 assert_equals(registration.active.scriptURL, expected_url,
72 'active should still exist after installing.');
73 return wait_for_state(t, registration.waiting, 'activated');
74 }
75 })
76 .then(function() {
77 // Test update still works after handling update event burst.
78 return Promise.all([registration.update(),
79 wait_for_update(t, registration)]);
80 })
81 .then(function() {
82 assert_equals(registration.installing.scriptURL, expected_url,
83 'new installing should be set after update resolves.');
84 assert_equals(registration.waiting, null,
85 'waiting should be null after activated.');
86 assert_equals(registration.active.scriptURL, expected_url,
87 'active should still exist after update found.');
88
89 return service_worker_unregister_and_done(t, scope);
90 });
91 }, 'Trigger multiple updates.');
92 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698