Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/regexpFilters_matching.js

Issue 30025555: Issue 6820 - Move tests to mocha (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created March 7, 2019, 1:14 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/notification.js ('k') | test/signatures.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 "use strict"; 18 "use strict";
19 19
20 const assert = require("assert");
20 const {createSandbox} = require("./_common"); 21 const {createSandbox} = require("./_common");
21 22
22 let Filter = null; 23 let Filter = null;
23 let RegExpFilter = null; 24 let RegExpFilter = null;
24 25
25 exports.setUp = function(callback) 26 describe("Regexp filters matching", () =>
26 { 27 {
27 let sandboxedRequire = createSandbox(); 28 beforeEach(() =>
28 ( 29 {
29 {Filter, RegExpFilter} = sandboxedRequire("../lib/filterClasses") 30 let sandboxedRequire = createSandbox();
30 ); 31 (
31 32 {Filter, RegExpFilter} = sandboxedRequire("../lib/filterClasses")
32 callback(); 33 );
33 }; 34 });
34 35
35 36 function testMatch(text, location, contentType, docDomain, thirdParty, sitekey , expected)
36 37 {
37 function testMatch(test, text, location, contentType, docDomain, thirdParty, sit ekey, expected) 38 function testMatchInternal(filterText)
38 { 39 {
39 function testMatchInternal(filterText) 40 let filter = Filter.fromText(filterText);
40 { 41 let result = filter.matches(location, RegExpFilter.typeMap[contentType], d ocDomain, thirdParty, sitekey);
41 let filter = Filter.fromText(filterText); 42 assert.equal(!!result, expected, '"' + filterText + '".matches(' + locatio n + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " + (sitekey || "no-sitekey") + ")");
42 let result = filter.matches(location, RegExpFilter.typeMap[contentType], doc Domain, thirdParty, sitekey); 43 }
43 test.equal(!!result, expected, '"' + filterText + '".matches(' + location + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "fi rst-party") + ", " + (sitekey || "no-sitekey") + ")"); 44
45 testMatchInternal(text);
46 if (!/^@@/.test(text))
47 testMatchInternal("@@" + text);
44 } 48 }
45 49
46 testMatchInternal(text); 50 it("Basic Filters", () =>
47 if (!/^@@/.test(text)) 51 {
48 testMatchInternal("@@" + text); 52 testMatch("abc", "http://abc/adf", "IMAGE", null, false, null, true);
49 } 53 testMatch("abc", "http://ABC/adf", "IMAGE", null, false, null, true);
50 54 testMatch("abc", "http://abd/adf", "IMAGE", null, false, null, false);
51 exports.testBasicFilters = function(test) 55 testMatch("|abc", "http://abc/adf", "IMAGE", null, false, null, false);
52 { 56 testMatch("|http://abc", "http://abc/adf", "IMAGE", null, false, null, true) ;
53 testMatch(test, "abc", "http://abc/adf", "IMAGE", null, false, null, true); 57 testMatch("abc|", "http://abc/adf", "IMAGE", null, false, null, false);
54 testMatch(test, "abc", "http://ABC/adf", "IMAGE", null, false, null, true); 58 testMatch("abc/adf|", "http://abc/adf", "IMAGE", null, false, null, true);
55 testMatch(test, "abc", "http://abd/adf", "IMAGE", null, false, null, false); 59 testMatch("||example.com/foo", "http://example.com/foo/bar", "IMAGE", null, false, null, true);
56 testMatch(test, "|abc", "http://abc/adf", "IMAGE", null, false, null, false); 60 testMatch("||com/foo", "http://example.com/foo/bar", "IMAGE", null, false, n ull, true);
57 testMatch(test, "|http://abc", "http://abc/adf", "IMAGE", null, false, null, t rue); 61 testMatch("||mple.com/foo", "http://example.com/foo/bar", "IMAGE", null, fal se, null, false);
58 testMatch(test, "abc|", "http://abc/adf", "IMAGE", null, false, null, false); 62 testMatch("||/example.com/foo", "http://example.com/foo/bar", "IMAGE", null, false, null, false);
59 testMatch(test, "abc/adf|", "http://abc/adf", "IMAGE", null, false, null, true ); 63 testMatch("||example.com/foo/bar|", "http://example.com/foo/bar", "IMAGE", n ull, false, null, true);
60 testMatch(test, "||example.com/foo", "http://example.com/foo/bar", "IMAGE", nu ll, false, null, true); 64 testMatch("||example.com/foo", "http://foo.com/http://example.com/foo/bar", "IMAGE", null, false, null, false);
61 testMatch(test, "||com/foo", "http://example.com/foo/bar", "IMAGE", null, fals e, null, true); 65 testMatch("||example.com/foo|", "http://example.com/foo/bar", "IMAGE", null, false, null, false);
62 testMatch(test, "||mple.com/foo", "http://example.com/foo/bar", "IMAGE", null, false, null, false); 66 });
63 testMatch(test, "||/example.com/foo", "http://example.com/foo/bar", "IMAGE", n ull, false, null, false); 67
64 testMatch(test, "||example.com/foo/bar|", "http://example.com/foo/bar", "IMAGE ", null, false, null, true); 68 it("Separators placeholders", () =>
65 testMatch(test, "||example.com/foo", "http://foo.com/http://example.com/foo/ba r", "IMAGE", null, false, null, false); 69 {
66 testMatch(test, "||example.com/foo|", "http://example.com/foo/bar", "IMAGE", n ull, false, null, false); 70 testMatch("abc^d", "http://abc/def", "IMAGE", null, false, null, true);
67 71 testMatch("abc^e", "http://abc/def", "IMAGE", null, false, null, false);
68 test.done(); 72 testMatch("def^", "http://abc/def", "IMAGE", null, false, null, true);
69 }; 73 testMatch("http://abc/d^f", "http://abc/def", "IMAGE", null, false, null, fa lse);
70 74 testMatch("http://abc/def^", "http://abc/def", "IMAGE", null, false, null, t rue);
71 exports.testSeparatorPlaceholders = function(test) 75 testMatch("^foo=bar^", "http://abc/?foo=bar", "IMAGE", null, false, null, tr ue);
72 { 76 testMatch("^foo=bar^", "http://abc/?a=b&foo=bar", "IMAGE", null, false, null , true);
73 testMatch(test, "abc^d", "http://abc/def", "IMAGE", null, false, null, true); 77 testMatch("^foo=bar^", "http://abc/?foo=bar&a=b", "IMAGE", null, false, null , true);
74 testMatch(test, "abc^e", "http://abc/def", "IMAGE", null, false, null, false); 78 testMatch("^foo=bar^", "http://abc/?notfoo=bar", "IMAGE", null, false, null, false);
75 testMatch(test, "def^", "http://abc/def", "IMAGE", null, false, null, true); 79 testMatch("^foo=bar^", "http://abc/?foo=barnot", "IMAGE", null, false, null, false);
76 testMatch(test, "http://abc/d^f", "http://abc/def", "IMAGE", null, false, null , false); 80 testMatch("^foo=bar^", "http://abc/?foo=bar%2Enot", "IMAGE", null, false, nu ll, false);
77 testMatch(test, "http://abc/def^", "http://abc/def", "IMAGE", null, false, nul l, true); 81 testMatch("||example.com^", "http://example.com/foo/bar", "IMAGE", null, fal se, null, true);
78 testMatch(test, "^foo=bar^", "http://abc/?foo=bar", "IMAGE", null, false, null , true); 82 testMatch("||example.com^", "http://example.company.com/foo/bar", "IMAGE", n ull, false, null, false);
79 testMatch(test, "^foo=bar^", "http://abc/?a=b&foo=bar", "IMAGE", null, false, null, true); 83 testMatch("||example.com^", "http://example.com:1234/foo/bar", "IMAGE", null , false, null, true);
80 testMatch(test, "^foo=bar^", "http://abc/?foo=bar&a=b", "IMAGE", null, false, null, true); 84 testMatch("||example.com^", "http://example.com.com/foo/bar", "IMAGE", null, false, null, false);
81 testMatch(test, "^foo=bar^", "http://abc/?notfoo=bar", "IMAGE", null, false, n ull, false); 85 testMatch("||example.com^", "http://example.com-company.com/foo/bar", "IMAGE ", null, false, null, false);
82 testMatch(test, "^foo=bar^", "http://abc/?foo=barnot", "IMAGE", null, false, n ull, false); 86 testMatch("||example.com^foo", "http://example.com/foo/bar", "IMAGE", null, false, null, true);
83 testMatch(test, "^foo=bar^", "http://abc/?foo=bar%2Enot", "IMAGE", null, false , null, false); 87 testMatch("||пример.ру^", "http://пример.ру/foo/bar", "IMAGE", null, false, null, true);
84 testMatch(test, "||example.com^", "http://example.com/foo/bar", "IMAGE", null, false, null, true); 88 testMatch("||пример.ру^", "http://пример.руководитель.ру/foo/bar", "IMAGE", null, false, null, false);
85 testMatch(test, "||example.com^", "http://example.company.com/foo/bar", "IMAGE ", null, false, null, false); 89 testMatch("||пример.ру^", "http://пример.ру:1234/foo/bar", "IMAGE", null, fa lse, null, true);
86 testMatch(test, "||example.com^", "http://example.com:1234/foo/bar", "IMAGE", null, false, null, true); 90 testMatch("||пример.ру^", "http://пример.ру.ру/foo/bar", "IMAGE", null, fals e, null, false);
87 testMatch(test, "||example.com^", "http://example.com.com/foo/bar", "IMAGE", n ull, false, null, false); 91 testMatch("||пример.ру^", "http://пример.ру-ководитель.ру/foo/bar", "IMAGE", null, false, null, false);
88 testMatch(test, "||example.com^", "http://example.com-company.com/foo/bar", "I MAGE", null, false, null, false); 92 testMatch("||пример.ру^foo", "http://пример.ру/foo/bar", "IMAGE", null, fals e, null, true);
89 testMatch(test, "||example.com^foo", "http://example.com/foo/bar", "IMAGE", nu ll, false, null, true); 93 });
90 testMatch(test, "||пример.ру^", "http://пример.ру/foo/bar", "IMAGE", null, fal se, null, true); 94
91 testMatch(test, "||пример.ру^", "http://пример.руководитель.ру/foo/bar", "IMAG E", null, false, null, false); 95 it("Wildcard matching", () =>
92 testMatch(test, "||пример.ру^", "http://пример.ру:1234/foo/bar", "IMAGE", null , false, null, true); 96 {
93 testMatch(test, "||пример.ру^", "http://пример.ру.ру/foo/bar", "IMAGE", null, false, null, false); 97 testMatch("abc*d", "http://abc/adf", "IMAGE", null, false, null, true);
94 testMatch(test, "||пример.ру^", "http://пример.ру-ководитель.ру/foo/bar", "IMA GE", null, false, null, false); 98 testMatch("abc*d", "http://abcd/af", "IMAGE", null, false, null, true);
95 testMatch(test, "||пример.ру^foo", "http://пример.ру/foo/bar", "IMAGE", null, false, null, true); 99 testMatch("abc*d", "http://abc/d/af", "IMAGE", null, false, null, true);
96 100 testMatch("abc*d", "http://dabc/af", "IMAGE", null, false, null, false);
97 test.done(); 101 testMatch("*abc", "http://abc/adf", "IMAGE", null, false, null, true);
98 }; 102 testMatch("abc*", "http://abc/adf", "IMAGE", null, false, null, true);
99 103 testMatch("|*abc", "http://abc/adf", "IMAGE", null, false, null, true);
100 exports.testWildcardMatching = function(test) 104 testMatch("abc*|", "http://abc/adf", "IMAGE", null, false, null, true);
101 { 105 testMatch("abc***d", "http://abc/adf", "IMAGE", null, false, null, true);
102 testMatch(test, "abc*d", "http://abc/adf", "IMAGE", null, false, null, true); 106 });
103 testMatch(test, "abc*d", "http://abcd/af", "IMAGE", null, false, null, true); 107
104 testMatch(test, "abc*d", "http://abc/d/af", "IMAGE", null, false, null, true); 108 it("Type options", () =>
105 testMatch(test, "abc*d", "http://dabc/af", "IMAGE", null, false, null, false); 109 {
106 testMatch(test, "*abc", "http://abc/adf", "IMAGE", null, false, null, true); 110 testMatch("abc$image", "http://abc/adf", "IMAGE", null, false, null, true);
107 testMatch(test, "abc*", "http://abc/adf", "IMAGE", null, false, null, true); 111 testMatch("abc$other", "http://abc/adf", "IMAGE", null, false, null, false);
108 testMatch(test, "|*abc", "http://abc/adf", "IMAGE", null, false, null, true); 112 testMatch("abc$other", "http://abc/adf", "OTHER", null, false, null, true);
109 testMatch(test, "abc*|", "http://abc/adf", "IMAGE", null, false, null, true); 113 testMatch("abc$~other", "http://abc/adf", "OTHER", null, false, null, false) ;
110 testMatch(test, "abc***d", "http://abc/adf", "IMAGE", null, false, null, true) ; 114 testMatch("abc$script", "http://abc/adf", "IMAGE", null, false, null, false) ;
111 115 testMatch("abc$script", "http://abc/adf", "SCRIPT", null, false, null, true) ;
112 test.done(); 116 testMatch("abc$~script", "http://abc/adf", "SCRIPT", null, false, null, fals e);
113 }; 117 testMatch("abc$stylesheet", "http://abc/adf", "IMAGE", null, false, null, fa lse);
114 118 testMatch("abc$stylesheet", "http://abc/adf", "STYLESHEET", null, false, nul l, true);
115 exports.testTypeOptions = function(test) 119 testMatch("abc$~stylesheet", "http://abc/adf", "STYLESHEET", null, false, nu ll, false);
116 { 120 testMatch("abc$object", "http://abc/adf", "IMAGE", null, false, null, false) ;
117 testMatch(test, "abc$image", "http://abc/adf", "IMAGE", null, false, null, tru e); 121 testMatch("abc$object", "http://abc/adf", "OBJECT", null, false, null, true) ;
118 testMatch(test, "abc$other", "http://abc/adf", "IMAGE", null, false, null, fal se); 122 testMatch("abc$~object", "http://abc/adf", "OBJECT", null, false, null, fals e);
119 testMatch(test, "abc$other", "http://abc/adf", "OTHER", null, false, null, tru e); 123 testMatch("abc$document", "http://abc/adf", "IMAGE", null, false, null, fals e);
120 testMatch(test, "abc$~other", "http://abc/adf", "OTHER", null, false, null, fa lse); 124 testMatch("abc$document", "http://abc/adf", "DOCUMENT", null, false, null, t rue);
121 testMatch(test, "abc$script", "http://abc/adf", "IMAGE", null, false, null, fa lse); 125 testMatch("abc$~document", "http://abc/adf", "DOCUMENT", null, false, null, false);
122 testMatch(test, "abc$script", "http://abc/adf", "SCRIPT", null, false, null, t rue); 126 testMatch("abc$subdocument", "http://abc/adf", "IMAGE", null, false, null, f alse);
123 testMatch(test, "abc$~script", "http://abc/adf", "SCRIPT", null, false, null, false); 127 testMatch("abc$subdocument", "http://abc/adf", "SUBDOCUMENT", null, false, n ull, true);
124 testMatch(test, "abc$stylesheet", "http://abc/adf", "IMAGE", null, false, null , false); 128 testMatch("abc$~subdocument", "http://abc/adf", "SUBDOCUMENT", null, false, null, false);
125 testMatch(test, "abc$stylesheet", "http://abc/adf", "STYLESHEET", null, false, null, true); 129 testMatch("abc$websocket", "http://abc/adf", "OBJECT", null, false, null, fa lse);
126 testMatch(test, "abc$~stylesheet", "http://abc/adf", "STYLESHEET", null, false , null, false); 130 testMatch("abc$websocket", "http://abc/adf", "WEBSOCKET", null, false, null, true);
127 testMatch(test, "abc$object", "http://abc/adf", "IMAGE", null, false, null, fa lse); 131 testMatch("abc$~websocket", "http://abc/adf", "WEBSOCKET", null, false, null , false);
128 testMatch(test, "abc$object", "http://abc/adf", "OBJECT", null, false, null, t rue); 132 testMatch("abc$webrtc", "http://abc/adf", "OBJECT", null, false, null, false );
129 testMatch(test, "abc$~object", "http://abc/adf", "OBJECT", null, false, null, false); 133 testMatch("abc$webrtc", "http://abc/adf", "WEBRTC", null, false, null, true) ;
130 testMatch(test, "abc$document", "http://abc/adf", "IMAGE", null, false, null, false); 134 testMatch("abc$~webrtc", "http://abc/adf", "WEBRTC", null, false, null, fals e);
131 testMatch(test, "abc$document", "http://abc/adf", "DOCUMENT", null, false, nul l, true); 135 testMatch("abc$background", "http://abc/adf", "OBJECT", null, false, null, f alse);
132 testMatch(test, "abc$~document", "http://abc/adf", "DOCUMENT", null, false, nu ll, false); 136 testMatch("abc$background", "http://abc/adf", "IMAGE", null, false, null, tr ue);
133 testMatch(test, "abc$subdocument", "http://abc/adf", "IMAGE", null, false, nul l, false); 137 testMatch("abc$~background", "http://abc/adf", "IMAGE", null, false, null, f alse);
134 testMatch(test, "abc$subdocument", "http://abc/adf", "SUBDOCUMENT", null, fals e, null, true); 138 testMatch("abc$xbl", "http://abc/adf", "IMAGE", null, false, null, false);
135 testMatch(test, "abc$~subdocument", "http://abc/adf", "SUBDOCUMENT", null, fal se, null, false); 139 testMatch("abc$xbl", "http://abc/adf", "XBL", null, false, null, true);
136 testMatch(test, "abc$websocket", "http://abc/adf", "OBJECT", null, false, null , false); 140 testMatch("abc$~xbl", "http://abc/adf", "XBL", null, false, null, false);
137 testMatch(test, "abc$websocket", "http://abc/adf", "WEBSOCKET", null, false, n ull, true); 141 testMatch("abc$ping", "http://abc/adf", "IMAGE", null, false, null, false);
138 testMatch(test, "abc$~websocket", "http://abc/adf", "WEBSOCKET", null, false, null, false); 142 testMatch("abc$ping", "http://abc/adf", "PING", null, false, null, true);
139 testMatch(test, "abc$webrtc", "http://abc/adf", "OBJECT", null, false, null, f alse); 143 testMatch("abc$~ping", "http://abc/adf", "PING", null, false, null, false);
140 testMatch(test, "abc$webrtc", "http://abc/adf", "WEBRTC", null, false, null, t rue); 144 testMatch("abc$xmlhttprequest", "http://abc/adf", "IMAGE", null, false, null , false);
141 testMatch(test, "abc$~webrtc", "http://abc/adf", "WEBRTC", null, false, null, false); 145 testMatch("abc$xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", null, fa lse, null, true);
142 testMatch(test, "abc$background", "http://abc/adf", "OBJECT", null, false, nul l, false); 146 testMatch("abc$~xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", null, f alse, null, false);
143 testMatch(test, "abc$background", "http://abc/adf", "IMAGE", null, false, null , true); 147 testMatch("abc$object-subrequest", "http://abc/adf", "IMAGE", null, false, n ull, false);
144 testMatch(test, "abc$~background", "http://abc/adf", "IMAGE", null, false, nul l, false); 148 testMatch("abc$object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST", nu ll, false, null, true);
145 testMatch(test, "abc$xbl", "http://abc/adf", "IMAGE", null, false, null, false ); 149 testMatch("abc$~object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST", n ull, false, null, false);
146 testMatch(test, "abc$xbl", "http://abc/adf", "XBL", null, false, null, true); 150 testMatch("abc$dtd", "http://abc/adf", "IMAGE", null, false, null, false);
147 testMatch(test, "abc$~xbl", "http://abc/adf", "XBL", null, false, null, false) ; 151 testMatch("abc$dtd", "http://abc/adf", "DTD", null, false, null, true);
148 testMatch(test, "abc$ping", "http://abc/adf", "IMAGE", null, false, null, fals e); 152 testMatch("abc$~dtd", "http://abc/adf", "DTD", null, false, null, false);
149 testMatch(test, "abc$ping", "http://abc/adf", "PING", null, false, null, true) ; 153
150 testMatch(test, "abc$~ping", "http://abc/adf", "PING", null, false, null, fals e); 154 testMatch("abc$media", "http://abc/adf", "IMAGE", null, false, null, false);
151 testMatch(test, "abc$xmlhttprequest", "http://abc/adf", "IMAGE", null, false, null, false); 155 testMatch("abc$media", "http://abc/adf", "MEDIA", null, false, null, true);
152 testMatch(test, "abc$xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", null , false, null, true); 156 testMatch("abc$~media", "http://abc/adf", "MEDIA", null, false, null, false) ;
153 testMatch(test, "abc$~xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", nul l, false, null, false); 157
154 testMatch(test, "abc$object-subrequest", "http://abc/adf", "IMAGE", null, fals e, null, false); 158 testMatch("abc$font", "http://abc/adf", "IMAGE", null, false, null, false);
155 testMatch(test, "abc$object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST" , null, false, null, true); 159 testMatch("abc$font", "http://abc/adf", "FONT", null, false, null, true);
156 testMatch(test, "abc$~object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST ", null, false, null, false); 160 testMatch("abc$~font", "http://abc/adf", "FONT", null, false, null, false);
157 testMatch(test, "abc$dtd", "http://abc/adf", "IMAGE", null, false, null, false ); 161
158 testMatch(test, "abc$dtd", "http://abc/adf", "DTD", null, false, null, true); 162 testMatch("abc$ping", "http://abc/adf", "IMAGE", null, false, null, false);
159 testMatch(test, "abc$~dtd", "http://abc/adf", "DTD", null, false, null, false) ; 163 testMatch("abc$ping", "http://abc/adf", "PING", null, false, null, true);
160 164 testMatch("abc$~ping", "http://abc/adf", "PING", null, false, null, false);
161 testMatch(test, "abc$media", "http://abc/adf", "IMAGE", null, false, null, fal se); 165
162 testMatch(test, "abc$media", "http://abc/adf", "MEDIA", null, false, null, tru e); 166 testMatch("abc$image,script", "http://abc/adf", "IMAGE", null, false, null, true);
163 testMatch(test, "abc$~media", "http://abc/adf", "MEDIA", null, false, null, fa lse); 167 testMatch("abc$~image", "http://abc/adf", "IMAGE", null, false, null, false) ;
164 168 testMatch("abc$~script", "http://abc/adf", "IMAGE", null, false, null, true) ;
165 testMatch(test, "abc$font", "http://abc/adf", "IMAGE", null, false, null, fals e); 169 testMatch("abc$~image,~script", "http://abc/adf", "IMAGE", null, false, null , false);
166 testMatch(test, "abc$font", "http://abc/adf", "FONT", null, false, null, true) ; 170 testMatch("abc$~script,~image", "http://abc/adf", "IMAGE", null, false, null , false);
167 testMatch(test, "abc$~font", "http://abc/adf", "FONT", null, false, null, fals e); 171 testMatch("abc$~document,~script,~other", "http://abc/adf", "IMAGE", null, f alse, null, true);
168 172 testMatch("abc$~image,image", "http://abc/adf", "IMAGE", null, false, null, true);
169 testMatch(test, "abc$ping", "http://abc/adf", "IMAGE", null, false, null, fals e); 173 testMatch("abc$image,~image", "http://abc/adf", "IMAGE", null, false, null, false);
170 testMatch(test, "abc$ping", "http://abc/adf", "PING", null, false, null, true) ; 174 testMatch("abc$~image,image", "http://abc/adf", "SCRIPT", null, false, null, true);
171 testMatch(test, "abc$~ping", "http://abc/adf", "PING", null, false, null, fals e); 175 testMatch("abc$image,~image", "http://abc/adf", "SCRIPT", null, false, null, false);
172 176 testMatch("abc$match-case", "http://abc/adf", "IMAGE", null, false, null, tr ue);
173 testMatch(test, "abc$image,script", "http://abc/adf", "IMAGE", null, false, nu ll, true); 177 testMatch("abc$match-case", "http://ABC/adf", "IMAGE", null, false, null, fa lse);
174 testMatch(test, "abc$~image", "http://abc/adf", "IMAGE", null, false, null, fa lse); 178 testMatch("abc$~match-case", "http://abc/adf", "IMAGE", null, false, null, t rue);
175 testMatch(test, "abc$~script", "http://abc/adf", "IMAGE", null, false, null, t rue); 179 testMatch("abc$~match-case", "http://ABC/adf", "IMAGE", null, false, null, t rue);
176 testMatch(test, "abc$~image,~script", "http://abc/adf", "IMAGE", null, false, null, false); 180 testMatch("abc$match-case,image", "http://abc/adf", "IMAGE", null, false, nu ll, true);
177 testMatch(test, "abc$~script,~image", "http://abc/adf", "IMAGE", null, false, null, false); 181 testMatch("abc$match-case,script", "http://abc/adf", "IMAGE", null, false, n ull, false);
178 testMatch(test, "abc$~document,~script,~other", "http://abc/adf", "IMAGE", nul l, false, null, true); 182 testMatch("abc$match-case,image", "http://ABC/adf", "IMAGE", null, false, nu ll, false);
179 testMatch(test, "abc$~image,image", "http://abc/adf", "IMAGE", null, false, nu ll, true); 183 testMatch("abc$match-case,script", "http://ABC/adf", "IMAGE", null, false, n ull, false);
180 testMatch(test, "abc$image,~image", "http://abc/adf", "IMAGE", null, false, nu ll, false); 184 testMatch("abc$third-party", "http://abc/adf", "IMAGE", null, false, null, f alse);
181 testMatch(test, "abc$~image,image", "http://abc/adf", "SCRIPT", null, false, n ull, true); 185 testMatch("abc$third-party", "http://abc/adf", "IMAGE", null, true, null, tr ue);
182 testMatch(test, "abc$image,~image", "http://abc/adf", "SCRIPT", null, false, n ull, false); 186 testMatch("abd$third-party", "http://abc/adf", "IMAGE", null, false, null, f alse);
183 testMatch(test, "abc$match-case", "http://abc/adf", "IMAGE", null, false, null , true); 187 testMatch("abd$third-party", "http://abc/adf", "IMAGE", null, true, null, fa lse);
184 testMatch(test, "abc$match-case", "http://ABC/adf", "IMAGE", null, false, null , false); 188 testMatch("abc$image,third-party", "http://abc/adf", "IMAGE", null, false, n ull, false);
185 testMatch(test, "abc$~match-case", "http://abc/adf", "IMAGE", null, false, nul l, true); 189 testMatch("abc$image,third-party", "http://abc/adf", "IMAGE", null, true, nu ll, true);
186 testMatch(test, "abc$~match-case", "http://ABC/adf", "IMAGE", null, false, nul l, true); 190 testMatch("abc$~image,third-party", "http://abc/adf", "IMAGE", null, false, null, false);
187 testMatch(test, "abc$match-case,image", "http://abc/adf", "IMAGE", null, false , null, true); 191 testMatch("abc$~image,third-party", "http://abc/adf", "IMAGE", null, true, n ull, false);
188 testMatch(test, "abc$match-case,script", "http://abc/adf", "IMAGE", null, fals e, null, false); 192 testMatch("abc$~third-party", "http://abc/adf", "IMAGE", null, false, null, true);
189 testMatch(test, "abc$match-case,image", "http://ABC/adf", "IMAGE", null, false , null, false); 193 testMatch("abc$~third-party", "http://abc/adf", "IMAGE", null, true, null, f alse);
190 testMatch(test, "abc$match-case,script", "http://ABC/adf", "IMAGE", null, fals e, null, false); 194 testMatch("abd$~third-party", "http://abc/adf", "IMAGE", null, false, null, false);
191 testMatch(test, "abc$third-party", "http://abc/adf", "IMAGE", null, false, nul l, false); 195 testMatch("abd$~third-party", "http://abc/adf", "IMAGE", null, true, null, f alse);
192 testMatch(test, "abc$third-party", "http://abc/adf", "IMAGE", null, true, null , true); 196 testMatch("abc$image,~third-party", "http://abc/adf", "IMAGE", null, false, null, true);
193 testMatch(test, "abd$third-party", "http://abc/adf", "IMAGE", null, false, nul l, false); 197 testMatch("abc$image,~third-party", "http://abc/adf", "IMAGE", null, true, n ull, false);
194 testMatch(test, "abd$third-party", "http://abc/adf", "IMAGE", null, true, null , false); 198 testMatch("abc$~image,~third-party", "http://abc/adf", "IMAGE", null, false, null, false);
195 testMatch(test, "abc$image,third-party", "http://abc/adf", "IMAGE", null, fals e, null, false); 199 });
196 testMatch(test, "abc$image,third-party", "http://abc/adf", "IMAGE", null, true , null, true); 200
197 testMatch(test, "abc$~image,third-party", "http://abc/adf", "IMAGE", null, fal se, null, false); 201 it("Regular Expressions", () =>
198 testMatch(test, "abc$~image,third-party", "http://abc/adf", "IMAGE", null, tru e, null, false); 202 {
199 testMatch(test, "abc$~third-party", "http://abc/adf", "IMAGE", null, false, nu ll, true); 203 testMatch("/abc/", "http://abc/adf", "IMAGE", null, false, null, true);
200 testMatch(test, "abc$~third-party", "http://abc/adf", "IMAGE", null, true, nul l, false); 204 testMatch("/abc/", "http://abcd/adf", "IMAGE", null, false, null, true);
201 testMatch(test, "abd$~third-party", "http://abc/adf", "IMAGE", null, false, nu ll, false); 205 testMatch("*/abc/", "http://abc/adf", "IMAGE", null, false, null, true);
202 testMatch(test, "abd$~third-party", "http://abc/adf", "IMAGE", null, true, nul l, false); 206 testMatch("*/abc/", "http://abcd/adf", "IMAGE", null, false, null, false);
203 testMatch(test, "abc$image,~third-party", "http://abc/adf", "IMAGE", null, fal se, null, true); 207 testMatch("/a\\wc/", "http://abc/adf", "IMAGE", null, false, null, true);
204 testMatch(test, "abc$image,~third-party", "http://abc/adf", "IMAGE", null, tru e, null, false); 208 testMatch("/a\\wc/", "http://a1c/adf", "IMAGE", null, false, null, true);
205 testMatch(test, "abc$~image,~third-party", "http://abc/adf", "IMAGE", null, fa lse, null, false); 209 testMatch("/a\\wc/", "http://a_c/adf", "IMAGE", null, false, null, true);
206 210 testMatch("/a\\wc/", "http://a%c/adf", "IMAGE", null, false, null, false);
207 test.done(); 211 });
208 }; 212
209 213 it("Regular Expressions with type options", () =>
210 exports.testRegularExpressions = function(test) 214 {
211 { 215 testMatch("/abc/$image", "http://abc/adf", "IMAGE", null, false, null, true) ;
212 testMatch(test, "/abc/", "http://abc/adf", "IMAGE", null, false, null, true); 216 testMatch("/abc/$image", "http://aBc/adf", "IMAGE", null, false, null, true) ;
213 testMatch(test, "/abc/", "http://abcd/adf", "IMAGE", null, false, null, true); 217 testMatch("/abc/$script", "http://abc/adf", "IMAGE", null, false, null, fals e);
214 testMatch(test, "*/abc/", "http://abc/adf", "IMAGE", null, false, null, true); 218 testMatch("/abc/$~image", "http://abcd/adf", "IMAGE", null, false, null, fal se);
215 testMatch(test, "*/abc/", "http://abcd/adf", "IMAGE", null, false, null, false ); 219 testMatch("/ab{2}c/$image", "http://abc/adf", "IMAGE", null, false, null, fa lse);
216 testMatch(test, "/a\\wc/", "http://abc/adf", "IMAGE", null, false, null, true) ; 220 testMatch("/ab{2}c/$script", "http://abc/adf", "IMAGE", null, false, null, f alse);
217 testMatch(test, "/a\\wc/", "http://a1c/adf", "IMAGE", null, false, null, true) ; 221 testMatch("/ab{2}c/$~image", "http://abcd/adf", "IMAGE", null, false, null, false);
218 testMatch(test, "/a\\wc/", "http://a_c/adf", "IMAGE", null, false, null, true) ; 222 testMatch("/abc/$third-party", "http://abc/adf", "IMAGE", null, false, null, false);
219 testMatch(test, "/a\\wc/", "http://a%c/adf", "IMAGE", null, false, null, false ); 223 testMatch("/abc/$third-party", "http://abc/adf", "IMAGE", null, true, null, true);
220 224 testMatch("/abc/$~third-party", "http://abc/adf", "IMAGE", null, false, null , true);
221 test.done(); 225 testMatch("/abc/$~third-party", "http://abc/adf", "IMAGE", null, true, null, false);
222 }; 226 testMatch("/abc/$match-case", "http://abc/adf", "IMAGE", null, false, null, true);
223 227 testMatch("/abc/$match-case", "http://aBc/adf", "IMAGE", null, true, null, f alse);
224 exports.testRegularExpressionsWithTypeOptions = function(test) 228 testMatch("/ab{2}c/$match-case", "http://abc/adf", "IMAGE", null, false, nul l, false);
225 { 229 testMatch("/ab{2}c/$match-case", "http://aBc/adf", "IMAGE", null, true, null , false);
226 testMatch(test, "/abc/$image", "http://abc/adf", "IMAGE", null, false, null, t rue); 230 testMatch("/abc/$~match-case", "http://abc/adf", "IMAGE", null, false, null, true);
227 testMatch(test, "/abc/$image", "http://aBc/adf", "IMAGE", null, false, null, t rue); 231 testMatch("/abc/$~match-case", "http://aBc/adf", "IMAGE", null, true, null, true);
228 testMatch(test, "/abc/$script", "http://abc/adf", "IMAGE", null, false, null, false); 232 testMatch("/ab{2}c/$~match-case", "http://abc/adf", "IMAGE", null, false, nu ll, false);
229 testMatch(test, "/abc/$~image", "http://abcd/adf", "IMAGE", null, false, null, false); 233 testMatch("/ab{2}c/$~match-case", "http://aBc/adf", "IMAGE", null, true, nul l, false);
230 testMatch(test, "/ab{2}c/$image", "http://abc/adf", "IMAGE", null, false, null , false); 234 });
231 testMatch(test, "/ab{2}c/$script", "http://abc/adf", "IMAGE", null, false, nul l, false); 235
232 testMatch(test, "/ab{2}c/$~image", "http://abcd/adf", "IMAGE", null, false, nu ll, false); 236 it("Domain restrictions", () =>
233 testMatch(test, "/abc/$third-party", "http://abc/adf", "IMAGE", null, false, n ull, false); 237 {
234 testMatch(test, "/abc/$third-party", "http://abc/adf", "IMAGE", null, true, nu ll, true); 238 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com", true, null, true);
235 testMatch(test, "/abc/$~third-party", "http://abc/adf", "IMAGE", null, false, null, true); 239 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com.", true, null, true);
236 testMatch(test, "/abc/$~third-party", "http://abc/adf", "IMAGE", null, true, n ull, false); 240 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com", tr ue, null, true);
237 testMatch(test, "/abc/$match-case", "http://abc/adf", "IMAGE", null, false, nu ll, true); 241 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com.", t rue, null, true);
238 testMatch(test, "/abc/$match-case", "http://aBc/adf", "IMAGE", null, true, nul l, false); 242 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "Foo.com", true, null, true);
239 testMatch(test, "/ab{2}c/$match-case", "http://abc/adf", "IMAGE", null, false, null, false); 243 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "abc.def.foo.com" , true, null, true);
240 testMatch(test, "/ab{2}c/$match-case", "http://aBc/adf", "IMAGE", null, true, null, false); 244 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "www.baz.com", tr ue, null, false);
241 testMatch(test, "/abc/$~match-case", "http://abc/adf", "IMAGE", null, false, n ull, true); 245 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", null, true, null, false);
242 testMatch(test, "/abc/$~match-case", "http://aBc/adf", "IMAGE", null, true, nu ll, true); 246 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo.com" , true, null, true);
243 testMatch(test, "/ab{2}c/$~match-case", "http://abc/adf", "IMAGE", null, false , null, false); 247 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo.com. ", true, null, true);
244 testMatch(test, "/ab{2}c/$~match-case", "http://aBc/adf", "IMAGE", null, true, null, false); 248 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www.foo. com", true, null, true);
245 249 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www.foo. com.", true, null, true);
246 test.done(); 250 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "Foo.com" , true, null, true);
247 }; 251 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "abc.def. foo.com", true, null, true);
248 252 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www.baz. com", true, null, false);
249 exports.testDomainRestrictions = function(test) 253 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", null, tru e, null, false);
250 { 254 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo.com" , true, null, true);
251 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com", tr ue, null, true); 255 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo.com. ", true, null, true);
252 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com.", t rue, null, true); 256 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www.foo. com", true, null, true);
253 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com" , true, null, true); 257 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www.foo. com.", true, null, true);
254 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com. ", true, null, true); 258 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "Foo.com" , true, null, true);
255 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "Foo.com", tr ue, null, true); 259 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "abc.def. foo.com", true, null, true);
256 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "abc.def.foo. com", true, null, true); 260 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www.baz. com", true, null, false);
257 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "www.baz.com" , true, null, false); 261 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", null, tru e, null, false);
258 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", null, true, n ull, false); 262 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com", true, null, false);
259 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo. com", true, null, true); 263 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com.", true , null, false);
260 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo. com.", true, null, true); 264 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com", t rue, null, false);
261 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www. foo.com", true, null, true); 265 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com.", true, null, false);
262 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www. foo.com.", true, null, true); 266 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "Foo.com", true, null, false);
263 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "Foo. com", true, null, true); 267 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "abc.def.foo.com ", true, null, false);
264 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "abc. def.foo.com", true, null, true); 268 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.baz.com", t rue, null, true);
265 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www. baz.com", true, null, false); 269 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", null, true, null , true);
266 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", null, true, null, false); 270 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "foo.co m", true, null, false);
267 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo. com", true, null, true); 271 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "foo.co m.", true, null, false);
268 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo. com.", true, null, true); 272 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "www.fo o.com", true, null, false);
269 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www. foo.com", true, null, true); 273 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "www.fo o.com.", true, null, false);
270 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www. foo.com.", true, null, true); 274 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "Foo.co m", true, null, false);
271 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "Foo. com", true, null, true); 275 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "abc.de f.foo.com", true, null, false);
272 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "abc. def.foo.com", true, null, true); 276 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "www.ba z.com", true, null, true);
273 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www. baz.com", true, null, false); 277 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", null, t rue, null, true);
274 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", null, true, null, false); 278 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "foo.co m", true, null, false);
275 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com", t rue, null, false); 279 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "foo.co m.", true, null, false);
276 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com.", true, null, false); 280 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "www.fo o.com", true, null, false);
277 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com ", true, null, false); 281 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "www.fo o.com.", true, null, false);
278 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com .", true, null, false); 282 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "Foo.co m", true, null, false);
279 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "Foo.com", t rue, null, false); 283 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "abc.de f.foo.com", true, null, false);
280 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "abc.def.foo .com", true, null, false); 284 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "www.ba z.com", true, null, true);
281 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.baz.com ", true, null, true); 285 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", null, t rue, null, true);
282 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", null, true, null, true); 286 testMatch("abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "foo.com ", true, null, true);
283 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "fo o.com", true, null, false); 287 testMatch("abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "bar.com ", true, null, false);
284 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "fo o.com.", true, null, false); 288 testMatch("abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "baz.com ", true, null, false);
285 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ww w.foo.com", true, null, false); 289 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "foo .com", true, null, true);
286 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ww w.foo.com.", true, null, false); 290 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www .foo.com", true, null, true);
287 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "Fo o.com", true, null, false); 291 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "bar .foo.com", true, null, false);
288 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ab c.def.foo.com", true, null, false); 292 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www .bar.foo.com", true, null, false);
289 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ww w.baz.com", true, null, true); 293 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "baz .com", true, null, false);
290 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", nul l, true, null, true); 294 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www .baz.com", true, null, false);
291 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "fo o.com", true, null, false); 295 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.com", t rue, null, true);
292 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "fo o.com.", true, null, false); 296 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.net", t rue, null, false);
293 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ww w.foo.com", true, null, false); 297 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.com", t rue, null, false);
294 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ww w.foo.com.", true, null, false); 298 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.net", t rue, null, false);
295 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "Fo o.com", true, null, false); 299 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "com", true, null, true);
296 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ab c.def.foo.com", true, null, false); 300 testMatch("abc$domain=foo.com", "http://ccc/def", "IMAGE", "foo.com", true, null, false);
297 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ww w.baz.com", true, null, true); 301 testMatch("abc$domain=foo.com", "http://ccc/def", "IMAGE", "bar.com", true, null, false);
298 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", nul l, true, null, true); 302 testMatch("abc$image,domain=foo.com", "http://abc/def", "IMAGE", "foo.com", true, null, true);
299 testMatch(test, "abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "foo .com", true, null, true); 303 testMatch("abc$image,domain=foo.com", "http://abc/def", "IMAGE", "bar.com", true, null, false);
300 testMatch(test, "abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "bar .com", true, null, false); 304 testMatch("abc$image,domain=foo.com", "http://abc/def", "OBJECT", "foo.com", true, null, false);
301 testMatch(test, "abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "baz .com", true, null, false); 305 testMatch("abc$image,domain=foo.com", "http://abc/def", "OBJECT", "bar.com", true, null, false);
302 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "foo.com", true, null, true); 306 testMatch("abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "foo.com", true, null, false);
303 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www.foo.com", true, null, true); 307 testMatch("abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "bar.com", true, null, false);
304 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "bar.foo.com", true, null, false); 308 testMatch("abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "foo.com" , true, null, true);
305 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www.bar.foo.com", true, null, false); 309 testMatch("abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "bar.com" , true, null, false);
306 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "baz.com", true, null, false); 310 testMatch("abc$domain=foo.com,image", "http://abc/def", "IMAGE", "foo.com", true, null, true);
307 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www.baz.com", true, null, false); 311 testMatch("abc$domain=foo.com,image", "http://abc/def", "IMAGE", "bar.com", true, null, false);
308 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.com ", true, null, true); 312 testMatch("abc$domain=foo.com,image", "http://abc/def", "OBJECT", "foo.com", true, null, false);
309 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.net ", true, null, false); 313 testMatch("abc$domain=foo.com,image", "http://abc/def", "OBJECT", "bar.com", true, null, false);
310 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.com ", true, null, false); 314 testMatch("abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "foo.com", true, null, false);
311 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.net ", true, null, false); 315 testMatch("abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "bar.com", true, null, false);
312 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "com", t rue, null, true); 316 testMatch("abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "foo.com" , true, null, true);
313 testMatch(test, "abc$domain=foo.com", "http://ccc/def", "IMAGE", "foo.com", tr ue, null, false); 317 testMatch("abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "bar.com" , true, null, false);
314 testMatch(test, "abc$domain=foo.com", "http://ccc/def", "IMAGE", "bar.com", tr ue, null, false); 318 });
315 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "IMAGE", "foo.co m", true, null, true); 319
316 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "IMAGE", "bar.co m", true, null, false); 320 it("Sitekey restrictions", () =>
317 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "OBJECT", "foo.c om", true, null, false); 321 {
318 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "OBJECT", "bar.c om", true, null, false); 322 testMatch("abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, "foo-publickey", true);
319 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "foo.c om", true, null, false); 323 testMatch("abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, null, false);
320 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "bar.c om", true, null, false); 324 testMatch("abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, "bar-publickey", false);
321 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "foo. com", true, null, true); 325 testMatch("abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", "IMAG E", "foo.com", true, "foo-publickey", true);
322 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "bar. com", true, null, false); 326 testMatch("abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", "IMAG E", "foo.com", true, null, false);
323 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "IMAGE", "foo.co m", true, null, true); 327 testMatch("abc$sitekey=bar-publickey|foo-publickey", "http://abc/def", "IMAG E", "foo.com", true, "foo-publickey", true);
324 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "IMAGE", "bar.co m", true, null, false); 328 testMatch("abc$sitekey=foo-publickey", "http://ccc/def", "IMAGE", "foo.com", true, "foo-publickey", false);
325 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "OBJECT", "foo.c om", true, null, false); 329 testMatch("abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMA GE", "foo.com", true, "foo-publickey", true);
326 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "OBJECT", "bar.c om", true, null, false); 330 testMatch("abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMA GE", "bar.com", true, "foo-publickey", false);
327 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "foo.c om", true, null, false); 331 testMatch("abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IM AGE", "foo.com", true, "foo-publickey", false);
328 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "bar.c om", true, null, false); 332 testMatch("abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IM AGE", "bar.com", true, "foo-publickey", true);
329 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "foo. com", true, null, true); 333 });
330 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "bar. com", true, null, false); 334
331 335 it("Exception rules", () =>
332 test.done(); 336 {
333 }; 337 testMatch("@@test", "http://test/", "DOCUMENT", null, false, null, false);
334 338 testMatch("@@http://test*", "http://test/", "DOCUMENT", null, false, null, f alse);
335 exports.testSitekeyRestrictions = function(test) 339 testMatch("@@ftp://test*", "ftp://test/", "DOCUMENT", null, false, null, fal se);
336 { 340 testMatch("@@test$document", "http://test/", "DOCUMENT", null, false, null, true);
337 testMatch(test, "abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.c om", true, "foo-publickey", true); 341 testMatch("@@test$document,image", "http://test/", "DOCUMENT", null, false, null, true);
338 testMatch(test, "abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.c om", true, null, false); 342 testMatch("@@test$~image", "http://test/", "DOCUMENT", null, false, null, fa lse);
339 testMatch(test, "abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.c om", true, "bar-publickey", false); 343 testMatch("@@test$~image,document", "http://test/", "DOCUMENT", null, false, null, true);
340 testMatch(test, "abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", " IMAGE", "foo.com", true, "foo-publickey", true); 344 testMatch("@@test$document,~image", "http://test/", "DOCUMENT", null, false, null, true);
341 testMatch(test, "abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", " IMAGE", "foo.com", true, null, false); 345 testMatch("@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "foo .com", false, null, true);
342 testMatch(test, "abc$sitekey=bar-publickey|foo-publickey", "http://abc/def", " IMAGE", "foo.com", true, "foo-publickey", true); 346 testMatch("@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "bar .com", false, null, false);
343 testMatch(test, "abc$sitekey=foo-publickey", "http://ccc/def", "IMAGE", "foo.c om", true, "foo-publickey", false); 347 testMatch("@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "fo o.com", false, null, false);
344 testMatch(test, "abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, "foo-publickey", true); 348 testMatch("@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "ba r.com", false, null, true);
345 testMatch(test, "abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "bar.com", true, "foo-publickey", false); 349 testMatch("@@test$document,sitekey=foo-publickey", "http://test/", "DOCUMENT ", "foo.com", false, "foo-publickey", true);
346 testMatch(test, "abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, "foo-publickey", false); 350 testMatch("@@test$document,sitekey=foo-publickey", "http://test/", "DOCUMENT ", "foo.com", false, null, false);
347 testMatch(test, "abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "bar.com", true, "foo-publickey", true); 351 });
348 352 });
349 test.done();
350 };
351
352 exports.testExceptionRules = function(test)
353 {
354 testMatch(test, "@@test", "http://test/", "DOCUMENT", null, false, null, false );
355 testMatch(test, "@@http://test*", "http://test/", "DOCUMENT", null, false, nul l, false);
356 testMatch(test, "@@ftp://test*", "ftp://test/", "DOCUMENT", null, false, null, false);
357 testMatch(test, "@@test$document", "http://test/", "DOCUMENT", null, false, nu ll, true);
358 testMatch(test, "@@test$document,image", "http://test/", "DOCUMENT", null, fal se, null, true);
359 testMatch(test, "@@test$~image", "http://test/", "DOCUMENT", null, false, null , false);
360 testMatch(test, "@@test$~image,document", "http://test/", "DOCUMENT", null, fa lse, null, true);
361 testMatch(test, "@@test$document,~image", "http://test/", "DOCUMENT", null, fa lse, null, true);
362 testMatch(test, "@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "foo.com", false, null, true);
363 testMatch(test, "@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "bar.com", false, null, false);
364 testMatch(test, "@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "foo.com", false, null, false);
365 testMatch(test, "@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "bar.com", false, null, true);
366 testMatch(test, "@@test$document,sitekey=foo-publickey", "http://test/", "DOCU MENT", "foo.com", false, "foo-publickey", true);
367 testMatch(test, "@@test$document,sitekey=foo-publickey", "http://test/", "DOCU MENT", "foo.com", false, null, false);
368
369 test.done();
370 };
OLDNEW
« no previous file with comments | « test/notification.js ('k') | test/signatures.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld