Bug 1147699 - Part 6: Add a test for FetchEvent.request.context when intercepting a video element load; r=nsm

Note that currently our implementation incorrectly reflects this as
'audio'.  This will be fixed later.
This commit is contained in:
Ehsan Akhgari 2015-03-25 19:46:07 -04:00
Родитель fe261ef1d6
Коммит e573e0c13e
2 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -20,6 +20,11 @@ self.addEventListener("fetch", function(event) {
if (event.request.context == "audio") {
event.respondWith(fetch("realaudio.ogg"));
}
} else if (event.request.url.indexOf("video.ogg") >= 0) {
// FIXME: Bug 1147668: This should be "video".
if (event.request.context == "audio") {
event.respondWith(fetch("realaudio.ogg"));
}
}
// Fail any request that we don't know about.
try {

Просмотреть файл

@ -71,12 +71,26 @@
});
}
function testVideo() {
return new Promise(function(resolve, reject) {
var video = document.createElement("video");
video.src = "video.ogg";
video.preload = "metadata";
// The service worker will respond with an existing video only if the
// Request has the correct context, otherwise the Promise will get
// rejected and the test will fail.
video.onloadedmetadata = resolve;
video.onerror = reject;
});
}
Promise.all([
testFetch(),
testImage(),
testImageSrcSet(),
testPicture(),
testAudio(),
testVideo(),
])
.then(function() {
finish();