OLD | NEW |
1 importScripts('../../resources/test-helpers.js'); | 1 importScripts('../../resources/test-helpers.js'); |
2 importScripts('../../resources/worker-testharness.js'); | 2 importScripts('../../resources/worker-testharness.js'); |
3 | 3 |
| 4 var events_seen = []; |
| 5 |
4 assert_equals( | 6 assert_equals( |
5 self.registration.scope, | 7 self.registration.scope, |
6 normalizeURL('scope/registration-attribute'), | 8 normalizeURL('scope/registration-attribute'), |
7 'On worker script evaluation, registration attribute should be set'); | 9 'On worker script evaluation, registration attribute should be set'); |
8 assert_equals( | 10 assert_equals( |
9 self.registration.installing, | 11 self.registration.installing, |
10 null, | 12 null, |
11 'On worker script evaluation, installing worker should be null'); | 13 'On worker script evaluation, installing worker should be null'); |
12 assert_equals( | 14 assert_equals( |
13 self.registration.waiting, | 15 self.registration.waiting, |
14 null, | 16 null, |
15 'On worker script evaluation, waiting worker should be null'); | 17 'On worker script evaluation, waiting worker should be null'); |
16 assert_equals( | 18 assert_equals( |
17 self.registration.active, | 19 self.registration.active, |
18 null, | 20 null, |
19 'On worker script evaluation, active worker should be null'); | 21 'On worker script evaluation, active worker should be null'); |
20 | 22 |
| 23 self.registration.addEventListener('updatefound', function() { |
| 24 events_seen.push('updatefound'); |
| 25 |
| 26 assert_equals( |
| 27 self.registration.scope, |
| 28 normalizeURL('scope/registration-attribute'), |
| 29 'On updatefound event, registration attribute should be set'); |
| 30 assert_equals( |
| 31 self.registration.installing.scriptURL, |
| 32 normalizeURL('registration-attribute-worker.js'), |
| 33 'On updatefound event, installing worker should be set'); |
| 34 assert_equals( |
| 35 self.registration.waiting, |
| 36 null, |
| 37 'On updatefound event, waiting worker should be null'); |
| 38 assert_equals( |
| 39 self.registration.active, |
| 40 null, |
| 41 'On updatefound event, active worker should be null'); |
| 42 |
| 43 assert_equals( |
| 44 self.registration.installing.state, |
| 45 'installing', |
| 46 'On updatefound event, worker should be in the installing state'); |
| 47 |
| 48 var worker = self.registration.installing; |
| 49 self.registration.installing.addEventListener('statechange', function() { |
| 50 events_seen.push('statechange(' + worker.state + ')'); |
| 51 }); |
| 52 }); |
| 53 |
21 self.addEventListener('install', function(e) { | 54 self.addEventListener('install', function(e) { |
| 55 events_seen.push('install'); |
| 56 |
22 assert_equals( | 57 assert_equals( |
23 self.registration.scope, | 58 self.registration.scope, |
24 normalizeURL('scope/registration-attribute'), | 59 normalizeURL('scope/registration-attribute'), |
25 'On install event, registration attribute should be set'); | 60 'On install event, registration attribute should be set'); |
26 // FIXME: Verify that... | 61 assert_equals( |
27 // - registration.installing is set. | 62 self.registration.installing.scriptURL, |
28 // - registration.{waiting, active} are null. | 63 normalizeURL('registration-attribute-worker.js'), |
29 // (http://crbug.com/437677) | 64 'On install event, installing worker should be set'); |
| 65 assert_equals( |
| 66 self.registration.waiting, |
| 67 null, |
| 68 'On install event, waiting worker should be null'); |
| 69 assert_equals( |
| 70 self.registration.active, |
| 71 null, |
| 72 'On install event, active worker should be null'); |
| 73 |
| 74 assert_equals( |
| 75 self.registration.installing.state, |
| 76 'installing', |
| 77 'On install event, worker should be in the installing state'); |
30 }); | 78 }); |
31 | 79 |
32 self.addEventListener('activate', function(e) { | 80 self.addEventListener('activate', function(e) { |
| 81 events_seen.push('activate'); |
| 82 |
33 assert_equals( | 83 assert_equals( |
34 self.registration.scope, | 84 self.registration.scope, |
35 normalizeURL('scope/registration-attribute'), | 85 normalizeURL('scope/registration-attribute'), |
36 'On activate event, registration attribute should be set'); | 86 'On activate event, registration attribute should be set'); |
37 // FIXME: Verify that... | 87 assert_equals( |
38 // - registration.{installing, waiting} are null. | 88 self.registration.installing, |
39 // - registration.active is set. | 89 null, |
40 // (http://crbug.com/437677) | 90 'On activate event, installing worker should be null'); |
| 91 assert_equals( |
| 92 self.registration.waiting, |
| 93 null, |
| 94 'On activate event, waiting worker should be null'); |
| 95 assert_equals( |
| 96 self.registration.active.scriptURL, |
| 97 normalizeURL('registration-attribute-worker.js'), |
| 98 'On activate event, active worker should be set'); |
| 99 |
| 100 assert_equals( |
| 101 self.registration.active.state, |
| 102 'activating', |
| 103 'On activate event, worker should be in the activating state'); |
41 }); | 104 }); |
42 | 105 |
43 self.addEventListener('fetch', function(e) { | 106 self.addEventListener('fetch', function(e) { |
| 107 events_seen.push('fetch'); |
| 108 |
44 assert_equals( | 109 assert_equals( |
45 self.registration.scope, | 110 self.registration.scope, |
46 normalizeURL('scope/registration-attribute'), | 111 normalizeURL('scope/registration-attribute'), |
47 'On fetch event, registration attribute should be set'); | 112 'On fetch event, registration attribute should be set'); |
48 // FIXME: Verify that... | 113 assert_equals( |
49 // - registration.{installing, waiting} are null. | 114 self.registration.installing, |
50 // - registration.active is set. | 115 null, |
51 // (http://crbug.com/437677) | 116 'On fetch event, installing worker should be null'); |
52 e.respondWith(new Response('PASS')); | 117 assert_equals( |
| 118 self.registration.waiting, |
| 119 null, |
| 120 'On fetch event, waiting worker should be null'); |
| 121 assert_equals( |
| 122 self.registration.active.scriptURL, |
| 123 normalizeURL('registration-attribute-worker.js'), |
| 124 'On fetch event, active worker should be set'); |
| 125 |
| 126 assert_equals( |
| 127 self.registration.active.state, |
| 128 'activated', |
| 129 'On fetch event, worker should be in the activated state'); |
| 130 |
| 131 e.respondWith(new Response(events_seen)); |
53 }); | 132 }); |
OLD | NEW |