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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/request-end-to-end.https.html

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 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: Request end-to-end</title>
3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.sub.js"></script>
6 <script>
7 var t = async_test('Request: end-to-end');
8 t.step(function() {
9 var url = 'resources/request-end-to-end-worker.js';
10 var scope = 'resources/blank.html';
11 var frames = [];
12
13 service_worker_unregister_and_register(t, url, scope)
14 .then(onRegister)
15 .catch(unreached_rejection(t));
16
17 function sendMessagePort(worker) {
18 var messageChannel = new MessageChannel();
19 worker.postMessage({port:messageChannel.port2}, [messageChannel.port2]);
20 return messageChannel.port1;
21 }
22
23 function onRegister(registration) {
24 var sw = registration.installing;
25 var port = sendMessagePort(sw);
26 port.addEventListener('message', t.step_func(function(event) {
27 onMessage(event);
28 }), false);
29 port.start();
30 sw.addEventListener('statechange', t.step_func(function(event) {
31 if (event.target.state == 'activated')
32 onActive();
33 }));
34 }
35
36 function onActive() {
37 with_iframe(scope).then(function(f) { frames.push(f); });
38 }
39
40 function onMessage(event) {
41 assert_equals(
42 event.data.url,
43 location.href.substring(0, location.href.lastIndexOf('/') + 1) +
44 scope,
45 'request.url should be passed to onfetch event.');
46 assert_equals(event.data.mode, 'navigate',
47 'request.mode should be passed to onfetch event.');
48 assert_equals(event.data.method, 'GET',
49 'request.method should be passed to onfetch event.');
50 assert_equals(event.data.referrer, location.href,
51 'request.referrer should be passed to onfetch event.');
52 assert_equals(event.data.headers['user-agent'], undefined,
53 'Default User-Agent header should not be passed to onfetch event.')
54 assert_equals(event.data.errorNameWhileAppendingHeader, 'TypeError',
55 'Appending a new header to the request must throw a ' +
56 'TypeError.')
57 frames.forEach(function(f) { f.remove(); });
58 service_worker_unregister_and_done(t, scope);
59 }
60 });
61 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698