зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
fe261ef1d6
Коммит
e573e0c13e
|
@ -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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче