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

Side by Side Diff: LayoutTests/http/tests/media/mixed-range-response.html

Issue 1226473002: Add LayoutTests for mixed range response handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incorporated falken's comment and refactored 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 <title>Mixed range responses must be handled as an error.</title>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/get-host-info.js"></script>
5 <script src="../../media-resources/media-file.js"></script>
6 <body>
7 <script>
8 // This file tests the following behavior:
9 // 1. The audio element sends the first request.
10 // 2. mixed-range-response.php returns the first 3 bytes ("Ogg").
11 // 3. The element sends the second request with "Range: bytes=3-" header.
12 // 4. mixed-range-response.php returns 206 response.
13 // 5. The element sends the thired request to load-video.php.
14 // 6. load-video.php returns the audio file from the fourth byte.
15 //
16 // If the origin of 2. (mixed-range-response.php) and 6. (load-video.php) are
17 // different and the origin of 6. (load-video.php) is remote origin, an error
18 // should occur.
19
20 function create_failure_audio_test(url) {
21 return new Promise(function(resolve, reject) {
22 var audio = document.createElement('audio');
23 audio.oncanplay = function() {
24 reject('canplay event should not be fired. url: ' + url);
25 };
26 audio.onerror = resolve;
27 audio.src = url;
28 document.body.appendChild(audio);
29 });
30 }
31
32 function create_success_audio_test(url) {
33 return new Promise(function(resolve, reject) {
34 var audio = document.createElement('audio');
35 audio.oncanplay = resolve;
36 audio.onerror = function(e) {
37 reject('error event should not be fired. url: ' + url);
38 };
39 audio.src = url;
40 document.body.appendChild(audio);
41 });
42 }
43
44 var HOST_INFO = get_host_info();
45 var MIX_RESPONSE_PHP_PATH = '/media/resources/mixed-range-response.php';
46 var AUDIO_PATH = '/media/resources/load-video.php?' +
47 'name=../../../../media/content/silence.oga&type=audio/ogg';
48
49 promise_test(function(t) {
50 return create_success_audio_test(
51 HOST_INFO['HTTP_ORIGIN'] + MIX_RESPONSE_PHP_PATH + '?location=' +
52 encodeURIComponent(HOST_INFO['HTTP_ORIGIN'] + AUDIO_PATH));
53 }, 'Mixing same-origin responses must succeed.');
54
55 promise_test(function(t) {
56 return create_failure_audio_test(
57 HOST_INFO['HTTP_ORIGIN'] + MIX_RESPONSE_PHP_PATH + '?location=' +
58 encodeURIComponent(HOST_INFO['HTTP_REMOTE_ORIGIN'] + AUDIO_PATH));
59 }, 'Mixing same-origin response and remote-origin response must fail.');
60
61 promise_test(function(t) {
62 return create_success_audio_test(
63 HOST_INFO['HTTP_REMOTE_ORIGIN'] + MIX_RESPONSE_PHP_PATH + '?location=' +
64 encodeURIComponent(HOST_INFO['HTTP_ORIGIN'] + AUDIO_PATH));
65 }, 'Mixing remote-origin response and same-origin response must succeed.');
66
67 promise_test(function(t) {
68 return create_success_audio_test(
69 HOST_INFO['HTTP_REMOTE_ORIGIN'] + MIX_RESPONSE_PHP_PATH + '?location=' +
70 encodeURIComponent(HOST_INFO['HTTP_REMOTE_ORIGIN'] + AUDIO_PATH));
71 }, 'Mixing same remote-origin responses must succeed.');
72
73 </script>
74 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698