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

Side by Side Diff: LayoutTests/http/tests/serviceworker/chromium/service-worker-generated-mixed-response.html

Issue 1226473002: Add LayoutTests for mixed range response handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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>
falken 2015/07/03 04:10:36 Can you add a short comment about why this is in c
horo 2015/07/06 11:45:40 Done.
2 <title>SW generated mixed response shold be handled as an error.</title>
falken 2015/07/03 04:10:36 nit: should (two places)
horo 2015/07/06 11:45:40 Done.
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <script src="../resources/test-helpers.js"></script>
6 <body>
7 <script>
8 // This file tests the following behavior:
9 // 1. The audio element sends the first request.
10 // 2. The ServiceWorker intercepts the request and returns the first 3 bytes
11 // ("Ogg").
12 // 3. The element sends the second request with "Range: bytes=3-" header.
13 // 4. The ServiceWorker doesn't intercept the request.
14 // 5. load-video.php returns the audio file from the fourth byte.
15 //
16 // The first response (2) is generated by the ServiceWorker but the second
17 // response is from the server. So an error should be occur.
falken 2015/07/03 04:10:37 I like this explanatory comment! nit: "should occ
horo 2015/07/06 11:45:40 Done.
18
19 promise_test(function(t) {
20 var SCOPE = 'resources/blank.html?service-worker-generated-mixed-response-if rame.html';
21 var SCRIPT = 'resources/service-worker-generated-mixed-response-worker.js';
22 var frame;
23 return service_worker_unregister_and_register(t, SCRIPT, SCOPE)
24 .then(function(registration) {
25 return wait_for_state(t, registration.installing, 'activated');
26 })
27 .then(function() { return with_iframe(SCOPE); })
28 .then(function(f) {
29 frame = f;
30 return new Promise(function (resolve, reject) {
31 var audio = frame.contentWindow.document.createElement('audio');
32 audio.oncanplay = function() {
33 reject('CanPlay event should not be fired.');
falken 2015/07/03 04:10:36 nit: "canplay" https://developer.mozilla.org/en-US
horo 2015/07/06 11:45:40 Done.
34 };
35 audio.onerror = resolve;
36 audio.src =
37 'http://localhost:8000/media/resources/load-video.php?' +
38 'name=../../../../media/content/silence.oga&type=audio/ogg';
39 frame.contentWindow.document.body.appendChild(audio);
40 })
41 })
42 .then(function() {
43 frame.remove();
44 return service_worker_unregister_and_done(t, SCOPE);
45 });
46 }, 'SW generated mixed response shold be handled as an error.');
47 </script>
48 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698