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

Side by Side Diff: test/filterListener.js

Issue 29926557: Issue 6994 - Use shortcut matching for location-only filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Fix comment Created Oct. 25, 2018, 9:27 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
« lib/matcher.js ('K') | « lib/matcher.js ('k') | no next file » | 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
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 callback(); 59 callback();
60 }; 60 };
61 61
62 function checkKnownFilters(test, text, expected) 62 function checkKnownFilters(test, text, expected)
63 { 63 {
64 let result = {}; 64 let result = {};
65 for (let type of ["blacklist", "whitelist"]) 65 for (let type of ["blacklist", "whitelist"])
66 { 66 {
67 let matcher = defaultMatcher["_" + type]; 67 let matcher = defaultMatcher["_" + type];
68 let filters = []; 68 let filters = [];
69 for (let [keyword, set] of matcher._filterByKeyword) 69 for (let map of [matcher._simpleFiltersByKeyword,
70 matcher._complexFiltersByKeyword])
70 { 71 {
71 for (let filter of set) 72 for (let [keyword, set] of map)
72 { 73 {
73 test.equal(matcher.findKeyword(filter), keyword, 74 for (let filter of set)
74 "Keyword of filter " + filter.text); 75 {
75 filters.push(filter.text); 76 test.equal(matcher.findKeyword(filter), keyword,
77 "Keyword of filter " + filter.text);
78 filters.push(filter.text);
79 }
76 } 80 }
77 } 81 }
78 result[type] = filters; 82 result[type] = filters;
79 } 83 }
80 84
81 let elemHide = sandboxedRequire("../lib/elemHide"); 85 let elemHide = sandboxedRequire("../lib/elemHide");
82 result.elemhide = []; 86 result.elemhide = [];
83 for (let filter of elemHide.knownFilters) 87 for (let filter of elemHide.knownFilters)
84 result.elemhide.push(filter.text); 88 result.elemhide.push(filter.text);
85 89
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 checkKnownFilters(test, "add special subscription with filter2", {snippets: [f ilter1.text, filter2.text]}); 360 checkKnownFilters(test, "add special subscription with filter2", {snippets: [f ilter1.text, filter2.text]});
357 361
358 let subscription4 = Subscription.fromURL("https://easylist-downloads.adblockpl us.org/abp-filters-anti-cv.txt"); 362 let subscription4 = Subscription.fromURL("https://easylist-downloads.adblockpl us.org/abp-filters-anti-cv.txt");
359 subscription4.filters = [filter3]; 363 subscription4.filters = [filter3];
360 364
361 filterStorage.addSubscription(subscription4); 365 filterStorage.addSubscription(subscription4);
362 checkKnownFilters(test, "add ABP anti-circumvention subscription with filter3" , {snippets: [filter1.text, filter2.text, filter3.text]}); 366 checkKnownFilters(test, "add ABP anti-circumvention subscription with filter3" , {snippets: [filter1.text, filter2.text, filter3.text]});
363 367
364 test.done(); 368 test.done();
365 }; 369 };
OLDNEW
« lib/matcher.js ('K') | « lib/matcher.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld