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

Side by Side Diff: LayoutTests/http/tests/serviceworker/claim-using-registration.html

Issue 872593002: ServiceWorker: add ServiceWorkerClients.claim() support (3/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: change error type Created 5 years, 11 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 <title>Service Worker: claim client using registration</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharness-helpers.js"></script>
5 <script src="../resources/testharnessreport.js"></script>
6 <script src="resources/test-helpers.js"></script>
7 <script>
8
9 promise_test(function(t) {
10 var scope = 'resources/';
11 var frame_url = 'resources/blank.html';
12 var url1 = 'resources/empty.js';
13 var url2 = 'resources/claim-worker.js';
14 var worker, sw_registration, frame;
15 return service_worker_unregister_and_register(t, url1, scope)
16 .then(function(registration) {
17 return wait_for_state(t, registration.installing, 'activated');
18 })
19 .then(function() {
20 return with_iframe(frame_url);
21 })
22 .then(function(f) {
23 frame = f;
24 return navigator.serviceWorker.register(url2, {scope: frame_url});
25 })
26 .then(function(registration) {
27 worker = registration.installing;
28 sw_registration = registration;
29 return wait_for_state(t, registration.installing, 'activated');
30 })
31 .then(function() {
32 var saw_controllerchanged = new Promise(function(resolve) {
33 frame.contentWindow.navigator.serviceWorker.oncontrollerchange =
34 function() { resolve(); }
35 });
36 var channel = new MessageChannel();
37 var saw_message = new Promise(function(resolve) {
38 channel.port1.onmessage = t.step_func(function(e) {
39 assert_equals(e.data, 'PASS');
jsbell 2015/01/24 01:09:38 Can you add a message to this assertion? e.g. 'Wor
xiang 2015/01/26 07:19:16 Done.
40 resolve();
41 });
42 });
43 worker.postMessage({port: channel.port2}, [channel.port2]);
44 return Promise.all([saw_controllerchanged, saw_message]);
45 })
46 .then(function() {
47 assert_equals(
48 frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
49 normalizeURL(url2),
50 'Frame1 controller scriptURL should be changed to url2');
51 frame.remove();
52 return sw_registration.unregister();
53 })
54 .then(function() {
55 return service_worker_unregister_and_done(t, scope);
56 });
57 }, 'Test worker claim client which is using another registration');
58
59 promise_test(function(t) {
60 var scope = 'resources/other.html';
61 var url1 = 'resources/empty.js';
62 var url2 = 'resources/claim-worker.js';
63 var frame, worker;
64 return service_worker_unregister_and_register(t, url1, scope)
65 .then(function(registration) {
66 return wait_for_state(t, registration.installing, 'activated');
67 })
68 .then(function() {
69 return with_iframe(scope);
70 })
71 .then(function(f) {
72 frame = f;
73 return navigator.serviceWorker.register(url2, {scope: scope});
74 })
75 .then(function(registration) {
76 worker = registration.installing;
77 return wait_for_state(t, registration.installing, 'installed');
78 })
79 .then(function() {
80 var channel = new MessageChannel();
81 var saw_message = new Promise(function(resolve) {
82 channel.port1.onmessage = t.step_func(function(e) {
83 assert_equals(e.data, 'FAIL: exception: InvalidStateError: ' +
jsbell 2015/01/24 01:09:38 Can you add a message to this assertion? e.g. 'Wor
xiang 2015/01/26 07:19:16 Done.
84 'Only active worker can claim clients.');
jsbell 2015/01/24 01:09:38 Where is this message ("Only active worker...") co
xiang 2015/01/26 07:19:16 The message defined in https://codereview.chromium
85 resolve();
86 });
87 });
88 worker.postMessage({port: channel.port2}, [channel.port2]);
89 return saw_message;
90 })
91 .then(function() {
92 frame.remove();
93 return service_worker_unregister_and_done(t, scope);
94 });
95 }, 'Test installed worker claim client which is using the same registration');
96
97 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698