Bug 863246 - Add test case
MozReview-Commit-ID: G7sFwKSTEBc
--- a/browser/components/resistfingerprinting/moz.build
+++ b/browser/components/resistfingerprinting/moz.build
@@ -5,8 +5,12 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files("**"):
BUG_COMPONENT = ("Core", "Security")
BROWSER_CHROME_MANIFESTS += [
'test/browser/browser.ini',
]
+
+MOCHITEST_MANIFESTS += [
+ 'test/mochitest/mochitest.ini',
+]
new file mode 100644
--- /dev/null
+++ b/browser/components/resistfingerprinting/test/mochitest/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+ extends: [
+ "plugin:mozilla/browser-test"
+ ]
+};
new file mode 100644
--- /dev/null
+++ b/browser/components/resistfingerprinting/test/mochitest/mochitest.ini
@@ -0,0 +1,4 @@
+[DEFAULT]
+tags = resistfingerprinting
+
+[test_uri_resource.html]
new file mode 100644
--- /dev/null
+++ b/browser/components/resistfingerprinting/test/mochitest/test_uri_resource.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<meta charset="utf8">
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script>
+function printPref(aSrc, aKey, aValue) {
+ // console.log(aSrc + " - " + aKey + ":" + aValue);
+}
+
+var pref = printPref.bind(null, "pref");
+var sticky_pref = printPref.bind(null, "sticky_pref");
+
+SimpleTest.waitForExplicitFinish();
+document.addEventListener("DOMContentLoaded", function() {
+ var kPrefName = "security.block_resource_uri";
+
+ var createPromise = function(aPrefVal) {
+ return new Promise(async function(aResolve, aReject) {
+ var dom;
+
+ var listener = function(aSucc) {
+ SimpleTest.ok(aSucc, "Loading of URI with scheme resource:// should "
+ + (aPrefVal ? "" : "not ")
+ + "be blocked when preference "
+ + kPrefName
+ + " is "
+ + aPrefVal);
+ aResolve();
+ };
+
+ await SpecialPowers.pushPrefEnv({
+ set: [["security.block_resource_uri", aPrefVal]]
+ });
+ dom = document.createElement("script");
+ dom.onload = listener.bind(dom, !aPrefVal);
+ dom.onerror = listener.bind(dom, aPrefVal);
+ document.head.appendChild(dom);
+ dom.src = "resource:///defaults/preferences/firefox.js";
+ });
+ };
+
+ Promise.resolve(createPromise(true))
+ .then(() => createPromise(false))
+ .then(() => SimpleTest.finish());
+});
+</script>