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

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: third 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/media/resources/mixed-range-response.php » ('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 <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 third 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, an error should occur.
18
19 function create_failure_audio_test(url) {
20 return new Promise(function(resolve, reject) {
21 var audio = document.createElement('audio');
22 audio.oncanplay = function() {
23 reject('canplay event should not be fired. url: ' + url);
24 };
25 audio.onerror = resolve;
26 audio.src = url;
27 document.body.appendChild(audio);
28 });
29 }
30
31 function create_success_audio_test(url) {
32 return new Promise(function(resolve, reject) {
33 var audio = document.createElement('audio');
34 audio.oncanplay = resolve;
35 audio.onerror = function(e) {
36 reject('error event should not be fired. url: ' + url);
37 };
38 audio.src = url;
39 document.body.appendChild(audio);
40 });
41 }
42
43 var HOST_INFO = get_host_info();
44 var MIX_RESPONSE_PHP_PATH = '/media/resources/mixed-range-response.php';
45 var AUDIO_PATH = '/media/resources/load-video.php?' +
46 'name=../../../../media/content/silence.oga&type=audio/ogg';
47
48 promise_test(function(t) {
49 return create_success_audio_test(
50 HOST_INFO['HTTP_ORIGIN'] + MIX_RESPONSE_PHP_PATH + '?location=' +
51 encodeURIComponent(HOST_INFO['HTTP_ORIGIN'] + AUDIO_PATH));
52 }, 'Mixing same-origin responses must succeed.');
53
54 promise_test(function(t) {
55 return create_failure_audio_test(
56 HOST_INFO['HTTP_ORIGIN'] + MIX_RESPONSE_PHP_PATH + '?location=' +
57 encodeURIComponent(HOST_INFO['HTTP_REMOTE_ORIGIN'] + AUDIO_PATH));
58 }, 'Mixing same-origin response and remote-origin response must fail.');
59
60 promise_test(function(t) {
61 return create_failure_audio_test(
62 HOST_INFO['HTTP_REMOTE_ORIGIN'] + MIX_RESPONSE_PHP_PATH + '?location=' +
63 encodeURIComponent(HOST_INFO['HTTP_ORIGIN'] + AUDIO_PATH));
64 }, 'Mixing remote-origin response and same-origin response must fail.');
65
66 promise_test(function(t) {
67 return create_success_audio_test(
68 HOST_INFO['HTTP_REMOTE_ORIGIN'] + MIX_RESPONSE_PHP_PATH + '?location=' +
69 encodeURIComponent(HOST_INFO['HTTP_REMOTE_ORIGIN'] + AUDIO_PATH));
70 }, 'Mixing same remote-origin responses must succeed.');
71
72 </script>
73 </body>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/media/resources/mixed-range-response.php » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698