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

Side by Side Diff: LayoutTests/http/tests/serviceworker/fetch-event.html

Issue 304233017: ServiceWorker: Add layout tests for fetch event response (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: patch for landing 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 | LayoutTests/http/tests/serviceworker/fetch-event-expected.txt » ('j') | 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 <body>
6 <script>
7 var worker = 'resources/fetch-event-test-worker.js';
8
9 (function() {
10 var t = async_test('Service Worker responds to fetch event with blob body');
11 var scope = 'helloworld';
12 service_worker_unregister_and_register(t, worker, scope, onRegister);
13
14 function onRegister(sw) {
15 sw.addEventListener('statechange', t.step_func(onStateChange));
16 }
17
18 function onStateChange(event) {
19 if (event.target.state != 'active')
20 return;
21 with_iframe(scope, t.step_func(function(frame) {
22 assert_equals(frame.contentDocument.body.textContent, 'hello, world' ,
23 'Service Worker should respond to fetch with a fixed-s tring body');
24 service_worker_unregister_and_done(t, scope);
25 }));
26 }
27 }());
28
29 (function() {
30 var t = async_test('Service Worker does not respond to fetch event');
31 var scope = 'resources/simple.html?ignore';
32 service_worker_unregister_and_register(t, worker, scope, onRegister);
33
34 function onRegister(sw) {
35 sw.addEventListener('statechange', t.step_func(onStateChange));
36 }
37
38 function onStateChange(event) {
39 if (event.target.state != 'active')
40 return;
41 with_iframe(scope, t.step_func(function(frame) {
42 assert_equals(frame.contentDocument.body.textContent, 'Here\'s a sim ple html file.\n',
43 'Response should come from fallback to native fetch');
44 service_worker_unregister_and_done(t, scope);
45 }));
46 }
47 }());
48
49 (function() {
50 var t = async_test('Service Worker responds to fetch event with null respons e body');
51 var scope = 'resources/simple.html?null';
52 service_worker_unregister_and_register(t, worker, scope, onRegister);
53
54 function onRegister(sw) {
55 sw.addEventListener('statechange', t.step_func(onStateChange));
56 }
57
58 function onStateChange(event) {
59 if (event.target.state != 'active')
60 return;
61 with_iframe(scope, t.step_func(function(frame) {
62 assert_equals(frame.contentDocument.body.textContent, '',
63 'Response should be the empty string');
64 service_worker_unregister_and_done(t, scope);
65 }));
66 }
67 }());
68
69 (function() {
70 var t = async_test('Service Worker rejects fetch event');
71 var scope = 'resources/simple.html?ignore';
72 service_worker_unregister_and_register(t, worker, scope, onRegister);
73
74 function onRegister(sw) {
75 sw.addEventListener('statechange', t.step_func(onStateChange));
76 }
77
78 function onStateChange(event) {
79 if (event.target.state != 'active')
80 return;
81 with_iframe(scope, t.step_func(function(frame) {
82 assert_equals(frame.contentDocument.body.textContent, 'Here\'s a sim ple html file.\n',
83 'Response should come from fallback to native fetch');
84 service_worker_unregister_and_done(t, scope);
85 }));
86 }
87 }());
88 </script>
89 </body>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/fetch-event-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698