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

Side by Side Diff: LayoutTests/http/tests/serviceworker/request-end-to-end.html

Issue 1311933003: Deflake http/tests/serviceworker/request-end-to-end.html (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: text expectations Created 5 years, 3 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: Request end-to-end</title> 2 <title>Service Worker: FetchEvent.request passed to onfetch</title>
3 <script src="../resources/testharness.js"></script> 3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script> 5 <script src="resources/test-helpers.js"></script>
6 <script> 6 <script>
7 var t = async_test('Request: end-to-end'); 7 promise_test(t => {
8 t.step(function() {
9 var url = 'resources/request-end-to-end-worker.js'; 8 var url = 'resources/request-end-to-end-worker.js';
10 var scope = 'resources/blank.html'; 9 var scope = 'resources/blank.html';
10 return service_worker_unregister_and_register(t, url, scope)
11 .then(r => {
12 add_completion_callback(() => { r.unregister(); });
13 return wait_for_state(t, r.installing, 'activated');
14 })
15 .then(() => { return with_iframe(scope); })
16 .then(frame => {
17 add_completion_callback(() => { frame.remove(); });
11 18
12 service_worker_unregister_and_register(t, url, scope) 19 var result = JSON.parse(frame.contentDocument.body.textContent);
13 .then(onRegister) 20 assert_equals(result.url, frame.src, 'request.url');
14 .catch(unreached_rejection(t)); 21 assert_equals(result.method, 'GET', 'request.method');
15 22 assert_equals(result.referrer, location.href, 'request.referrer');
16 function sendMessagePort(worker) { 23 assert_equals(result.headers['user-agent'], navigator.userAgent,
17 var messageChannel = new MessageChannel(); 24 'User-Agent header');
18 worker.postMessage({port:messageChannel.port2}, [messageChannel.port2]); 25 assert_equals(result.append_header_error, 'TypeError',
19 return messageChannel.port1; 26 'Appending a new header to the request must throw a ' +
20 } 27 'TypeError.')
21 28 });
22 function onRegister(registration) { 29 }, 'Test FetchEvent.request passed to onfetch');
23 var sw = registration.installing;
24 var port = sendMessagePort(sw);
25 port.addEventListener('message', t.step_func(function(event) {
26 onMessage(event);
27 }), false);
28 port.start();
29 sw.addEventListener('statechange', t.step_func(function(event) {
30 if (event.target.state == 'activated')
31 onActive();
32 }));
33 }
34
35 function onActive() {
36 with_iframe(scope);
37 }
38
39 function onMessage(event) {
40 assert_equals(
41 event.data.url,
42 location.href.substring(0, location.href.lastIndexOf('/') + 1) +
43 scope,
44 'request.url should be passed to onfetch event.');
45 assert_equals(event.data.method, 'GET',
46 'request.method should be passed to onfetch event.');
47 assert_equals(event.data.referrer, location.href,
48 'request.referrer should be passed to onfetch event.');
49 assert_equals(event.data.headers['user-agent'], navigator.userAgent,
50 'User-Agent header should be passed to onfetch event.')
51 assert_equals(event.data.errorNameWhileAppendingHeader, 'TypeError',
52 'Appending a new header to the request must throw a ' +
53 'TypeError.')
54 service_worker_unregister_and_done(t, scope);
55 }
56 });
57 </script> 30 </script>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/http/tests/serviceworker/resources/request-end-to-end-worker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698