fune/toolkit/components/antitracking/test/browser/image.sjs
Andrea Marchesini 9fc78a12aa Bug 1475189 - Block storage access in tracking sub-resources when not in iframes - part 3 - image cache, r=ehsan
--HG--
rename : toolkit/components/antitracking/test/browser/script.sjs => toolkit/components/antitracking/test/browser/subResources.sjs
2018-07-13 12:02:19 +02:00

20 lines
746 B
JavaScript

// A 1x1 PNG image.
// Source: https://commons.wikimedia.org/wiki/File:1x1.png (Public Domain)
const IMAGE = atob("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAA" +
"ACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=");
function handleRequest(aRequest, aResponse) {
aResponse.setStatusLine(aRequest.httpVersion, 200);
if (aRequest.queryString.includes("result")) {
aResponse.write(getState("hints") || 0);
setState("hints", "0");
} else {
let hints = parseInt(getState("hints") || 0) + 1;
setState("hints", hints.toString());
aResponse.setHeader("Set-Cookie", "foopy=1");
aResponse.setHeader("Content-Type", "image/png", false);
aResponse.write(IMAGE);
}
}