Bug 1147699 - Part 10: Add a test for FetchEvent.request.context when intercepting font loads; r=nsm

This commit is contained in:
Ehsan Akhgari 2015-03-26 15:00:31 -04:00
parent c7b94a91ea
commit 10f853c059
2 changed files with 20 additions and 0 deletions

View File

@ -38,6 +38,8 @@ self.addEventListener("fetch", function(event) {
respondToServiceWorker(event, "embed");
} else if (event.request.url.indexOf("object") >= 0) {
respondToServiceWorker(event, "object");
} else if (event.request.url.indexOf("font") >= 0) {
respondToServiceWorker(event, "font");
}
// Fail any request that we don't know about.
try {

View File

@ -141,6 +141,23 @@
});
}
function testFont() {
return new Promise(function(resolve, reject) {
var css = '@font-face { font-family: "sw-font"; src: url("font"); }';
css += '* { font-family: "sw-font"; }';
var style = document.createElement("style");
style.appendChild(document.createTextNode(css));
document.documentElement.appendChild(style);
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "font") {
is(e.data.context, "font", "Expected the font context on an font");
navigator.serviceWorker.removeEventListener("message", onMessage);
resolve();
}
}, false);
});
}
Promise.all([
testFetch(),
testImage(),
@ -152,6 +169,7 @@
testCSPReport(),
testEmbed(),
testObject(),
testFont(),
])
.then(function() {
finish();