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

Side by Side Diff: LayoutTests/http/tests/serviceworker/claim-not-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: address comment 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 not 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 frame1_url = 'resources/blank.html';
11 var frame2_url = 'resources/other.html';
12 var claim_scope = 'resources/';
13 var url1 = 'resources/empty.js';
14 var url2 = 'resources/claim-worker.js';
15 var claim_worker, claim_registration, frame1, frame2;
16 return service_worker_unregister_and_register(t, url1, frame2_url)
falken 2015/01/27 03:25:54 nit: "url1" and "url2" doesn't really speak to me,
xiang 2015/01/28 07:36:43 Done.
17 .then(function(registration) {
18 return wait_for_state(t, registration.installing, 'activated');
19 })
20 .then(function() {
21 return Promise.all([with_iframe(frame1_url), with_iframe(frame2_url)]) ;
22 })
23 .then(function(frames) {
24 frame1 = frames[0];
25 frame2 = frames[1];
26 assert_equals(
27 frame1.contentWindow.navigator.serviceWorker.controller, null,
28 'Frame1 controller should be null');
29 assert_equals(
30 frame2.contentWindow.navigator.serviceWorker.controller.scriptURL,
31 normalizeURL(url1),
32 'Frame2 controller scriptURL should be url1');
33 return navigator.serviceWorker.register(url2, {scope: claim_scope});
34 })
35 .then(function(registration) {
36 claim_worker = registration.installing;
37 claim_registration = registration;
38 return wait_for_state(t, registration.installing, 'activated');
39 })
40 .then(function() {
41 var saw_controllerchanged = new Promise(function(resolve) {
42 frame1.contentWindow.navigator.serviceWorker.oncontrollerchange =
43 function() { resolve(); }
44 });
45 var channel = new MessageChannel();
46 var saw_message = new Promise(function(resolve) {
47 channel.port1.onmessage = t.step_func(function(e) {
48 assert_equals(e.data, 'PASS',
49 'Worker call to claim() should fulfill.');
50 resolve();
51 });
52 });
53 claim_worker.postMessage({port: channel.port2}, [channel.port2]);
54 return Promise.all([saw_controllerchanged, saw_message]);
55 })
56 .then(function() {
57 assert_equals(
58 frame1.contentWindow.navigator.serviceWorker.controller.scriptURL,
59 normalizeURL(url2),
60 'Frame1 should be controlled by the new registration');
61 assert_equals(
62 frame2.contentWindow.navigator.serviceWorker.controller.scriptURL,
63 normalizeURL(url1),
64 'Frame2 should not be influenced');
65 frame1.remove();
66 frame2.remove();
67 return claim_registration.unregister();
68 })
69 .then(function() {
70 return service_worker_unregister_and_done(t, frame2_url);
71 });
72 }, 'Test claim client which is not using registration');
73
74 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698