Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / serviceworker / unregister-then-register.html
blob9fd7133f755f38721c20ba6b2983bbc5839ba755
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/test-helpers.js"></script>
5 <script>
6 var worker_url = 'resources/empty-worker.js';
8 async_test(function(t) {
9 var scope = 'resources/scope/re-register-resolves-to-new-value';
10 var iframe;
11 var registration;
13 service_worker_unregister_and_register(t, worker_url, scope)
14 .then(function(r) {
15 registration = r;
16 return wait_for_state(t, r.installing, 'activated');
18 .then(function() {
19 return registration.unregister();
21 .then(function() {
22 return navigator.serviceWorker.register(worker_url, { scope: scope });
24 .then(function(new_registration) {
25 assert_not_equals(registration, new_registration,
26 'register should resolve to a new value');
27 service_worker_unregister_and_done(t, scope);
29 .catch(unreached_rejection(t));
30 }, 'Unregister then register resolves to a new value');
32 async_test(function(t) {
33 var scope = 'resources/scope/re-register-while-old-registration-in-use';
34 var registration;
36 service_worker_unregister_and_register(t, worker_url, scope)
37 .then(function(r) {
38 registration = r;
39 return wait_for_state(t, r.installing, 'activated');
41 .then(function() {
42 return with_iframe(scope);
44 .then(function(frame) {
45 return registration.unregister();
47 .then(function() {
48 return navigator.serviceWorker.register(worker_url, { scope: scope });
50 .then(function(new_registration) {
51 assert_registration_equals(
52 registration, new_registration,
53 'register should resolve to the same registration');
54 service_worker_unregister_and_done(t, scope);
56 .catch(unreached_rejection(t));
57 }, 'Unregister then register resolves to the original value if the ' +
58 'registration is in use.');
60 async_test(function(t) {
61 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee';
62 var iframe;
63 var registration;
64 var controller;
66 service_worker_unregister_and_register(t, worker_url, scope)
67 .then(function(r) {
68 registration = r;
69 return wait_for_state(t, r.installing, 'activated');
71 .then(function() {
72 return with_iframe(scope);
74 .then(function(frame) {
75 iframe = frame;
76 controller = iframe.contentWindow.navigator.serviceWorker.controller;
77 return registration.unregister();
79 .then(function() {
80 return navigator.serviceWorker.register(worker_url, { scope: scope });
82 .then(function(registration) {
83 assert_equals(registration.installing, null,
84 'installing version is null');
85 assert_equals(registration.waiting, null, 'waiting version is null');
86 assert_equals(
87 iframe.contentWindow.navigator.serviceWorker.controller,
88 controller,
89 'the worker from the first registration is the controller');
90 service_worker_unregister_and_done(t, scope);
92 .catch(unreached_rejection(t));
93 }, 'Unregister then register does not affect existing controllee');
95 async_test(function(t) {
96 var scope = 'resources/scope/resurrection';
97 var iframe;
98 var registration;
100 service_worker_unregister_and_register(t, worker_url, scope)
101 .then(function(r) {
102 registration = r;
103 return wait_for_state(t, r.installing, 'activated');
105 .then(function() {
106 return with_iframe(scope);
108 .then(function(frame) {
109 iframe = frame;
110 return registration.unregister();
112 .then(function() {
113 return navigator.serviceWorker.register(worker_url, { scope: scope });
115 .then(function() {
116 iframe.remove();
117 return with_iframe(scope);
119 .then(function(frame) {
120 // FIXME: When crbug.com/400602 is fixed, assert that controller
121 // equals the original worker.
122 assert_not_equals(
123 frame.contentWindow.navigator.serviceWorker.controller, null,
124 'document should have a controller');
125 service_worker_unregister_and_done(t, scope);
127 .catch(unreached_rejection(t));
128 }, 'Unregister then register resurrects the registration');
129 </script>