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: Rebased Created April 10, 2019, 6:33 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 let URLRequest = null; 25 let URLRequest = null;
25 26
26 exports.setUp = function(callback) 27 describe("Regexp filters matching", () =>
27 { 28 {
28 let sandboxedRequire = createSandbox(); 29 beforeEach(() =>
29 ( 30 {
30 {Filter, RegExpFilter} = sandboxedRequire("../lib/filterClasses"), 31 let sandboxedRequire = createSandbox();
31 {URLRequest} = sandboxedRequire("../lib/url") 32 (
32 ); 33 {Filter, RegExpFilter} = sandboxedRequire("../lib/filterClasses"),
33 34 {URLRequest} = sandboxedRequire("../lib/url")
34 callback(); 35 );
35 }; 36 });
36 37
37 38 function testMatch(text, location, contentType, docDomain, thirdParty, sitekey , expected)
38 39 {
39 function testMatch(test, text, location, contentType, docDomain, thirdParty, sit ekey, expected) 40 if (thirdParty && docDomain == null)
40 { 41 docDomain = "some-other-domain";
41 if (thirdParty && docDomain == null) 42
42 docDomain = "some-other-domain"; 43 function testMatchInternal(filterText)
43 44 {
44 function testMatchInternal(filterText) 45 let filter = Filter.fromText(filterText);
45 { 46 let request = URLRequest.from(location, docDomain);
46 let filter = Filter.fromText(filterText); 47 let result = filter.matches(request, RegExpFilter.typeMap[contentType], si tekey);
47 let request = URLRequest.from(location, docDomain); 48 assert.equal(!!result, expected, '"' + filterText + '".matches(' + locatio n + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " + (sitekey || "no-sitekey") + ")");
48 let result = filter.matches(request, RegExpFilter.typeMap[contentType], site key); 49 }
49 test.equal(!!result, expected, '"' + filterText + '".matches(' + location + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "fi rst-party") + ", " + (sitekey || "no-sitekey") + ")"); 50
51 testMatchInternal(text);
52 if (!/^@@/.test(text))
53 testMatchInternal("@@" + text);
50 } 54 }
51 55
52 testMatchInternal(text); 56 it("Basic Filters", () =>
53 if (!/^@@/.test(text)) 57 {
54 testMatchInternal("@@" + text); 58 testMatch("abc", "http://abc/adf", "IMAGE", null, false, null, true);
55 } 59 testMatch("abc", "http://ABC/adf", "IMAGE", null, false, null, true);
56 60 testMatch("abc", "http://abd/adf", "IMAGE", null, false, null, false);
57 exports.testBasicFilters = function(test) 61 testMatch("|abc", "http://abc/adf", "IMAGE", null, false, null, false);
58 { 62 testMatch("|http://abc", "http://abc/adf", "IMAGE", null, false, null, true) ;
59 testMatch(test, "abc", "http://abc/adf", "IMAGE", null, false, null, true); 63 testMatch("abc|", "http://abc/adf", "IMAGE", null, false, null, false);
60 testMatch(test, "abc", "http://ABC/adf", "IMAGE", null, false, null, true); 64 testMatch("abc/adf|", "http://abc/adf", "IMAGE", null, false, null, true);
61 testMatch(test, "abc", "http://abd/adf", "IMAGE", null, false, null, false); 65 testMatch("||example.com/foo", "http://example.com/foo/bar", "IMAGE", null, false, null, true);
62 testMatch(test, "|abc", "http://abc/adf", "IMAGE", null, false, null, false); 66 testMatch("||com/foo", "http://example.com/foo/bar", "IMAGE", null, false, n ull, true);
63 testMatch(test, "|http://abc", "http://abc/adf", "IMAGE", null, false, null, t rue); 67 testMatch("||mple.com/foo", "http://example.com/foo/bar", "IMAGE", null, fal se, null, false);
64 testMatch(test, "abc|", "http://abc/adf", "IMAGE", null, false, null, false); 68 testMatch("||/example.com/foo", "http://example.com/foo/bar", "IMAGE", null, false, null, false);
65 testMatch(test, "abc/adf|", "http://abc/adf", "IMAGE", null, false, null, true ); 69 testMatch("||example.com/foo/bar|", "http://example.com/foo/bar", "IMAGE", n ull, false, null, true);
66 testMatch(test, "||example.com/foo", "http://example.com/foo/bar", "IMAGE", nu ll, false, null, true); 70 testMatch("||example.com/foo", "http://foo.com/http://example.com/foo/bar", "IMAGE", null, false, null, false);
67 testMatch(test, "||com/foo", "http://example.com/foo/bar", "IMAGE", null, fals e, null, true); 71 testMatch("||example.com/foo|", "http://example.com/foo/bar", "IMAGE", null, false, null, false);
68 testMatch(test, "||mple.com/foo", "http://example.com/foo/bar", "IMAGE", null, false, null, false); 72 });
69 testMatch(test, "||/example.com/foo", "http://example.com/foo/bar", "IMAGE", n ull, false, null, false); 73
70 testMatch(test, "||example.com/foo/bar|", "http://example.com/foo/bar", "IMAGE ", null, false, null, true); 74 it("Separators placeholders", () =>
71 testMatch(test, "||example.com/foo", "http://foo.com/http://example.com/foo/ba r", "IMAGE", null, false, null, false); 75 {
72 testMatch(test, "||example.com/foo|", "http://example.com/foo/bar", "IMAGE", n ull, false, null, false); 76 testMatch("abc^d", "http://abc/def", "IMAGE", null, false, null, true);
73 77 testMatch("abc^e", "http://abc/def", "IMAGE", null, false, null, false);
74 test.done(); 78 testMatch("def^", "http://abc/def", "IMAGE", null, false, null, true);
75 }; 79 testMatch("http://abc/d^f", "http://abc/def", "IMAGE", null, false, null, fa lse);
76 80 testMatch("http://abc/def^", "http://abc/def", "IMAGE", null, false, null, t rue);
77 exports.testSeparatorPlaceholders = function(test) 81 testMatch("^foo=bar^", "http://abc/?foo=bar", "IMAGE", null, false, null, tr ue);
78 { 82 testMatch("^foo=bar^", "http://abc/?a=b&foo=bar", "IMAGE", null, false, null , true);
79 testMatch(test, "abc^d", "http://abc/def", "IMAGE", null, false, null, true); 83 testMatch("^foo=bar^", "http://abc/?foo=bar&a=b", "IMAGE", null, false, null , true);
80 testMatch(test, "abc^e", "http://abc/def", "IMAGE", null, false, null, false); 84 testMatch("^foo=bar^", "http://abc/?notfoo=bar", "IMAGE", null, false, null, false);
81 testMatch(test, "def^", "http://abc/def", "IMAGE", null, false, null, true); 85 testMatch("^foo=bar^", "http://abc/?foo=barnot", "IMAGE", null, false, null, false);
82 testMatch(test, "http://abc/d^f", "http://abc/def", "IMAGE", null, false, null , false); 86 testMatch("^foo=bar^", "http://abc/?foo=bar%2Enot", "IMAGE", null, false, nu ll, false);
83 testMatch(test, "http://abc/def^", "http://abc/def", "IMAGE", null, false, nul l, true); 87 testMatch("||example.com^", "http://example.com/foo/bar", "IMAGE", null, fal se, null, true);
84 testMatch(test, "^foo=bar^", "http://abc/?foo=bar", "IMAGE", null, false, null , true); 88 testMatch("||example.com^", "http://example.company.com/foo/bar", "IMAGE", n ull, false, null, false);
85 testMatch(test, "^foo=bar^", "http://abc/?a=b&foo=bar", "IMAGE", null, false, null, true); 89 testMatch("||example.com^", "http://example.com:1234/foo/bar", "IMAGE", null , false, null, true);
86 testMatch(test, "^foo=bar^", "http://abc/?foo=bar&a=b", "IMAGE", null, false, null, true); 90 testMatch("||example.com^", "http://example.com.com/foo/bar", "IMAGE", null, false, null, false);
87 testMatch(test, "^foo=bar^", "http://abc/?notfoo=bar", "IMAGE", null, false, n ull, false); 91 testMatch("||example.com^", "http://example.com-company.com/foo/bar", "IMAGE ", null, false, null, false);
88 testMatch(test, "^foo=bar^", "http://abc/?foo=barnot", "IMAGE", null, false, n ull, false); 92 testMatch("||example.com^foo", "http://example.com/foo/bar", "IMAGE", null, false, null, true);
89 testMatch(test, "^foo=bar^", "http://abc/?foo=bar%2Enot", "IMAGE", null, false , null, false); 93 testMatch("||пример.ру^", "http://пример.ру/foo/bar", "IMAGE", null, false, null, true);
90 testMatch(test, "||example.com^", "http://example.com/foo/bar", "IMAGE", null, false, null, true); 94 testMatch("||пример.ру^", "http://пример.руководитель.ру/foo/bar", "IMAGE", null, false, null, false);
91 testMatch(test, "||example.com^", "http://example.company.com/foo/bar", "IMAGE ", null, false, null, false); 95 testMatch("||пример.ру^", "http://пример.ру:1234/foo/bar", "IMAGE", null, fa lse, null, true);
92 testMatch(test, "||example.com^", "http://example.com:1234/foo/bar", "IMAGE", null, false, null, true); 96 testMatch("||пример.ру^", "http://пример.ру.ру/foo/bar", "IMAGE", null, fals e, null, false);
93 testMatch(test, "||example.com^", "http://example.com.com/foo/bar", "IMAGE", n ull, false, null, false); 97 testMatch("||пример.ру^", "http://пример.ру-ководитель.ру/foo/bar", "IMAGE", null, false, null, false);
94 testMatch(test, "||example.com^", "http://example.com-company.com/foo/bar", "I MAGE", null, false, null, false); 98 testMatch("||пример.ру^foo", "http://пример.ру/foo/bar", "IMAGE", null, fals e, null, true);
95 testMatch(test, "||example.com^foo", "http://example.com/foo/bar", "IMAGE", nu ll, false, null, true); 99 });
96 testMatch(test, "||пример.ру^", "http://пример.ру/foo/bar", "IMAGE", null, fal se, null, true); 100
97 testMatch(test, "||пример.ру^", "http://пример.руководитель.ру/foo/bar", "IMAG E", null, false, null, false); 101 it("Wildcard matching", () =>
98 testMatch(test, "||пример.ру^", "http://пример.ру:1234/foo/bar", "IMAGE", null , false, null, true); 102 {
99 testMatch(test, "||пример.ру^", "http://пример.ру.ру/foo/bar", "IMAGE", null, false, null, false); 103 testMatch("abc*d", "http://abc/adf", "IMAGE", null, false, null, true);
100 testMatch(test, "||пример.ру^", "http://пример.ру-ководитель.ру/foo/bar", "IMA GE", null, false, null, false); 104 testMatch("abc*d", "http://abcd/af", "IMAGE", null, false, null, true);
101 testMatch(test, "||пример.ру^foo", "http://пример.ру/foo/bar", "IMAGE", null, false, null, true); 105 testMatch("abc*d", "http://abc/d/af", "IMAGE", null, false, null, true);
102 106 testMatch("abc*d", "http://dabc/af", "IMAGE", null, false, null, false);
103 test.done(); 107 testMatch("*abc", "http://abc/adf", "IMAGE", null, false, null, true);
104 }; 108 testMatch("abc*", "http://abc/adf", "IMAGE", null, false, null, true);
105 109 testMatch("|*abc", "http://abc/adf", "IMAGE", null, false, null, true);
106 exports.testWildcardMatching = function(test) 110 testMatch("abc*|", "http://abc/adf", "IMAGE", null, false, null, true);
107 { 111 testMatch("abc***d", "http://abc/adf", "IMAGE", null, false, null, true);
108 testMatch(test, "abc*d", "http://abc/adf", "IMAGE", null, false, null, true); 112 });
109 testMatch(test, "abc*d", "http://abcd/af", "IMAGE", null, false, null, true); 113
110 testMatch(test, "abc*d", "http://abc/d/af", "IMAGE", null, false, null, true); 114 it("Type options", () =>
111 testMatch(test, "abc*d", "http://dabc/af", "IMAGE", null, false, null, false); 115 {
112 testMatch(test, "*abc", "http://abc/adf", "IMAGE", null, false, null, true); 116 testMatch("abc$image", "http://abc/adf", "IMAGE", null, false, null, true);
113 testMatch(test, "abc*", "http://abc/adf", "IMAGE", null, false, null, true); 117 testMatch("abc$other", "http://abc/adf", "IMAGE", null, false, null, false);
114 testMatch(test, "|*abc", "http://abc/adf", "IMAGE", null, false, null, true); 118 testMatch("abc$other", "http://abc/adf", "OTHER", null, false, null, true);
115 testMatch(test, "abc*|", "http://abc/adf", "IMAGE", null, false, null, true); 119 testMatch("abc$~other", "http://abc/adf", "OTHER", null, false, null, false) ;
116 testMatch(test, "abc***d", "http://abc/adf", "IMAGE", null, false, null, true) ; 120 testMatch("abc$script", "http://abc/adf", "IMAGE", null, false, null, false) ;
117 121 testMatch("abc$script", "http://abc/adf", "SCRIPT", null, false, null, true) ;
118 test.done(); 122 testMatch("abc$~script", "http://abc/adf", "SCRIPT", null, false, null, fals e);
119 }; 123 testMatch("abc$stylesheet", "http://abc/adf", "IMAGE", null, false, null, fa lse);
120 124 testMatch("abc$stylesheet", "http://abc/adf", "STYLESHEET", null, false, nul l, true);
121 exports.testTypeOptions = function(test) 125 testMatch("abc$~stylesheet", "http://abc/adf", "STYLESHEET", null, false, nu ll, false);
122 { 126 testMatch("abc$object", "http://abc/adf", "IMAGE", null, false, null, false) ;
123 testMatch(test, "abc$image", "http://abc/adf", "IMAGE", null, false, null, tru e); 127 testMatch("abc$object", "http://abc/adf", "OBJECT", null, false, null, true) ;
124 testMatch(test, "abc$other", "http://abc/adf", "IMAGE", null, false, null, fal se); 128 testMatch("abc$~object", "http://abc/adf", "OBJECT", null, false, null, fals e);
125 testMatch(test, "abc$other", "http://abc/adf", "OTHER", null, false, null, tru e); 129 testMatch("abc$document", "http://abc/adf", "IMAGE", null, false, null, fals e);
126 testMatch(test, "abc$~other", "http://abc/adf", "OTHER", null, false, null, fa lse); 130 testMatch("abc$document", "http://abc/adf", "DOCUMENT", null, false, null, t rue);
127 testMatch(test, "abc$script", "http://abc/adf", "IMAGE", null, false, null, fa lse); 131 testMatch("abc$~document", "http://abc/adf", "DOCUMENT", null, false, null, false);
128 testMatch(test, "abc$script", "http://abc/adf", "SCRIPT", null, false, null, t rue); 132 testMatch("abc$subdocument", "http://abc/adf", "IMAGE", null, false, null, f alse);
129 testMatch(test, "abc$~script", "http://abc/adf", "SCRIPT", null, false, null, false); 133 testMatch("abc$subdocument", "http://abc/adf", "SUBDOCUMENT", null, false, n ull, true);
130 testMatch(test, "abc$stylesheet", "http://abc/adf", "IMAGE", null, false, null , false); 134 testMatch("abc$~subdocument", "http://abc/adf", "SUBDOCUMENT", null, false, null, false);
131 testMatch(test, "abc$stylesheet", "http://abc/adf", "STYLESHEET", null, false, null, true); 135 testMatch("abc$websocket", "http://abc/adf", "OBJECT", null, false, null, fa lse);
132 testMatch(test, "abc$~stylesheet", "http://abc/adf", "STYLESHEET", null, false , null, false); 136 testMatch("abc$websocket", "http://abc/adf", "WEBSOCKET", null, false, null, true);
133 testMatch(test, "abc$object", "http://abc/adf", "IMAGE", null, false, null, fa lse); 137 testMatch("abc$~websocket", "http://abc/adf", "WEBSOCKET", null, false, null , false);
134 testMatch(test, "abc$object", "http://abc/adf", "OBJECT", null, false, null, t rue); 138 testMatch("abc$webrtc", "http://abc/adf", "OBJECT", null, false, null, false );
135 testMatch(test, "abc$~object", "http://abc/adf", "OBJECT", null, false, null, false); 139 testMatch("abc$webrtc", "http://abc/adf", "WEBRTC", null, false, null, true) ;
136 testMatch(test, "abc$document", "http://abc/adf", "IMAGE", null, false, null, false); 140 testMatch("abc$~webrtc", "http://abc/adf", "WEBRTC", null, false, null, fals e);
137 testMatch(test, "abc$document", "http://abc/adf", "DOCUMENT", null, false, nul l, true); 141 testMatch("abc$background", "http://abc/adf", "OBJECT", null, false, null, f alse);
138 testMatch(test, "abc$~document", "http://abc/adf", "DOCUMENT", null, false, nu ll, false); 142 testMatch("abc$background", "http://abc/adf", "IMAGE", null, false, null, tr ue);
139 testMatch(test, "abc$subdocument", "http://abc/adf", "IMAGE", null, false, nul l, false); 143 testMatch("abc$~background", "http://abc/adf", "IMAGE", null, false, null, f alse);
140 testMatch(test, "abc$subdocument", "http://abc/adf", "SUBDOCUMENT", null, fals e, null, true); 144 testMatch("abc$xbl", "http://abc/adf", "IMAGE", null, false, null, false);
141 testMatch(test, "abc$~subdocument", "http://abc/adf", "SUBDOCUMENT", null, fal se, null, false); 145 testMatch("abc$xbl", "http://abc/adf", "XBL", null, false, null, true);
142 testMatch(test, "abc$websocket", "http://abc/adf", "OBJECT", null, false, null , false); 146 testMatch("abc$~xbl", "http://abc/adf", "XBL", null, false, null, false);
143 testMatch(test, "abc$websocket", "http://abc/adf", "WEBSOCKET", null, false, n ull, true); 147 testMatch("abc$ping", "http://abc/adf", "IMAGE", null, false, null, false);
144 testMatch(test, "abc$~websocket", "http://abc/adf", "WEBSOCKET", null, false, null, false); 148 testMatch("abc$ping", "http://abc/adf", "PING", null, false, null, true);
145 testMatch(test, "abc$webrtc", "http://abc/adf", "OBJECT", null, false, null, f alse); 149 testMatch("abc$~ping", "http://abc/adf", "PING", null, false, null, false);
146 testMatch(test, "abc$webrtc", "http://abc/adf", "WEBRTC", null, false, null, t rue); 150 testMatch("abc$xmlhttprequest", "http://abc/adf", "IMAGE", null, false, null , false);
147 testMatch(test, "abc$~webrtc", "http://abc/adf", "WEBRTC", null, false, null, false); 151 testMatch("abc$xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", null, fa lse, null, true);
148 testMatch(test, "abc$background", "http://abc/adf", "OBJECT", null, false, nul l, false); 152 testMatch("abc$~xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", null, f alse, null, false);
149 testMatch(test, "abc$background", "http://abc/adf", "IMAGE", null, false, null , true); 153 testMatch("abc$object-subrequest", "http://abc/adf", "IMAGE", null, false, n ull, false);
150 testMatch(test, "abc$~background", "http://abc/adf", "IMAGE", null, false, nul l, false); 154 testMatch("abc$object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST", nu ll, false, null, true);
151 testMatch(test, "abc$xbl", "http://abc/adf", "IMAGE", null, false, null, false ); 155 testMatch("abc$~object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST", n ull, false, null, false);
152 testMatch(test, "abc$xbl", "http://abc/adf", "XBL", null, false, null, true); 156 testMatch("abc$dtd", "http://abc/adf", "IMAGE", null, false, null, false);
153 testMatch(test, "abc$~xbl", "http://abc/adf", "XBL", null, false, null, false) ; 157 testMatch("abc$dtd", "http://abc/adf", "DTD", null, false, null, true);
154 testMatch(test, "abc$ping", "http://abc/adf", "IMAGE", null, false, null, fals e); 158 testMatch("abc$~dtd", "http://abc/adf", "DTD", null, false, null, false);
155 testMatch(test, "abc$ping", "http://abc/adf", "PING", null, false, null, true) ; 159
156 testMatch(test, "abc$~ping", "http://abc/adf", "PING", null, false, null, fals e); 160 testMatch("abc$media", "http://abc/adf", "IMAGE", null, false, null, false);
157 testMatch(test, "abc$xmlhttprequest", "http://abc/adf", "IMAGE", null, false, null, false); 161 testMatch("abc$media", "http://abc/adf", "MEDIA", null, false, null, true);
158 testMatch(test, "abc$xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", null , false, null, true); 162 testMatch("abc$~media", "http://abc/adf", "MEDIA", null, false, null, false) ;
159 testMatch(test, "abc$~xmlhttprequest", "http://abc/adf", "XMLHTTPREQUEST", nul l, false, null, false); 163
160 testMatch(test, "abc$object-subrequest", "http://abc/adf", "IMAGE", null, fals e, null, false); 164 testMatch("abc$font", "http://abc/adf", "IMAGE", null, false, null, false);
161 testMatch(test, "abc$object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST" , null, false, null, true); 165 testMatch("abc$font", "http://abc/adf", "FONT", null, false, null, true);
162 testMatch(test, "abc$~object-subrequest", "http://abc/adf", "OBJECT_SUBREQUEST ", null, false, null, false); 166 testMatch("abc$~font", "http://abc/adf", "FONT", null, false, null, false);
163 testMatch(test, "abc$dtd", "http://abc/adf", "IMAGE", null, false, null, false ); 167
164 testMatch(test, "abc$dtd", "http://abc/adf", "DTD", null, false, null, true); 168 testMatch("abc$ping", "http://abc/adf", "IMAGE", null, false, null, false);
165 testMatch(test, "abc$~dtd", "http://abc/adf", "DTD", null, false, null, false) ; 169 testMatch("abc$ping", "http://abc/adf", "PING", null, false, null, true);
166 170 testMatch("abc$~ping", "http://abc/adf", "PING", null, false, null, false);
167 testMatch(test, "abc$media", "http://abc/adf", "IMAGE", null, false, null, fal se); 171
168 testMatch(test, "abc$media", "http://abc/adf", "MEDIA", null, false, null, tru e); 172 testMatch("abc$image,script", "http://abc/adf", "IMAGE", null, false, null, true);
169 testMatch(test, "abc$~media", "http://abc/adf", "MEDIA", null, false, null, fa lse); 173 testMatch("abc$~image", "http://abc/adf", "IMAGE", null, false, null, false) ;
170 174 testMatch("abc$~script", "http://abc/adf", "IMAGE", null, false, null, true) ;
171 testMatch(test, "abc$font", "http://abc/adf", "IMAGE", null, false, null, fals e); 175 testMatch("abc$~image,~script", "http://abc/adf", "IMAGE", null, false, null , false);
172 testMatch(test, "abc$font", "http://abc/adf", "FONT", null, false, null, true) ; 176 testMatch("abc$~script,~image", "http://abc/adf", "IMAGE", null, false, null , false);
173 testMatch(test, "abc$~font", "http://abc/adf", "FONT", null, false, null, fals e); 177 testMatch("abc$~document,~script,~other", "http://abc/adf", "IMAGE", null, f alse, null, true);
174 178 testMatch("abc$~image,image", "http://abc/adf", "IMAGE", null, false, null, true);
175 testMatch(test, "abc$ping", "http://abc/adf", "IMAGE", null, false, null, fals e); 179 testMatch("abc$image,~image", "http://abc/adf", "IMAGE", null, false, null, false);
176 testMatch(test, "abc$ping", "http://abc/adf", "PING", null, false, null, true) ; 180 testMatch("abc$~image,image", "http://abc/adf", "SCRIPT", null, false, null, true);
177 testMatch(test, "abc$~ping", "http://abc/adf", "PING", null, false, null, fals e); 181 testMatch("abc$image,~image", "http://abc/adf", "SCRIPT", null, false, null, false);
178 182 testMatch("abc$match-case", "http://abc/adf", "IMAGE", null, false, null, tr ue);
179 testMatch(test, "abc$image,script", "http://abc/adf", "IMAGE", null, false, nu ll, true); 183 testMatch("abc$match-case", "http://ABC/adf", "IMAGE", null, false, null, fa lse);
180 testMatch(test, "abc$~image", "http://abc/adf", "IMAGE", null, false, null, fa lse); 184 testMatch("abc$~match-case", "http://abc/adf", "IMAGE", null, false, null, t rue);
181 testMatch(test, "abc$~script", "http://abc/adf", "IMAGE", null, false, null, t rue); 185 testMatch("abc$~match-case", "http://ABC/adf", "IMAGE", null, false, null, t rue);
182 testMatch(test, "abc$~image,~script", "http://abc/adf", "IMAGE", null, false, null, false); 186 testMatch("abc$match-case,image", "http://abc/adf", "IMAGE", null, false, nu ll, true);
183 testMatch(test, "abc$~script,~image", "http://abc/adf", "IMAGE", null, false, null, false); 187 testMatch("abc$match-case,script", "http://abc/adf", "IMAGE", null, false, n ull, false);
184 testMatch(test, "abc$~document,~script,~other", "http://abc/adf", "IMAGE", nul l, false, null, true); 188 testMatch("abc$match-case,image", "http://ABC/adf", "IMAGE", null, false, nu ll, false);
185 testMatch(test, "abc$~image,image", "http://abc/adf", "IMAGE", null, false, nu ll, true); 189 testMatch("abc$match-case,script", "http://ABC/adf", "IMAGE", null, false, n ull, false);
186 testMatch(test, "abc$image,~image", "http://abc/adf", "IMAGE", null, false, nu ll, false); 190 testMatch("abc$third-party", "http://abc/adf", "IMAGE", null, false, null, f alse);
187 testMatch(test, "abc$~image,image", "http://abc/adf", "SCRIPT", null, false, n ull, true); 191 testMatch("abc$third-party", "http://abc/adf", "IMAGE", null, true, null, tr ue);
188 testMatch(test, "abc$image,~image", "http://abc/adf", "SCRIPT", null, false, n ull, false); 192 testMatch("abd$third-party", "http://abc/adf", "IMAGE", null, false, null, f alse);
189 testMatch(test, "abc$match-case", "http://abc/adf", "IMAGE", null, false, null , true); 193 testMatch("abd$third-party", "http://abc/adf", "IMAGE", null, true, null, fa lse);
190 testMatch(test, "abc$match-case", "http://ABC/adf", "IMAGE", null, false, null , false); 194 testMatch("abc$image,third-party", "http://abc/adf", "IMAGE", null, false, n ull, false);
191 testMatch(test, "abc$~match-case", "http://abc/adf", "IMAGE", null, false, nul l, true); 195 testMatch("abc$image,third-party", "http://abc/adf", "IMAGE", null, true, nu ll, true);
192 testMatch(test, "abc$~match-case", "http://ABC/adf", "IMAGE", null, false, nul l, true); 196 testMatch("abc$~image,third-party", "http://abc/adf", "IMAGE", null, false, null, false);
193 testMatch(test, "abc$match-case,image", "http://abc/adf", "IMAGE", null, false , null, true); 197 testMatch("abc$~image,third-party", "http://abc/adf", "IMAGE", null, true, n ull, false);
194 testMatch(test, "abc$match-case,script", "http://abc/adf", "IMAGE", null, fals e, null, false); 198 testMatch("abc$~third-party", "http://abc/adf", "IMAGE", null, false, null, true);
195 testMatch(test, "abc$match-case,image", "http://ABC/adf", "IMAGE", null, false , null, false); 199 testMatch("abc$~third-party", "http://abc/adf", "IMAGE", null, true, null, f alse);
196 testMatch(test, "abc$match-case,script", "http://ABC/adf", "IMAGE", null, fals e, null, false); 200 testMatch("abd$~third-party", "http://abc/adf", "IMAGE", null, false, null, false);
197 testMatch(test, "abc$third-party", "http://abc/adf", "IMAGE", null, false, nul l, false); 201 testMatch("abd$~third-party", "http://abc/adf", "IMAGE", null, true, null, f alse);
198 testMatch(test, "abc$third-party", "http://abc/adf", "IMAGE", null, true, null , true); 202 testMatch("abc$image,~third-party", "http://abc/adf", "IMAGE", null, false, null, true);
199 testMatch(test, "abd$third-party", "http://abc/adf", "IMAGE", null, false, nul l, false); 203 testMatch("abc$image,~third-party", "http://abc/adf", "IMAGE", null, true, n ull, false);
200 testMatch(test, "abd$third-party", "http://abc/adf", "IMAGE", null, true, null , false); 204 testMatch("abc$~image,~third-party", "http://abc/adf", "IMAGE", null, false, null, false);
201 testMatch(test, "abc$image,third-party", "http://abc/adf", "IMAGE", null, fals e, null, false); 205 });
202 testMatch(test, "abc$image,third-party", "http://abc/adf", "IMAGE", null, true , null, true); 206
203 testMatch(test, "abc$~image,third-party", "http://abc/adf", "IMAGE", null, fal se, null, false); 207 it("Regular Expressions", () =>
204 testMatch(test, "abc$~image,third-party", "http://abc/adf", "IMAGE", null, tru e, null, false); 208 {
205 testMatch(test, "abc$~third-party", "http://abc/adf", "IMAGE", null, false, nu ll, true); 209 testMatch("/abc/", "http://abc/adf", "IMAGE", null, false, null, true);
206 testMatch(test, "abc$~third-party", "http://abc/adf", "IMAGE", null, true, nul l, false); 210 testMatch("/abc/", "http://abcd/adf", "IMAGE", null, false, null, true);
207 testMatch(test, "abd$~third-party", "http://abc/adf", "IMAGE", null, false, nu ll, false); 211 testMatch("*/abc/", "http://abc/adf", "IMAGE", null, false, null, true);
208 testMatch(test, "abd$~third-party", "http://abc/adf", "IMAGE", null, true, nul l, false); 212 testMatch("*/abc/", "http://abcd/adf", "IMAGE", null, false, null, false);
209 testMatch(test, "abc$image,~third-party", "http://abc/adf", "IMAGE", null, fal se, null, true); 213 testMatch("/a\\wc/", "http://abc/adf", "IMAGE", null, false, null, true);
210 testMatch(test, "abc$image,~third-party", "http://abc/adf", "IMAGE", null, tru e, null, false); 214 testMatch("/a\\wc/", "http://a1c/adf", "IMAGE", null, false, null, true);
211 testMatch(test, "abc$~image,~third-party", "http://abc/adf", "IMAGE", null, fa lse, null, false); 215 testMatch("/a\\wc/", "http://a_c/adf", "IMAGE", null, false, null, true);
212 216 testMatch("/a\\wc/", "http://a%c/adf", "IMAGE", null, false, null, false);
213 test.done(); 217 });
214 }; 218
215 219 it("Regular Expressions with type options", () =>
216 exports.testRegularExpressions = function(test) 220 {
217 { 221 testMatch("/abc/$image", "http://abc/adf", "IMAGE", null, false, null, true) ;
218 testMatch(test, "/abc/", "http://abc/adf", "IMAGE", null, false, null, true); 222 testMatch("/abc/$image", "http://aBc/adf", "IMAGE", null, false, null, true) ;
219 testMatch(test, "/abc/", "http://abcd/adf", "IMAGE", null, false, null, true); 223 testMatch("/abc/$script", "http://abc/adf", "IMAGE", null, false, null, fals e);
220 testMatch(test, "*/abc/", "http://abc/adf", "IMAGE", null, false, null, true); 224 testMatch("/abc/$~image", "http://abcd/adf", "IMAGE", null, false, null, fal se);
221 testMatch(test, "*/abc/", "http://abcd/adf", "IMAGE", null, false, null, false ); 225 testMatch("/ab{2}c/$image", "http://abc/adf", "IMAGE", null, false, null, fa lse);
222 testMatch(test, "/a\\wc/", "http://abc/adf", "IMAGE", null, false, null, true) ; 226 testMatch("/ab{2}c/$script", "http://abc/adf", "IMAGE", null, false, null, f alse);
223 testMatch(test, "/a\\wc/", "http://a1c/adf", "IMAGE", null, false, null, true) ; 227 testMatch("/ab{2}c/$~image", "http://abcd/adf", "IMAGE", null, false, null, false);
224 testMatch(test, "/a\\wc/", "http://a_c/adf", "IMAGE", null, false, null, true) ; 228 testMatch("/abc/$third-party", "http://abc/adf", "IMAGE", null, false, null, false);
225 testMatch(test, "/a\\wc/", "http://a%c/adf", "IMAGE", null, false, null, false ); 229 testMatch("/abc/$third-party", "http://abc/adf", "IMAGE", null, true, null, true);
226 230 testMatch("/abc/$~third-party", "http://abc/adf", "IMAGE", null, false, null , true);
227 test.done(); 231 testMatch("/abc/$~third-party", "http://abc/adf", "IMAGE", null, true, null, false);
228 }; 232 testMatch("/abc/$match-case", "http://abc/adf", "IMAGE", null, false, null, true);
229 233 testMatch("/abc/$match-case", "http://aBc/adf", "IMAGE", null, true, null, f alse);
230 exports.testRegularExpressionsWithTypeOptions = function(test) 234 testMatch("/ab{2}c/$match-case", "http://abc/adf", "IMAGE", null, false, nul l, false);
231 { 235 testMatch("/ab{2}c/$match-case", "http://aBc/adf", "IMAGE", null, true, null , false);
232 testMatch(test, "/abc/$image", "http://abc/adf", "IMAGE", null, false, null, t rue); 236 testMatch("/abc/$~match-case", "http://abc/adf", "IMAGE", null, false, null, true);
233 testMatch(test, "/abc/$image", "http://aBc/adf", "IMAGE", null, false, null, t rue); 237 testMatch("/abc/$~match-case", "http://aBc/adf", "IMAGE", null, true, null, true);
234 testMatch(test, "/abc/$script", "http://abc/adf", "IMAGE", null, false, null, false); 238 testMatch("/ab{2}c/$~match-case", "http://abc/adf", "IMAGE", null, false, nu ll, false);
235 testMatch(test, "/abc/$~image", "http://abcd/adf", "IMAGE", null, false, null, false); 239 testMatch("/ab{2}c/$~match-case", "http://aBc/adf", "IMAGE", null, true, nul l, false);
236 testMatch(test, "/ab{2}c/$image", "http://abc/adf", "IMAGE", null, false, null , false); 240 });
237 testMatch(test, "/ab{2}c/$script", "http://abc/adf", "IMAGE", null, false, nul l, false); 241
238 testMatch(test, "/ab{2}c/$~image", "http://abcd/adf", "IMAGE", null, false, nu ll, false); 242 it("Domain restrictions", () =>
239 testMatch(test, "/abc/$third-party", "http://abc/adf", "IMAGE", null, false, n ull, false); 243 {
240 testMatch(test, "/abc/$third-party", "http://abc/adf", "IMAGE", null, true, nu ll, true); 244 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com", true, null, true);
241 testMatch(test, "/abc/$~third-party", "http://abc/adf", "IMAGE", null, false, null, true); 245 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com.", true, null, true);
242 testMatch(test, "/abc/$~third-party", "http://abc/adf", "IMAGE", null, true, n ull, false); 246 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com", tr ue, null, true);
243 testMatch(test, "/abc/$match-case", "http://abc/adf", "IMAGE", null, false, nu ll, true); 247 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com.", t rue, null, true);
244 testMatch(test, "/abc/$match-case", "http://aBc/adf", "IMAGE", null, true, nul l, false); 248 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "Foo.com", true, null, true);
245 testMatch(test, "/ab{2}c/$match-case", "http://abc/adf", "IMAGE", null, false, null, false); 249 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "abc.def.foo.com" , true, null, true);
246 testMatch(test, "/ab{2}c/$match-case", "http://aBc/adf", "IMAGE", null, true, null, false); 250 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", "www.baz.com", tr ue, null, false);
247 testMatch(test, "/abc/$~match-case", "http://abc/adf", "IMAGE", null, false, n ull, true); 251 testMatch("abc$domain=foo.com", "http://abc/def", "IMAGE", null, true, null, false);
248 testMatch(test, "/abc/$~match-case", "http://aBc/adf", "IMAGE", null, true, nu ll, true); 252 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo.com" , true, null, true);
249 testMatch(test, "/ab{2}c/$~match-case", "http://abc/adf", "IMAGE", null, false , null, false); 253 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo.com. ", true, null, true);
250 testMatch(test, "/ab{2}c/$~match-case", "http://aBc/adf", "IMAGE", null, true, null, false); 254 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www.foo. com", true, null, true);
251 255 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www.foo. com.", true, null, true);
252 test.done(); 256 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "Foo.com" , true, null, true);
253 }; 257 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "abc.def. foo.com", true, null, true);
254 258 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www.baz. com", true, null, false);
255 exports.testDomainRestrictions = function(test) 259 testMatch("abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", null, tru e, null, false);
256 { 260 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo.com" , true, null, true);
257 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com", tr ue, null, true); 261 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo.com. ", true, null, true);
258 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "foo.com.", t rue, null, true); 262 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www.foo. com", true, null, true);
259 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com" , true, null, true); 263 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www.foo. com.", true, null, true);
260 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "www.foo.com. ", true, null, true); 264 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "Foo.com" , true, null, true);
261 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "Foo.com", tr ue, null, true); 265 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "abc.def. foo.com", true, null, true);
262 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "abc.def.foo. com", true, null, true); 266 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www.baz. com", true, null, false);
263 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", "www.baz.com" , true, null, false); 267 testMatch("abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", null, tru e, null, false);
264 testMatch(test, "abc$domain=foo.com", "http://abc/def", "IMAGE", null, true, n ull, false); 268 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com", true, null, false);
265 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo. com", true, null, true); 269 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com.", true , null, false);
266 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "foo. com.", true, null, true); 270 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com", t rue, null, false);
267 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www. foo.com", true, null, true); 271 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com.", true, null, false);
268 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www. foo.com.", true, null, true); 272 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "Foo.com", true, null, false);
269 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "Foo. com", true, null, true); 273 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "abc.def.foo.com ", true, null, false);
270 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "abc. def.foo.com", true, null, true); 274 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.baz.com", t rue, null, true);
271 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", "www. baz.com", true, null, false); 275 testMatch("abc$domain=~foo.com", "http://abc/def", "IMAGE", null, true, null , true);
272 testMatch(test, "abc$domain=foo.com|bar.com", "http://abc/def", "IMAGE", null, true, null, false); 276 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "foo.co m", true, null, false);
273 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo. com", true, null, true); 277 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "foo.co m.", true, null, false);
274 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "foo. com.", true, null, true); 278 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "www.fo o.com", true, null, false);
275 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www. foo.com", true, null, true); 279 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "www.fo o.com.", true, null, false);
276 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www. foo.com.", true, null, true); 280 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "Foo.co m", true, null, false);
277 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "Foo. com", true, null, true); 281 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "abc.de f.foo.com", true, null, false);
278 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "abc. def.foo.com", true, null, true); 282 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "www.ba z.com", true, null, true);
279 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", "www. baz.com", true, null, false); 283 testMatch("abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", null, t rue, null, true);
280 testMatch(test, "abc$domain=bar.com|foo.com", "http://abc/def", "IMAGE", null, true, null, false); 284 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "foo.co m", true, null, false);
281 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com", t rue, null, false); 285 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "foo.co m.", true, null, false);
282 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "foo.com.", true, null, false); 286 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "www.fo o.com", true, null, false);
283 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com ", true, null, false); 287 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "www.fo o.com.", true, null, false);
284 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.foo.com .", true, null, false); 288 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "Foo.co m", true, null, false);
285 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "Foo.com", t rue, null, false); 289 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "abc.de f.foo.com", true, null, false);
286 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "abc.def.foo .com", true, null, false); 290 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "www.ba z.com", true, null, true);
287 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", "www.baz.com ", true, null, true); 291 testMatch("abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", null, t rue, null, true);
288 testMatch(test, "abc$domain=~foo.com", "http://abc/def", "IMAGE", null, true, null, true); 292 testMatch("abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "foo.com ", true, null, true);
289 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "fo o.com", true, null, false); 293 testMatch("abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "bar.com ", true, null, false);
290 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "fo o.com.", true, null, false); 294 testMatch("abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "baz.com ", true, null, false);
291 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ww w.foo.com", true, null, false); 295 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "foo .com", true, null, true);
292 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ww w.foo.com.", true, null, false); 296 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www .foo.com", true, null, true);
293 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "Fo o.com", true, null, false); 297 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "bar .foo.com", true, null, false);
294 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ab c.def.foo.com", true, null, false); 298 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www .bar.foo.com", true, null, false);
295 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", "ww w.baz.com", true, null, true); 299 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "baz .com", true, null, false);
296 testMatch(test, "abc$domain=~foo.com|~bar.com", "http://abc/def", "IMAGE", nul l, true, null, true); 300 testMatch("abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www .baz.com", true, null, false);
297 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "fo o.com", true, null, false); 301 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.com", t rue, null, true);
298 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "fo o.com.", true, null, false); 302 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.net", t rue, null, false);
299 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ww w.foo.com", true, null, false); 303 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.com", t rue, null, false);
300 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ww w.foo.com.", true, null, false); 304 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.net", t rue, null, false);
301 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "Fo o.com", true, null, false); 305 testMatch("abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "com", true, null, true);
302 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ab c.def.foo.com", true, null, false); 306 testMatch("abc$domain=foo.com", "http://ccc/def", "IMAGE", "foo.com", true, null, false);
303 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", "ww w.baz.com", true, null, true); 307 testMatch("abc$domain=foo.com", "http://ccc/def", "IMAGE", "bar.com", true, null, false);
304 testMatch(test, "abc$domain=~bar.com|~foo.com", "http://abc/def", "IMAGE", nul l, true, null, true); 308 testMatch("abc$image,domain=foo.com", "http://abc/def", "IMAGE", "foo.com", true, null, true);
305 testMatch(test, "abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "foo .com", true, null, true); 309 testMatch("abc$image,domain=foo.com", "http://abc/def", "IMAGE", "bar.com", true, null, false);
306 testMatch(test, "abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "bar .com", true, null, false); 310 testMatch("abc$image,domain=foo.com", "http://abc/def", "OBJECT", "foo.com", true, null, false);
307 testMatch(test, "abc$domain=foo.com|~bar.com", "http://abc/def", "IMAGE", "baz .com", true, null, false); 311 testMatch("abc$image,domain=foo.com", "http://abc/def", "OBJECT", "bar.com", true, null, false);
308 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "foo.com", true, null, true); 312 testMatch("abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "foo.com", true, null, false);
309 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www.foo.com", true, null, true); 313 testMatch("abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "bar.com", true, null, false);
310 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "bar.foo.com", true, null, false); 314 testMatch("abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "foo.com" , true, null, true);
311 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www.bar.foo.com", true, null, false); 315 testMatch("abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "bar.com" , true, null, false);
312 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "baz.com", true, null, false); 316 testMatch("abc$domain=foo.com,image", "http://abc/def", "IMAGE", "foo.com", true, null, true);
313 testMatch(test, "abc$domain=foo.com|~bar.foo.com", "http://abc/def", "IMAGE", "www.baz.com", true, null, false); 317 testMatch("abc$domain=foo.com,image", "http://abc/def", "IMAGE", "bar.com", true, null, false);
314 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.com ", true, null, true); 318 testMatch("abc$domain=foo.com,image", "http://abc/def", "OBJECT", "foo.com", true, null, false);
315 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "bar.net ", true, null, false); 319 testMatch("abc$domain=foo.com,image", "http://abc/def", "OBJECT", "bar.com", true, null, false);
316 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.com ", true, null, false); 320 testMatch("abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "foo.com", true, null, false);
317 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "foo.net ", true, null, false); 321 testMatch("abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "bar.com", true, null, false);
318 testMatch(test, "abc$domain=com|~foo.com", "http://abc/def", "IMAGE", "com", t rue, null, true); 322 testMatch("abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "foo.com" , true, null, true);
319 testMatch(test, "abc$domain=foo.com", "http://ccc/def", "IMAGE", "foo.com", tr ue, null, false); 323 testMatch("abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "bar.com" , true, null, false);
320 testMatch(test, "abc$domain=foo.com", "http://ccc/def", "IMAGE", "bar.com", tr ue, null, false); 324 });
321 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "IMAGE", "foo.co m", true, null, true); 325
322 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "IMAGE", "bar.co m", true, null, false); 326 it("Sitekey restrictions", () =>
323 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "OBJECT", "foo.c om", true, null, false); 327 {
324 testMatch(test, "abc$image,domain=foo.com", "http://abc/def", "OBJECT", "bar.c om", true, null, false); 328 testMatch("abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, "foo-publickey", true);
325 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "foo.c om", true, null, false); 329 testMatch("abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, null, false);
326 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "IMAGE", "bar.c om", true, null, false); 330 testMatch("abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, "bar-publickey", false);
327 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "foo. com", true, null, true); 331 testMatch("abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", "IMAG E", "foo.com", true, "foo-publickey", true);
328 testMatch(test, "abc$~image,domain=foo.com", "http://abc/def", "OBJECT", "bar. com", true, null, false); 332 testMatch("abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", "IMAG E", "foo.com", true, null, false);
329 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "IMAGE", "foo.co m", true, null, true); 333 testMatch("abc$sitekey=bar-publickey|foo-publickey", "http://abc/def", "IMAG E", "foo.com", true, "foo-publickey", true);
330 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "IMAGE", "bar.co m", true, null, false); 334 testMatch("abc$sitekey=foo-publickey", "http://ccc/def", "IMAGE", "foo.com", true, "foo-publickey", false);
331 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "OBJECT", "foo.c om", true, null, false); 335 testMatch("abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMA GE", "foo.com", true, "foo-publickey", true);
332 testMatch(test, "abc$domain=foo.com,image", "http://abc/def", "OBJECT", "bar.c om", true, null, false); 336 testMatch("abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMA GE", "bar.com", true, "foo-publickey", false);
333 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "foo.c om", true, null, false); 337 testMatch("abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IM AGE", "foo.com", true, "foo-publickey", false);
334 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "IMAGE", "bar.c om", true, null, false); 338 testMatch("abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IM AGE", "bar.com", true, "foo-publickey", true);
335 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "foo. com", true, null, true); 339 });
336 testMatch(test, "abc$domain=foo.com,~image", "http://abc/def", "OBJECT", "bar. com", true, null, false); 340
337 341 it("Exception rules", () =>
338 test.done(); 342 {
339 }; 343 testMatch("@@test", "http://test/", "DOCUMENT", null, false, null, false);
340 344 testMatch("@@http://test*", "http://test/", "DOCUMENT", null, false, null, f alse);
341 exports.testSitekeyRestrictions = function(test) 345 testMatch("@@ftp://test*", "ftp://test/", "DOCUMENT", null, false, null, fal se);
342 { 346 testMatch("@@test$document", "http://test/", "DOCUMENT", null, false, null, true);
343 testMatch(test, "abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.c om", true, "foo-publickey", true); 347 testMatch("@@test$document,image", "http://test/", "DOCUMENT", null, false, null, true);
344 testMatch(test, "abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.c om", true, null, false); 348 testMatch("@@test$~image", "http://test/", "DOCUMENT", null, false, null, fa lse);
345 testMatch(test, "abc$sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.c om", true, "bar-publickey", false); 349 testMatch("@@test$~image,document", "http://test/", "DOCUMENT", null, false, null, true);
346 testMatch(test, "abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", " IMAGE", "foo.com", true, "foo-publickey", true); 350 testMatch("@@test$document,~image", "http://test/", "DOCUMENT", null, false, null, true);
347 testMatch(test, "abc$sitekey=foo-publickey|bar-publickey", "http://abc/def", " IMAGE", "foo.com", true, null, false); 351 testMatch("@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "foo .com", false, null, true);
348 testMatch(test, "abc$sitekey=bar-publickey|foo-publickey", "http://abc/def", " IMAGE", "foo.com", true, "foo-publickey", true); 352 testMatch("@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "bar .com", false, null, false);
349 testMatch(test, "abc$sitekey=foo-publickey", "http://ccc/def", "IMAGE", "foo.c om", true, "foo-publickey", false); 353 testMatch("@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "fo o.com", false, null, false);
350 testMatch(test, "abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, "foo-publickey", true); 354 testMatch("@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "ba r.com", false, null, true);
351 testMatch(test, "abc$domain=foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "bar.com", true, "foo-publickey", false); 355 testMatch("@@test$document,sitekey=foo-publickey", "http://test/", "DOCUMENT ", "foo.com", false, "foo-publickey", true);
352 testMatch(test, "abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "foo.com", true, "foo-publickey", false); 356 testMatch("@@test$document,sitekey=foo-publickey", "http://test/", "DOCUMENT ", "foo.com", false, null, false);
353 testMatch(test, "abc$domain=~foo.com,sitekey=foo-publickey", "http://abc/def", "IMAGE", "bar.com", true, "foo-publickey", true); 357 });
354 358 });
355 test.done();
356 };
357
358 exports.testExceptionRules = function(test)
359 {
360 testMatch(test, "@@test", "http://test/", "DOCUMENT", null, false, null, false );
361 testMatch(test, "@@http://test*", "http://test/", "DOCUMENT", null, false, nul l, false);
362 testMatch(test, "@@ftp://test*", "ftp://test/", "DOCUMENT", null, false, null, false);
363 testMatch(test, "@@test$document", "http://test/", "DOCUMENT", null, false, nu ll, true);
364 testMatch(test, "@@test$document,image", "http://test/", "DOCUMENT", null, fal se, null, true);
365 testMatch(test, "@@test$~image", "http://test/", "DOCUMENT", null, false, null , false);
366 testMatch(test, "@@test$~image,document", "http://test/", "DOCUMENT", null, fa lse, null, true);
367 testMatch(test, "@@test$document,~image", "http://test/", "DOCUMENT", null, fa lse, null, true);
368 testMatch(test, "@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "foo.com", false, null, true);
369 testMatch(test, "@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "bar.com", false, null, false);
370 testMatch(test, "@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "foo.com", false, null, false);
371 testMatch(test, "@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "bar.com", false, null, true);
372 testMatch(test, "@@test$document,sitekey=foo-publickey", "http://test/", "DOCU MENT", "foo.com", false, "foo-publickey", true);
373 testMatch(test, "@@test$document,sitekey=foo-publickey", "http://test/", "DOCU MENT", "foo.com", false, null, false);
374
375 test.done();
376 };
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