Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/chromium/service-worker-generated-mixed-response.html |
| diff --git a/LayoutTests/http/tests/serviceworker/chromium/service-worker-generated-mixed-response.html b/LayoutTests/http/tests/serviceworker/chromium/service-worker-generated-mixed-response.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ead4f483bf5684020cb9f1106ece95ec5e579db7 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/serviceworker/chromium/service-worker-generated-mixed-response.html |
| @@ -0,0 +1,48 @@ |
| +<!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.
|
| +<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.
|
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script src="../resources/test-helpers.js"></script> |
| +<body> |
| +<script> |
| +// This file tests the following behavior: |
| +// 1. The audio element sends the first request. |
| +// 2. The ServiceWorker intercepts the request and returns the first 3 bytes |
| +// ("Ogg"). |
| +// 3. The element sends the second request with "Range: bytes=3-" header. |
| +// 4. The ServiceWorker doesn't intercept the request. |
| +// 5. load-video.php returns the audio file from the fourth byte. |
| +// |
| +// The first response (2) is generated by the ServiceWorker but the second |
| +// 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.
|
| + |
| +promise_test(function(t) { |
| + var SCOPE = 'resources/blank.html?service-worker-generated-mixed-response-iframe.html'; |
| + var SCRIPT = 'resources/service-worker-generated-mixed-response-worker.js'; |
| + var frame; |
| + return service_worker_unregister_and_register(t, SCRIPT, SCOPE) |
| + .then(function(registration) { |
| + return wait_for_state(t, registration.installing, 'activated'); |
| + }) |
| + .then(function() { return with_iframe(SCOPE); }) |
| + .then(function(f) { |
| + frame = f; |
| + return new Promise(function (resolve, reject) { |
| + var audio = frame.contentWindow.document.createElement('audio'); |
| + audio.oncanplay = function() { |
| + 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.
|
| + }; |
| + audio.onerror = resolve; |
| + audio.src = |
| + 'http://localhost:8000/media/resources/load-video.php?' + |
| + 'name=../../../../media/content/silence.oga&type=audio/ogg'; |
| + frame.contentWindow.document.body.appendChild(audio); |
| + }) |
| + }) |
| + .then(function() { |
| + frame.remove(); |
| + return service_worker_unregister_and_done(t, SCOPE); |
| + }); |
| + }, 'SW generated mixed response shold be handled as an error.'); |
| +</script> |
| +</body> |