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

This test is temporarily disabled until bug 1148064 gets fixed.
This commit is contained in:
Ehsan Akhgari 2015-03-26 15:59:24 -04:00
parent 969e778490
commit c0909b1151
5 changed files with 31 additions and 0 deletions

View File

@ -2,6 +2,7 @@ self.addEventListener("fetch", function(event) {
if (event.request.url.indexOf("index.html") >= 0 ||
event.request.url.indexOf("register.html") >= 0 ||
event.request.url.indexOf("unregister.html") >= 0 ||
event.request.url.indexOf("ping.html") >= 0 ||
event.request.url.indexOf("csp-violate.sjs") >= 0) {
// Handle pass-through requests
event.respondWith(fetch(event.request));
@ -51,6 +52,8 @@ self.addEventListener("fetch", function(event) {
}
} else if (event.request.url.indexOf("newwindow") >= 0) {
respondToServiceWorker(event, "newwindow");
} else if (event.request.url.indexOf("ping") >= 0) {
respondToServiceWorker(event, "ping");
}
// Fail any request that we don't know about.
try {

View File

@ -206,6 +206,23 @@
});
}
function testPing() {
// FIXME: Temporarily disabled until bug 1148064 gets fixed.
return Promise.resolve();
return new Promise(function(resolve, reject) {
var iframe = document.createElement("iframe");
iframe.src = "ping.html";
document.documentElement.appendChild(iframe);
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "ping") {
is(e.data.context, "ping", "Expected the ping context on an anchor ping");
navigator.serviceWorker.removeEventListener("message", onMessage);
resolve();
}
}, false);
});
}
Promise.all([
testFetch(),
testImage(),
@ -221,6 +238,7 @@
testIFrame(),
testFrame(),
testInternal(),
testPing(),
])
.then(function() {
finish();

View File

@ -0,0 +1,7 @@
<!DOCTYPE html>
<script>
onload = function() {
document.querySelector("a").click();
};
</script>
<a ping="ping" href="fetch.txt">link</a>

View File

@ -34,6 +34,7 @@ support-files =
fetch/context/realaudio.ogg
fetch/context/beacon.sjs
fetch/context/csp-violate.sjs
fetch/context/ping.html
fetch/https/index.html
fetch/https/register.html
fetch/https/unregister.html

View File

@ -40,6 +40,8 @@
onload = function() {
SpecialPowers.pushPrefEnv({"set": [
["beacon.enabled", true],
["browser.send_pings", true],
["browser.send_pings.max_per_link", -1],
["dom.image.picture.enabled", true],
["dom.image.srcset.enabled", true],
["dom.serviceWorkers.exemptFromPerDomainMax", true],