diff --git a/dom/tests/mochitest/beacon/beacon-handler.sjs b/dom/tests/mochitest/beacon/beacon-handler.sjs index 8a3d74ad232a..c8b799dc94e9 100644 --- a/dom/tests/mochitest/beacon/beacon-handler.sjs +++ b/dom/tests/mochitest/beacon/beacon-handler.sjs @@ -55,6 +55,13 @@ function handleRequest(request, response) { response.setHeader("Content-Type", "application/json", false); switch (request.queryString) { case "getLastBeacon": + // Allow CORS responses of the last beacon + var originHeader = request.getHeader("origin"); + response.setHeader("Access-Control-Allow-Headers", "content-type", false); + response.setHeader("Access-Control-Allow-Methods", "POST, GET", false); + response.setHeader("Access-Control-Allow-Origin", originHeader, false); + response.setHeader("Access-Control-Allow-Credentials", "true", false); + var state = getOurState(); if (state === "unblocked") { finishControlResponse(response); diff --git a/dom/tests/mochitest/beacon/chrome.ini b/dom/tests/mochitest/beacon/chrome.ini index 212b0a1178ec..27f8f939520b 100644 --- a/dom/tests/mochitest/beacon/chrome.ini +++ b/dom/tests/mochitest/beacon/chrome.ini @@ -5,3 +5,6 @@ skip-if = os == 'android' skip-if = (verify && !debug && (os == 'win')) support-files = beacon-set-cookie.sjs file_beaconCookies.html +[test_beaconWithSafelistedContentType.html] +support-files = beacon-handler.sjs + file_beaconSafelist.html diff --git a/dom/tests/mochitest/beacon/file_beaconSafelist.html b/dom/tests/mochitest/beacon/file_beaconSafelist.html new file mode 100644 index 000000000000..0079ed507471 --- /dev/null +++ b/dom/tests/mochitest/beacon/file_beaconSafelist.html @@ -0,0 +1,11 @@ + + diff --git a/dom/tests/mochitest/beacon/test_beaconWithSafelistedContentType.html b/dom/tests/mochitest/beacon/test_beaconWithSafelistedContentType.html new file mode 100644 index 000000000000..481f88c50c81 --- /dev/null +++ b/dom/tests/mochitest/beacon/test_beaconWithSafelistedContentType.html @@ -0,0 +1,103 @@ + + + +
++ ++ +