зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1147699 - Part 5: Add a test for FetchEvent.request.context when intercepting an audio element load; r=nsm
This commit is contained in:
Родитель
f479f50502
Коммит
fe261ef1d6
|
@ -16,6 +16,10 @@ self.addEventListener("fetch", function(event) {
|
|||
if (event.request.context == "imageset") {
|
||||
event.respondWith(fetch("realimg.jpg"));
|
||||
}
|
||||
} else if (event.request.url.indexOf("audio.ogg") >= 0) {
|
||||
if (event.request.context == "audio") {
|
||||
event.respondWith(fetch("realaudio.ogg"));
|
||||
}
|
||||
}
|
||||
// Fail any request that we don't know about.
|
||||
try {
|
||||
|
|
|
@ -58,11 +58,25 @@
|
|||
});
|
||||
}
|
||||
|
||||
function testAudio() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var audio = document.createElement("audio");
|
||||
audio.src = "audio.ogg";
|
||||
audio.preload = "metadata";
|
||||
// The service worker will respond with an existing audio only if the
|
||||
// Request has the correct context, otherwise the Promise will get
|
||||
// rejected and the test will fail.
|
||||
audio.onloadedmetadata = resolve;
|
||||
audio.onerror = reject;
|
||||
});
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
testFetch(),
|
||||
testImage(),
|
||||
testImageSrcSet(),
|
||||
testPicture(),
|
||||
testAudio(),
|
||||
])
|
||||
.then(function() {
|
||||
finish();
|
||||
|
|
Двоичный файл не отображается.
|
@ -31,6 +31,7 @@ support-files =
|
|||
fetch/context/unregister.html
|
||||
fetch/context/context_test.js
|
||||
fetch/context/realimg.jpg
|
||||
fetch/context/realaudio.ogg
|
||||
fetch/https/index.html
|
||||
fetch/https/register.html
|
||||
fetch/https/unregister.html
|
||||
|
|
Загрузка…
Ссылка в новой задаче