diff --git a/browser/components/resistfingerprinting/test/mochitest/mochitest.ini b/browser/components/resistfingerprinting/test/mochitest/mochitest.ini index d108c764d1cf27549c3d9cbee3bee5fd8b52cf9b..55a5db7753022da5ad8a93331cd732f00981ac88 100644 --- a/browser/components/resistfingerprinting/test/mochitest/mochitest.ini +++ b/browser/components/resistfingerprinting/test/mochitest/mochitest.ini @@ -1,5 +1,6 @@ [DEFAULT] tags = resistfingerprinting + support-files = worker_child.js worker_grandchild.js @@ -13,3 +14,4 @@ scheme = https support-files = test_hide_gamepad_info_iframe.html [test_speech_synthesis.html] [test_bug1382499_touch_api.html] +[test_bug863246_resource_uri.html] diff --git a/browser/components/resistfingerprinting/test/mochitest/test_bug863246_resource_uri.html b/browser/components/resistfingerprinting/test/mochitest/test_bug863246_resource_uri.html new file mode 100644 index 0000000000000000000000000000000000000000..13dad300ff055f900d9e285f9d441e417c0f2865 --- /dev/null +++ b/browser/components/resistfingerprinting/test/mochitest/test_bug863246_resource_uri.html @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<meta charset="utf8"> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<script src="/tests/SimpleTest/SpawnTask.js"></script> +<script> +/* global SimpleTest SpecialPowers add_task */ + +function waitForDOMContentLoaded() { + return new Promise((aResolve) => { + document.addEventListener("DOMContentLoaded", aResolve); + }); +} + +function testResourceUri(aTest, aUri, aContentAccessible) { + return new Promise((aResolve) => { + let link = document.createElement("link"); + link.rel = "stylesheet"; + link.onload = () => { + SimpleTest.ok(aContentAccessible, aTest); + aResolve(); + }; + link.onerror = () => { + SimpleTest.ok(!aContentAccessible, aTest); + aResolve(); + }; + link.href = aUri; + document.head.appendChild(link); + }); +} + +add_task(async function() { + await waitForDOMContentLoaded(); + await testResourceUri( + "resource://content-accessible is content-accessible", + "resource://content-accessible/viewsource.css", + true); + await testResourceUri( + "resource://gre-resources is not content-accessible", + "resource://gre-resources/html.css", + false); + await SpecialPowers.pushPrefEnv({ + set: [ + ["security.all_resource_uri_content_accessible", true] + ] + }); + await testResourceUri( + "security.all_resource_uri_content_accessible = true, resource://gre-resources is now content-accessible", + "resource://gre-resources/html.css", + true); +}); +</script>