| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Mixing response using ServiceWorker</title> | 2 <title>Mixing response using ServiceWorker</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/get-host-info.js"></script> | 5 <script src="../../resources/get-host-info.js"></script> |
| 6 <script src="../resources/test-helpers.js"></script> | 6 <script src="../resources/test-helpers.js"></script> |
| 7 <body> | 7 <body> |
| 8 <script> | 8 <script> |
| 9 // We put this test file in chromium/ directory, because the behavior of mixing | 9 // We put this test file in chromium/ directory, because the behavior of mixing |
| 10 // multiple resources are not defined in the spec. See | 10 // multiple resources are not defined in the spec. See |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // - If |second_byte| is 'cross', the SW does a fetch to | 61 // - If |second_byte| is 'cross', the SW does a fetch to |
| 62 // 'service-worker-mixed-response.php' in the cross origin server and | 62 // 'service-worker-mixed-response.php' in the cross origin server and |
| 63 // returns the response. | 63 // returns the response. |
| 64 // 5. The element sends the third request with "Range: bytes=2-" header. | 64 // 5. The element sends the third request with "Range: bytes=2-" header. |
| 65 // 6. The native server returns the remaining data. | 65 // 6. The native server returns the remaining data. |
| 66 // | 66 // |
| 67 // When the audio element recieves the first response, it remembers the original | 67 // When the audio element recieves the first response, it remembers the original |
| 68 // URL of it. And when it receives the succeeding response, it checks the origin | 68 // URL of it. And when it receives the succeeding response, it checks the origin |
| 69 // of the new response. If the origin is not same as the origin of the first | 69 // of the new response. If the origin is not same as the origin of the first |
| 70 // response, the response must be treated as an error. | 70 // response, the response must be treated as an error. |
| 71 |
| 72 var request_num = 1; |
| 71 function audio_test(frame, original, first_byte, second_byte, expect_success) { | 73 function audio_test(frame, original, first_byte, second_byte, expect_success) { |
| 72 var url; | 74 var url; |
| 73 var HOST_INFO = get_host_info(); | 75 var HOST_INFO = get_host_info(); |
| 74 var AUDIO_PATH = '/media/resources/load-video.php?' + | 76 var AUDIO_PATH = '/media/resources/load-video.php?' + |
| 75 'name=../../../../media/content/silence.oga&type=audio/ogg'; | 77 'name=../../../../media/content/silence.oga&type=audio/ogg'; |
| 76 if (original == 'same') { | 78 if (original == 'same') { |
| 77 url = HOST_INFO['HTTP_ORIGIN'] + AUDIO_PATH; | 79 url = HOST_INFO['HTTP_ORIGIN'] + AUDIO_PATH; |
| 78 } else if (original == 'cross') { | 80 } else if (original == 'cross') { |
| 79 url = HOST_INFO['HTTP_REMOTE_ORIGIN'] + AUDIO_PATH; | 81 url = HOST_INFO['HTTP_REMOTE_ORIGIN'] + AUDIO_PATH; |
| 80 } | 82 } |
| 81 url += '&SW_FIRST=' + first_byte + '&SW_SECOND=' + second_byte; | 83 url += '&SW_FIRST=' + first_byte + '&SW_SECOND=' + second_byte; |
| 84 url += '&prevent_cache=' + request_num; |
| 85 request_num += 1; |
| 82 if (expect_success) { | 86 if (expect_success) { |
| 83 return create_success_audio_test(frame, url); | 87 return create_success_audio_test(frame, url); |
| 84 } else { | 88 } else { |
| 85 return create_failure_audio_test(frame, url); | 89 return create_failure_audio_test(frame, url); |
| 86 } | 90 } |
| 87 } | 91 } |
| 88 | 92 |
| 89 promise_test(function(t) { | 93 promise_test(function(t) { |
| 90 var SCOPE = 'resources/blank.html?/service-worker-mixed-response'; | 94 var SCOPE = 'resources/blank.html?/service-worker-mixed-response'; |
| 91 var SCRIPT = 'resources/service-worker-mixed-response-worker.js'; | 95 var SCRIPT = 'resources/service-worker-mixed-response-worker.js'; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 audio_test(f, 'cross', 'cross', 'same', false), | 129 audio_test(f, 'cross', 'cross', 'same', false), |
| 126 audio_test(f, 'cross', 'cross', 'cross', true)]); | 130 audio_test(f, 'cross', 'cross', 'cross', true)]); |
| 127 }) | 131 }) |
| 128 .then(function() { | 132 .then(function() { |
| 129 frame.remove(); | 133 frame.remove(); |
| 130 return service_worker_unregister_and_done(t, SCOPE); | 134 return service_worker_unregister_and_done(t, SCOPE); |
| 131 }); | 135 }); |
| 132 }, 'Tests for Service Worker generated mixed responses.'); | 136 }, 'Tests for Service Worker generated mixed responses.'); |
| 133 </script> | 137 </script> |
| 134 </body> | 138 </body> |
| OLD | NEW |