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

Side by Side Diff: test/filterListener.js

Issue 29892596: Issue 6992 - Remove keyword-by-filter map (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Implement faster version of isSlowFilter Created Sept. 28, 2018, 9:22 a.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 | « 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, list] of matcher.filterByKeyword) 69 for (let [keyword, set] of matcher.filterByKeyword)
70 { 70 {
71 for (let i = 0; i < list.length; i++) 71 for (let filter of set)
72 { 72 {
73 let filter = list[i]; 73 test.equal(matcher.findKeyword(filter), keyword,
74 test.equal(matcher.getKeywordForFilter(filter), keyword,
75 "Keyword of filter " + filter.text); 74 "Keyword of filter " + filter.text);
76 filters.push(filter.text); 75 filters.push(filter.text);
77 } 76 }
78 } 77 }
79 result[type] = filters; 78 result[type] = filters;
80 } 79 }
81 80
82 let elemHide = sandboxedRequire("../lib/elemHide"); 81 let elemHide = sandboxedRequire("../lib/elemHide");
83 result.elemhide = []; 82 result.elemhide = [];
84 for (let filter of elemHide.knownFilters) 83 for (let filter of elemHide.knownFilters)
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 checkKnownFilters(test, "add special subscription with filter2", {snippets: [f ilter1.text, filter2.text]}); 356 checkKnownFilters(test, "add special subscription with filter2", {snippets: [f ilter1.text, filter2.text]});
358 357
359 let subscription4 = Subscription.fromURL("https://easylist-downloads.adblockpl us.org/abp-filters-anti-cv.txt"); 358 let subscription4 = Subscription.fromURL("https://easylist-downloads.adblockpl us.org/abp-filters-anti-cv.txt");
360 subscription4.filters = [filter3]; 359 subscription4.filters = [filter3];
361 360
362 FilterStorage.addSubscription(subscription4); 361 FilterStorage.addSubscription(subscription4);
363 checkKnownFilters(test, "add ABP anti-circumvention subscription with filter3" , {snippets: [filter1.text, filter2.text, filter3.text]}); 362 checkKnownFilters(test, "add ABP anti-circumvention subscription with filter3" , {snippets: [filter1.text, filter2.text, filter3.text]});
364 363
365 test.done(); 364 test.done();
366 }; 365 };
OLDNEW
« no previous file with comments | « lib/matcher.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld