OLD | NEW |
| (Empty) |
1 (function() | |
2 { | |
3 module("Domain restrictions", {setup: prepareFilterComponents, teardown: resto
reFilterComponents}); | |
4 | |
5 function testActive(text, domain, expectedActive, expectedOnlyDomain) | |
6 { | |
7 let filter = Filter.fromText(text); | |
8 equal(filter.isActiveOnDomain(domain), expectedActive, text + " active on "
+ domain); | |
9 equal(filter.isActiveOnlyOnDomain(domain), expectedOnlyDomain, text + " only
active on " + domain); | |
10 } | |
11 | |
12 test("Unrestricted blocking filters", function() | |
13 { | |
14 testActive("foo", null, true, false); | |
15 testActive("foo", "com", true, false); | |
16 testActive("foo", "example.com", true, false); | |
17 testActive("foo", "example.com.", true, false); | |
18 testActive("foo", "foo.example.com", true, false); | |
19 testActive("foo", "mple.com", true, false); | |
20 }); | |
21 | |
22 test("Unrestricted hiding rules", function() | |
23 { | |
24 testActive("#foo", null, true, false); | |
25 testActive("#foo", "com", true, false); | |
26 testActive("#foo", "example.com", true, false); | |
27 testActive("#foo", "example.com.", true, false); | |
28 testActive("#foo", "foo.example.com", true, false); | |
29 testActive("#foo", "mple.com", true, false); | |
30 }); | |
31 | |
32 test("Domain-restricted blocking filters", function() | |
33 { | |
34 testActive("foo$domain=example.com", null, false, false); | |
35 testActive("foo$domain=example.com", "com", false, true); | |
36 testActive("foo$domain=example.com", "example.com", true, true); | |
37 testActive("foo$domain=example.com", "example.com.", true, true); | |
38 testActive("foo$domain=example.com.", "example.com", true, true); | |
39 testActive("foo$domain=example.com.", "example.com.", true, true); | |
40 testActive("foo$domain=example.com", "foo.example.com", true, false); | |
41 testActive("foo$domain=example.com", "mple.com", false, false); | |
42 }); | |
43 | |
44 test("Domain-restricted hiding rules", function() | |
45 { | |
46 testActive("example.com#foo", null, false, false); | |
47 testActive("example.com#foo", "com", false, true); | |
48 testActive("example.com#foo", "example.com", true, true); | |
49 testActive("example.com#foo", "example.com.", false, false); | |
50 testActive("example.com.#foo", "example.com", false, false); | |
51 testActive("example.com.#foo", "example.com.", true, true); | |
52 testActive("example.com#foo", "foo.example.com", true, false); | |
53 testActive("example.com#foo", "mple.com", false, false); | |
54 }); | |
55 | |
56 test("Blocking filters restricted to domain and its subdomain", function() | |
57 { | |
58 testActive("foo$domain=example.com|foo.example.com", null, false, false); | |
59 testActive("foo$domain=example.com|foo.example.com", "com", false, true); | |
60 testActive("foo$domain=example.com|foo.example.com", "example.com", true, tr
ue); | |
61 testActive("foo$domain=example.com|foo.example.com", "example.com.", true, t
rue); | |
62 testActive("foo$domain=example.com|foo.example.com", "foo.example.com", true
, false); | |
63 testActive("foo$domain=example.com|foo.example.com", "mple.com", false, fals
e); | |
64 }); | |
65 | |
66 test("Hiding rules restricted to domain and its subdomain", function() | |
67 { | |
68 testActive("example.com,foo.example.com#foo", null, false, false); | |
69 testActive("example.com,foo.example.com#foo", "com", false, true); | |
70 testActive("example.com,foo.example.com#foo", "example.com", true, true); | |
71 testActive("example.com,foo.example.com#foo", "example.com.", false, false); | |
72 testActive("example.com,foo.example.com#foo", "foo.example.com", true, false
); | |
73 testActive("example.com,foo.example.com#foo", "mple.com", false, false); | |
74 }); | |
75 | |
76 test("Blocking filters with exception for a subdomain", function() | |
77 { | |
78 testActive("foo$domain=~foo.example.com", null, true, false); | |
79 testActive("foo$domain=~foo.example.com", "com", true, false); | |
80 testActive("foo$domain=~foo.example.com", "example.com", true, false); | |
81 testActive("foo$domain=~foo.example.com", "example.com.", true, false); | |
82 testActive("foo$domain=~foo.example.com", "foo.example.com", false, false); | |
83 testActive("foo$domain=~foo.example.com", "mple.com", true, false); | |
84 }); | |
85 | |
86 test("Hiding rules with exception for a subdomain", function() | |
87 { | |
88 testActive("~foo.example.com#foo", null, true, false); | |
89 testActive("~foo.example.com#foo", "com", true, false); | |
90 testActive("~foo.example.com#foo", "example.com", true, false); | |
91 testActive("~foo.example.com#foo", "example.com.", true, false); | |
92 testActive("~foo.example.com#foo", "foo.example.com", false, false); | |
93 testActive("~foo.example.com#foo", "mple.com", true, false); | |
94 }); | |
95 | |
96 test("Blocking filters for domain but not its subdomain", function() | |
97 { | |
98 testActive("foo$domain=example.com|~foo.example.com", null, false, false); | |
99 testActive("foo$domain=example.com|~foo.example.com", "com", false, true); | |
100 testActive("foo$domain=example.com|~foo.example.com", "example.com", true, t
rue); | |
101 testActive("foo$domain=example.com|~foo.example.com", "example.com.", true,
true); | |
102 testActive("foo$domain=example.com|~foo.example.com", "foo.example.com", fal
se, false); | |
103 testActive("foo$domain=example.com|~foo.example.com", "mple.com", false, fal
se); | |
104 }); | |
105 | |
106 test("Hiding rules for domain but not its subdomain", function() | |
107 { | |
108 testActive("example.com,~foo.example.com#foo", null, false, false); | |
109 testActive("example.com,~foo.example.com#foo", "com", false, true); | |
110 testActive("example.com,~foo.example.com#foo", "example.com", true, true); | |
111 testActive("example.com,~foo.example.com#foo", "example.com.", false, false)
; | |
112 testActive("example.com,~foo.example.com#foo", "foo.example.com", false, fal
se); | |
113 testActive("example.com,~foo.example.com#foo", "mple.com", false, false); | |
114 }); | |
115 | |
116 test("Blocking filters for domain but not its TLD", function() | |
117 { | |
118 testActive("foo$domain=example.com|~com", null, false, false); | |
119 testActive("foo$domain=example.com|~com", "com", false, true); | |
120 testActive("foo$domain=example.com|~com", "example.com", true, true); | |
121 testActive("foo$domain=example.com|~com", "example.com.", true, true); | |
122 testActive("foo$domain=example.com|~com", "foo.example.com", true, false); | |
123 testActive("foo$domain=example.com|~com", "mple.com", false, false); | |
124 }); | |
125 | |
126 test("Hiding rules for domain but not its TLD", function() | |
127 { | |
128 testActive("example.com,~com#foo", null, false, false); | |
129 testActive("example.com,~com#foo", "com", false, true); | |
130 testActive("example.com,~com#foo", "example.com", true, true); | |
131 testActive("example.com,~com#foo", "example.com.", false, false); | |
132 testActive("example.com,~com#foo", "foo.example.com", true, false); | |
133 testActive("example.com,~com#foo", "mple.com", false, false); | |
134 }); | |
135 | |
136 test("Blocking filters restricted to an unrelated domain", function() | |
137 { | |
138 testActive("foo$domain=nnnnnnn.nnn", null, false, false); | |
139 testActive("foo$domain=nnnnnnn.nnn", "com", false, false); | |
140 testActive("foo$domain=nnnnnnn.nnn", "example.com", false, false); | |
141 testActive("foo$domain=nnnnnnn.nnn", "example.com.", false, false); | |
142 testActive("foo$domain=nnnnnnn.nnn", "foo.example.com", false, false); | |
143 testActive("foo$domain=nnnnnnn.nnn", "mple.com", false, false); | |
144 }); | |
145 | |
146 test("Hiding rules restricted to an unrelated domain", function() | |
147 { | |
148 testActive("nnnnnnn.nnn#foo", null, false, false); | |
149 testActive("nnnnnnn.nnn#foo", "com", false, false); | |
150 testActive("nnnnnnn.nnn#foo", "example.com", false, false); | |
151 testActive("nnnnnnn.nnn#foo", "example.com.", false, false); | |
152 testActive("nnnnnnn.nnn#foo", "foo.example.com", false, false); | |
153 testActive("nnnnnnn.nnn#foo", "mple.com", false, false); | |
154 }); | |
155 })(); | |
OLD | NEW |