summaryrefslogtreecommitdiff
path: root/src/test/Policy_test.js
diff options
context:
space:
mode:
authorhackademix2018-07-01 01:01:23 +0200
committerhackademix2018-07-01 01:01:23 +0200
commiteceae7187a6f0e9510bc1165f6977256b87f490f (patch)
treed943f1ec73c09efa70954dcedb55eac82a726148 /src/test/Policy_test.js
downloadnoscript-eceae7187a6f0e9510bc1165f6977256b87f490f.tar.gz
noscript-eceae7187a6f0e9510bc1165f6977256b87f490f.tar.xz
noscript-eceae7187a6f0e9510bc1165f6977256b87f490f.zip
Initial commit starting at version 10.1.8.3rc4.
Diffstat (limited to 'src/test/Policy_test.js')
-rw-r--r--src/test/Policy_test.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/Policy_test.js b/src/test/Policy_test.js
new file mode 100644
index 0000000..f658379
--- /dev/null
+++ b/src/test/Policy_test.js
@@ -0,0 +1,29 @@
+{
+ let p1 = new Policy();
+ p1.set("noscript.net", new Permissions(["script"], true));
+ p1.set("https://noscript.net", new Permissions(["script", "object"]));
+ p1.set("maone.net", p1.TRUSTED.tempTwin);
+ p1.set(Sites.secureDomainKey("secure.informaction.com"), p1.TRUSTED);
+ p1.set("https://flashgot.net", p1.TRUSTED);
+ p1.set("http://flashgot.net", p1.UNTRUSTED);
+ p1.set("perchè.com", p1.TRUSTED);
+ let p2 = new Policy(p1.dry());
+ debug("p1", JSON.stringify(p1.dry()));
+ debug("p2", JSON.stringify(p2.dry()));
+
+ for(let t of [
+ () => p2.can("https://noscript.net"),
+ () => !p2.can("http://noscript.net"),
+ () => p2.can("https://noscript.net", "object"),
+ () => p1.snapshot !== p2.snapshot,
+ () => JSON.stringify(p1.dry()) === JSON.stringify(p2.dry()),
+ () => p1.can("http://perchè.com/test") /* IDN encoding */,
+ () => Sites.toExternal(new URL("https://perché.com/test")) ===
+ "https://perché.com/test" /* IDN decoding */,
+ () => !p1.can("http://secure.informaction.com"),
+ () => p1.can("https://secure.informaction.com"),
+ () => p1.can("https://www.secure.informaction.com"),
+ ]) Test.run(t);
+
+ Test.report();
+}