| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 "use strict"; | 
|  | 2 | 
|  | 3 let {Filter} = require("../lib/filterClasses"); | 
|  | 4 | 
|  | 5 function testActive(test,  text, domain, expectedActive, expectedOnlyDomain) | 
|  | 6 { | 
|  | 7   let filter = Filter.fromText(text); | 
|  | 8   test.equal(filter.isActiveOnDomain(domain), expectedActive, text + " active on
      " + domain); | 
|  | 9   test.equal(filter.isActiveOnlyOnDomain(domain), expectedOnlyDomain, text + " o
     nly active on " + domain); | 
|  | 10   filter.delete(); | 
|  | 11 } | 
|  | 12 | 
|  | 13 exports.testUnrestrictedBlocking = function(test) | 
|  | 14 { | 
|  | 15   testActive(test,  "foo", null, true, false); | 
|  | 16   testActive(test,  "foo", "com", true, false); | 
|  | 17   testActive(test,  "foo", "example.com", true, false); | 
|  | 18   testActive(test,  "foo", "example.com.", true, false); | 
|  | 19   testActive(test,  "foo", "foo.example.com", true, false); | 
|  | 20   testActive(test,  "foo", "mple.com", true, false); | 
|  | 21 | 
|  | 22   test.done(); | 
|  | 23 }; | 
|  | 24 | 
|  | 25 exports.unrestrictedHiding = function(test) | 
|  | 26 { | 
|  | 27   testActive(test,  "##foo", null, true, false); | 
|  | 28   testActive(test,  "##foo", "com", true, false); | 
|  | 29   testActive(test,  "##foo", "example.com", true, false); | 
|  | 30   testActive(test,  "##foo", "example.com.", true, false); | 
|  | 31   testActive(test,  "##foo", "foo.example.com", true, false); | 
|  | 32   testActive(test,  "##foo", "mple.com", true, false); | 
|  | 33 | 
|  | 34   test.done(); | 
|  | 35 }; | 
|  | 36 | 
|  | 37 exports.testDomainRestrictedBlocking = function(test) | 
|  | 38 { | 
|  | 39   testActive(test,  "foo$domain=example.com", null, false, false); | 
|  | 40   testActive(test,  "foo$domain=example.com", "com", false, true); | 
|  | 41   testActive(test,  "foo$domain=example.com", "example.com", true, true); | 
|  | 42   testActive(test,  "foo$domain=example.com", "example.com.", true, true); | 
|  | 43   testActive(test,  "foo$domain=example.com.", "example.com", true, true); | 
|  | 44   testActive(test,  "foo$domain=example.com.", "example.com.", true, true); | 
|  | 45   testActive(test,  "foo$domain=example.com", "foo.example.com", true, false); | 
|  | 46   testActive(test,  "foo$domain=example.com", "mple.com", false, false); | 
|  | 47 | 
|  | 48   test.done(); | 
|  | 49 }; | 
|  | 50 | 
|  | 51 exports.testDomainRestrictedHiding = function(test) | 
|  | 52 { | 
|  | 53   testActive(test,  "example.com##foo", null, false, false); | 
|  | 54   testActive(test,  "example.com##foo", "com", false, true); | 
|  | 55   testActive(test,  "example.com##foo", "example.com", true, true); | 
|  | 56   testActive(test,  "example.com##foo", "example.com.", false, false); | 
|  | 57   testActive(test,  "example.com.##foo", "example.com", false, false); | 
|  | 58   testActive(test,  "example.com.##foo", "example.com.", true, true); | 
|  | 59   testActive(test,  "example.com##foo", "foo.example.com", true, false); | 
|  | 60   testActive(test,  "example.com##foo", "mple.com", false, false); | 
|  | 61 | 
|  | 62   test.done(); | 
|  | 63 }; | 
|  | 64 | 
|  | 65 exports.testDomainSubdomainBlocking = function(test) | 
|  | 66 { | 
|  | 67   testActive(test,  "foo$domain=example.com|foo.example.com", null, false, false
     ); | 
|  | 68   testActive(test,  "foo$domain=example.com|foo.example.com", "com", false, true
     ); | 
|  | 69   testActive(test,  "foo$domain=example.com|foo.example.com", "example.com", tru
     e, true); | 
|  | 70   testActive(test,  "foo$domain=example.com|foo.example.com", "example.com.", tr
     ue, true); | 
|  | 71   testActive(test,  "foo$domain=example.com|foo.example.com", "foo.example.com",
      true, false); | 
|  | 72   testActive(test,  "foo$domain=example.com|foo.example.com", "mple.com", false,
      false); | 
|  | 73 | 
|  | 74   test.done(); | 
|  | 75 }; | 
|  | 76 | 
|  | 77 exports.testDomainSubdomainHiding = function(test) | 
|  | 78 { | 
|  | 79   testActive(test,  "example.com,foo.example.com##foo", null, false, false); | 
|  | 80   testActive(test,  "example.com,foo.example.com##foo", "com", false, true); | 
|  | 81   testActive(test,  "example.com,foo.example.com##foo", "example.com", true, tru
     e); | 
|  | 82   testActive(test,  "example.com,foo.example.com##foo", "example.com.", false, f
     alse); | 
|  | 83   testActive(test,  "example.com,foo.example.com##foo", "foo.example.com", true,
      false); | 
|  | 84   testActive(test,  "example.com,foo.example.com##foo", "mple.com", false, false
     ); | 
|  | 85 | 
|  | 86   test.done(); | 
|  | 87 }; | 
|  | 88 | 
|  | 89 exports.testSubdomainExceptionBlocking = function(test) | 
|  | 90 { | 
|  | 91   testActive(test,  "foo$domain=~foo.example.com", null, true, false); | 
|  | 92   testActive(test,  "foo$domain=~foo.example.com", "com", true, false); | 
|  | 93   testActive(test,  "foo$domain=~foo.example.com", "example.com", true, false); | 
|  | 94   testActive(test,  "foo$domain=~foo.example.com", "example.com.", true, false); | 
|  | 95   testActive(test,  "foo$domain=~foo.example.com", "foo.example.com", false, fal
     se); | 
|  | 96   testActive(test,  "foo$domain=~foo.example.com", "mple.com", true, false); | 
|  | 97 | 
|  | 98   test.done(); | 
|  | 99 }; | 
|  | 100 | 
|  | 101 exports.testSubdomainExceptionHiding = function(test) | 
|  | 102 { | 
|  | 103   testActive(test,  "~foo.example.com##foo", null, true, false); | 
|  | 104   testActive(test,  "~foo.example.com##foo", "com", true, false); | 
|  | 105   testActive(test,  "~foo.example.com##foo", "example.com", true, false); | 
|  | 106   testActive(test,  "~foo.example.com##foo", "example.com.", true, false); | 
|  | 107   testActive(test,  "~foo.example.com##foo", "foo.example.com", false, false); | 
|  | 108   testActive(test,  "~foo.example.com##foo", "mple.com", true, false); | 
|  | 109 | 
|  | 110   test.done(); | 
|  | 111 }; | 
|  | 112 | 
|  | 113 exports.testDomainSubdomainExceptionBlocking = function(test) | 
|  | 114 { | 
|  | 115   testActive(test,  "foo$domain=example.com|~foo.example.com", null, false, fals
     e); | 
|  | 116   testActive(test,  "foo$domain=example.com|~foo.example.com", "com", false, tru
     e); | 
|  | 117   testActive(test,  "foo$domain=example.com|~foo.example.com", "example.com", tr
     ue, true); | 
|  | 118   testActive(test,  "foo$domain=example.com|~foo.example.com", "example.com.", t
     rue, true); | 
|  | 119   testActive(test,  "foo$domain=example.com|~foo.example.com", "foo.example.com"
     , false, false); | 
|  | 120   testActive(test,  "foo$domain=example.com|~foo.example.com", "mple.com", false
     , false); | 
|  | 121 | 
|  | 122   test.done(); | 
|  | 123 }; | 
|  | 124 | 
|  | 125 exports.testDomainSubdomainExceptionHiding = function(test) | 
|  | 126 { | 
|  | 127   testActive(test,  "example.com,~foo.example.com##foo", null, false, false); | 
|  | 128   testActive(test,  "example.com,~foo.example.com##foo", "com", false, true); | 
|  | 129   testActive(test,  "example.com,~foo.example.com##foo", "example.com", true, tr
     ue); | 
|  | 130   testActive(test,  "example.com,~foo.example.com##foo", "example.com.", false, 
     false); | 
|  | 131   testActive(test,  "example.com,~foo.example.com##foo", "foo.example.com", fals
     e, false); | 
|  | 132   testActive(test,  "example.com,~foo.example.com##foo", "mple.com", false, fals
     e); | 
|  | 133 | 
|  | 134   test.done(); | 
|  | 135 }; | 
|  | 136 | 
|  | 137 exports.testDomainTLDExceptionBlocking = function(test) | 
|  | 138 { | 
|  | 139   testActive(test,  "foo$domain=example.com|~com", null, false, false); | 
|  | 140   testActive(test,  "foo$domain=example.com|~com", "com", false, true); | 
|  | 141   testActive(test,  "foo$domain=example.com|~com", "example.com", true, true); | 
|  | 142   testActive(test,  "foo$domain=example.com|~com", "example.com.", true, true); | 
|  | 143   testActive(test,  "foo$domain=example.com|~com", "foo.example.com", true, fals
     e); | 
|  | 144   testActive(test,  "foo$domain=example.com|~com", "mple.com", false, false); | 
|  | 145 | 
|  | 146   test.done(); | 
|  | 147 }; | 
|  | 148 | 
|  | 149 exports.testDomainTLDExceptionHiding = function(test) | 
|  | 150 { | 
|  | 151   testActive(test,  "example.com,~com##foo", null, false, false); | 
|  | 152   testActive(test,  "example.com,~com##foo", "com", false, true); | 
|  | 153   testActive(test,  "example.com,~com##foo", "example.com", true, true); | 
|  | 154   testActive(test,  "example.com,~com##foo", "example.com.", false, false); | 
|  | 155   testActive(test,  "example.com,~com##foo", "foo.example.com", true, false); | 
|  | 156   testActive(test,  "example.com,~com##foo", "mple.com", false, false); | 
|  | 157 | 
|  | 158   test.done(); | 
|  | 159 }; | 
|  | 160 | 
|  | 161 exports.testUnrelatedDomainBlocking = function(test) | 
|  | 162 { | 
|  | 163   testActive(test,  "foo$domain=nnnnnnn.nnn", null, false, false); | 
|  | 164   testActive(test,  "foo$domain=nnnnnnn.nnn", "com", false, false); | 
|  | 165   testActive(test,  "foo$domain=nnnnnnn.nnn", "example.com", false, false); | 
|  | 166   testActive(test,  "foo$domain=nnnnnnn.nnn", "example.com.", false, false); | 
|  | 167   testActive(test,  "foo$domain=nnnnnnn.nnn", "foo.example.com", false, false); | 
|  | 168   testActive(test,  "foo$domain=nnnnnnn.nnn", "mple.com", false, false); | 
|  | 169 | 
|  | 170   test.done(); | 
|  | 171 }; | 
|  | 172 | 
|  | 173 exports.testUnrelatedDomainHiding = function(test) | 
|  | 174 { | 
|  | 175   testActive(test,  "nnnnnnn.nnn##foo", null, false, false); | 
|  | 176   testActive(test,  "nnnnnnn.nnn##foo", "com", false, false); | 
|  | 177   testActive(test,  "nnnnnnn.nnn##foo", "example.com", false, false); | 
|  | 178   testActive(test,  "nnnnnnn.nnn##foo", "example.com.", false, false); | 
|  | 179   testActive(test,  "nnnnnnn.nnn##foo", "foo.example.com", false, false); | 
|  | 180   testActive(test,  "nnnnnnn.nnn##foo", "mple.com", false, false); | 
|  | 181 | 
|  | 182   test.done(); | 
|  | 183 }; | 
| OLD | NEW | 
|---|