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

Side by Side Diff: test/filterListener.js

Issue 29790555: Issue 6671 - Introduce trusted subscriptions (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Make user's own filters trusted Created May 25, 2018, 6:41 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/subscriptionClasses.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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 ); 48 );
49 49
50 FilterStorage.addSubscription(Subscription.fromURL("~fl~")); 50 FilterStorage.addSubscription(Subscription.fromURL("~fl~"));
51 FilterStorage.addSubscription(Subscription.fromURL("~wl~")); 51 FilterStorage.addSubscription(Subscription.fromURL("~wl~"));
52 FilterStorage.addSubscription(Subscription.fromURL("~eh~")); 52 FilterStorage.addSubscription(Subscription.fromURL("~eh~"));
53 53
54 Subscription.fromURL("~fl~").defaults = ["blocking"]; 54 Subscription.fromURL("~fl~").defaults = ["blocking"];
55 Subscription.fromURL("~wl~").defaults = ["whitelist"]; 55 Subscription.fromURL("~wl~").defaults = ["whitelist"];
56 Subscription.fromURL("~eh~").defaults = ["elemhide"]; 56 Subscription.fromURL("~eh~").defaults = ["elemhide"];
57 57
58 Subscription.fromURL("~fl~").trusted = false;
59
58 callback(); 60 callback();
59 }; 61 };
60 62
61 function checkKnownFilters(test, text, expected) 63 function checkKnownFilters(test, text, expected)
62 { 64 {
63 let result = {}; 65 let result = {};
64 for (let type of ["blacklist", "whitelist"]) 66 for (let type of ["blacklist", "whitelist"])
65 { 67 {
66 let matcher = defaultMatcher[type]; 68 let matcher = defaultMatcher[type];
67 let filters = []; 69 let filters = [];
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 else 105 else
104 expected[type].sort(); 106 expected[type].sort();
105 result[type].sort(); 107 result[type].sort();
106 } 108 }
107 109
108 test.deepEqual(result, expected, text); 110 test.deepEqual(result, expected, text);
109 } 111 }
110 112
111 exports.testAddingAndRemovingFilters = function(test) 113 exports.testAddingAndRemovingFilters = function(test)
112 { 114 {
115 let filter0 = Filter.fromText("filter0");
113 let filter1 = Filter.fromText("filter1"); 116 let filter1 = Filter.fromText("filter1");
114 let filter2 = Filter.fromText("@@filter2"); 117 let filter2 = Filter.fromText("@@filter2");
115 let filter3 = Filter.fromText("##filter3"); 118 let filter3 = Filter.fromText("##filter3");
116 let filter4 = Filter.fromText("!filter4"); 119 let filter4 = Filter.fromText("!filter4");
117 let filter5 = Filter.fromText("#@#filter5"); 120 let filter5 = Filter.fromText("#@#filter5");
118 let filter6 = Filter.fromText("example.com#?#:-abp-properties(filter6')"); 121 let filter6 = Filter.fromText("example.com#?#:-abp-properties(filter6')");
119 let filter7 = Filter.fromText("example.com#@#[-abp-properties='filter7']"); 122 let filter7 = Filter.fromText("example.com#@#[-abp-properties='filter7']");
120 123
124 filter0.needsTrust = true;
125 FilterStorage.addFilter(filter0);
126 checkKnownFilters(test, "add filter0", {});
127
121 FilterStorage.addFilter(filter1); 128 FilterStorage.addFilter(filter1);
122 checkKnownFilters(test, "add filter1", {blacklist: [filter1.text]}); 129 checkKnownFilters(test, "add filter1", {blacklist: [filter1.text]});
123 FilterStorage.addFilter(filter2); 130 FilterStorage.addFilter(filter2);
124 checkKnownFilters(test, "add @@filter2", {blacklist: [filter1.text], whitelist : [filter2.text]}); 131 checkKnownFilters(test, "add @@filter2", {blacklist: [filter1.text], whitelist : [filter2.text]});
125 FilterStorage.addFilter(filter3); 132 FilterStorage.addFilter(filter3);
126 checkKnownFilters(test, "add ##filter3", {blacklist: [filter1.text], whitelist : [filter2.text], elemhide: [filter3.text]}); 133 checkKnownFilters(test, "add ##filter3", {blacklist: [filter1.text], whitelist : [filter2.text], elemhide: [filter3.text]});
127 FilterStorage.addFilter(filter4); 134 FilterStorage.addFilter(filter4);
128 checkKnownFilters(test, "add !filter4", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text]}); 135 checkKnownFilters(test, "add !filter4", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text]});
129 FilterStorage.addFilter(filter5); 136 FilterStorage.addFilter(filter5);
130 checkKnownFilters(test, "add #@#filter5", {blacklist: [filter1.text], whitelis t: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text]}) ; 137 checkKnownFilters(test, "add #@#filter5", {blacklist: [filter1.text], whitelis t: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text]}) ;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 checkKnownFilters(test, "disable exception rules", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text]}); 325 checkKnownFilters(test, "disable exception rules", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text]});
319 326
320 FilterStorage.removeSubscription(subscription4); 327 FilterStorage.removeSubscription(subscription4);
321 checkKnownFilters(test, "remove subscription from the list", {blacklist: [filt er1.text]}); 328 checkKnownFilters(test, "remove subscription from the list", {blacklist: [filt er1.text]});
322 329
323 subscription3.disabled = false; 330 subscription3.disabled = false;
324 checkKnownFilters(test, "enable exception rules", {blacklist: [filter1.text], whitelist: [filter2.text]}); 331 checkKnownFilters(test, "enable exception rules", {blacklist: [filter1.text], whitelist: [filter2.text]});
325 332
326 test.done(); 333 test.done();
327 }; 334 };
OLDNEW
« no previous file with comments | « lib/subscriptionClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld