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

Side by Side Diff: LayoutTests/http/tests/serviceworker/unregister-controller.html

Issue 358553003: Service Worker: add layout tests for behavior of controller after unregister (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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/hello-world-worker.js';
7
8 async_test(function(t) {
9 var scope = 'unregister-existing-controller';
10 var w = null;
11
12 service_worker_unregister_and_register(t, worker_url, scope).then(t.step_fun c(function(worker) {
13 worker.addEventListener('statechange', t.step_func(on_state_change));
14 }));
15
16 function on_state_change(event) {
17 if (event.target.state != 'active')
18 return;
19 with_iframe(scope, t.step_func(function(frame) {
michaeln 2014/06/26 00:41:15 how is 'scope' used by with_iframe?
falken 2014/06/26 03:03:16 with_iframe makes an iframe with src=scope. The id
20 w = frame.contentWindow;
21 assert_true(w.navigator.serviceWorker.controller instanceof w.Servic eWorker,
22 'document should load with a controller');
23 document_loaded();
24 }));
25 }
26
27 function document_loaded() {
28 navigator.serviceWorker.unregister(scope).then(t.step_func(function() {
29 assert_true(w.navigator.serviceWorker.controller instanceof w.Servic eWorker,
30 'controller should remain after unregister');
31 var xhr = new w.XMLHttpRequest();
michaeln 2014/06/26 00:41:15 On my first reading, i didn't notice you were new'
falken 2014/06/26 03:03:16 Yeah I agree this is confusing though it seems to
32 xhr.addEventListener('readystatechange', t.step_func(function(event) {
33 if (event.target.readyState == 4) {
34 assert_equals(xhr.response, 'hello, world', 'controller shou ld intercept requests');
michaeln 2014/06/26 00:41:15 hello world is generated by the script, right? may
falken 2014/06/26 03:03:16 Done.
35 t.done();
36 }
37 }));
38 xhr.open('GET', 'resources/simple.html');
39 xhr.send();
40 }));
41 }
42 }, 'Unregister does not affect existing controller');
43
44 async_test(function(t) {
michaeln 2014/06/26 00:41:15 does this next async_test() get queued up and wait
falken 2014/06/26 03:03:16 They run concurrently. That's why we have to be ca
45 var scope = 'no-control-after-unregister';
46
47 service_worker_unregister_and_register(t, worker_url, scope).then(t.step_fun c(function(worker) {
48 worker.addEventListener('statechange', t.step_func(on_state_change));
49 }));
50
51 function on_state_change(event) {
52 if (event.target.state != 'active')
53 return;
54 navigator.serviceWorker.unregister(scope).then(t.step_func(function() {
55 with_iframe(scope, t.step_func(function(frame) {
56 var w = frame.contentWindow;
57 assert_equals(w.navigator.serviceWorker.controller, null, 'docum ent should not have a controller');
58 var xhr = new w.XMLHttpRequest();
59 xhr.addEventListener('readystatechange', t.step_func(function(ev ent) {
60 if (event.target.readyState == 4) {
61 assert_equals(xhr.response, '<!DOCTYPE html>\n<title>Sim ple</title>\nHere\'s a simple html file.\n', 'requests should not be intercepted ');
michaeln 2014/06/26 00:41:15 a simple text file would be even simpler (and make
falken 2014/06/26 03:03:16 Done.
62 t.done();
63 }
64 }));
65 xhr.open('GET', 'resources/simple.html');
66 xhr.send();
67 }));
68 }));
69 }
70 }, 'Unregister prevents control of subsequent navigations');
71 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698