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

Delta Between Two Patch Sets: test/filterListener.js

Issue 30025555: Issue 6820 - Move tests to mocha (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created March 7, 2019, 1:14 p.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « test/filterClasses.js ('k') | test/filterNotifier.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 17 matching lines...) Expand all
28 let SpecialSubscription = null; 28 let SpecialSubscription = null;
29 29
30 describe("Filter Listener", () => 30 describe("Filter Listener", () =>
31 { 31 {
32 beforeEach(() => 32 beforeEach(() =>
33 { 33 {
34 sandboxedRequire = createSandbox({ 34 sandboxedRequire = createSandbox({
35 extraExports: { 35 extraExports: {
36 elemHide: ["knownFilters"], 36 elemHide: ["knownFilters"],
37 elemHideEmulation: ["filters"], 37 elemHideEmulation: ["filters"],
38 elemHideExceptions: ["knownExceptions"], 38 elemHideExceptions: ["knownExceptions"]
39 snippets: ["filters"]
40 } 39 }
41 }); 40 });
42 41
43 // We need to require the filterListener module so that filter changes will be 42 // We need to require the filterListener module so that filter changes will be
44 // noticed, even though we don't directly use the module here. 43 // noticed, even though we don't directly use the module here.
45 sandboxedRequire("../lib/filterListener"); 44 sandboxedRequire("../lib/filterListener");
46 45
47 ( 46 (
48 {filterStorage} = sandboxedRequire("../lib/filterStorage"), 47 {filterStorage} = sandboxedRequire("../lib/filterStorage"),
49 {Subscription, SpecialSubscription} = sandboxedRequire("../lib/subscriptio nClasses"), 48 {Subscription, SpecialSubscription} = sandboxedRequire("../lib/subscriptio nClasses"),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 let elemHideExceptions = sandboxedRequire("../lib/elemHideExceptions"); 90 let elemHideExceptions = sandboxedRequire("../lib/elemHideExceptions");
92 result.elemhideexception = []; 91 result.elemhideexception = [];
93 for (let exception of elemHideExceptions.knownExceptions) 92 for (let exception of elemHideExceptions.knownExceptions)
94 result.elemhideexception.push(exception.text); 93 result.elemhideexception.push(exception.text);
95 94
96 let elemHideEmulation = sandboxedRequire("../lib/elemHideEmulation"); 95 let elemHideEmulation = sandboxedRequire("../lib/elemHideEmulation");
97 result.elemhideemulation = []; 96 result.elemhideemulation = [];
98 for (let filter of elemHideEmulation.filters) 97 for (let filter of elemHideEmulation.filters)
99 result.elemhideemulation.push(filter.text); 98 result.elemhideemulation.push(filter.text);
100 99
101 let snippets = sandboxedRequire("../lib/snippets"); 100 let {snippets} = sandboxedRequire("../lib/snippets");
102 result.snippets = []; 101 result.snippets = [];
103 for (let filter of snippets.filters) 102 for (let filter of snippets._filters)
104 result.snippets.push(filter.text); 103 result.snippets.push(filter.text);
105 104
106 let types = ["blacklist", "whitelist", "elemhide", "elemhideexception", 105 let types = ["blacklist", "whitelist", "elemhide", "elemhideexception",
107 "elemhideemulation", "snippets"]; 106 "elemhideemulation", "snippets"];
108 for (let type of types) 107 for (let type of types)
109 { 108 {
110 if (!(type in expected)) 109 if (!(type in expected))
111 expected[type] = []; 110 expected[type] = [];
112 else 111 else
113 expected[type].sort(); 112 expected[type].sort();
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 293
295 subscription2.disabled = false; 294 subscription2.disabled = false;
296 checkKnownFilters("enable blocking filters", {blacklist: [filter1.text]}); 295 checkKnownFilters("enable blocking filters", {blacklist: [filter1.text]});
297 296
298 let subscription3 = Subscription.fromURL("~wl~"); 297 let subscription3 = Subscription.fromURL("~wl~");
299 subscription3.disabled = true; 298 subscription3.disabled = true;
300 checkKnownFilters("disable exception rules", {blacklist: [filter1.text]}); 299 checkKnownFilters("disable exception rules", {blacklist: [filter1.text]});
301 300
302 filterStorage.addFilter(filter2); 301 filterStorage.addFilter(filter2);
303 checkKnownFilters("add @@filter2", {blacklist: [filter1.text], whitelist: [f ilter2.text]}); 302 checkKnownFilters("add @@filter2", {blacklist: [filter1.text], whitelist: [f ilter2.text]});
304 assert.equal(filter2.subscriptionCount, 1, "@@filter2.subscriptionCount"); 303 assert.equal([...filterStorage.subscriptions(filter2.text)].length, 1, "@@fi lter2.subscriptionCount");
305 assert.ok([...filter2.subscriptions()][0] instanceof SpecialSubscription, "@ @filter2 added to a new filter group"); 304 assert.ok([...filterStorage.subscriptions(filter2.text)][0] instanceof Speci alSubscription, "@@filter2 added to a new filter group");
306 assert.ok([...filter2.subscriptions()][0] != subscription3, "@@filter2 filte r group is not the disabled exceptions group"); 305 assert.ok([...filterStorage.subscriptions(filter2.text)][0] != subscription3 , "@@filter2 filter group is not the disabled exceptions group");
307 306
308 subscription3.disabled = false; 307 subscription3.disabled = false;
309 checkKnownFilters("enable exception rules", {blacklist: [filter1.text], whit elist: [filter2.text]}); 308 checkKnownFilters("enable exception rules", {blacklist: [filter1.text], whit elist: [filter2.text]});
310 309
311 filterStorage.removeFilter(filter2); 310 filterStorage.removeFilter(filter2);
312 filterStorage.addFilter(filter2); 311 filterStorage.addFilter(filter2);
313 checkKnownFilters("re-add @@filter2", {blacklist: [filter1.text], whitelist: [filter2.text]}); 312 checkKnownFilters("re-add @@filter2", {blacklist: [filter1.text], whitelist: [filter2.text]});
314 assert.equal(filter2.subscriptionCount, 1, "@@filter2.subscriptionCount"); 313 assert.equal([...filterStorage.subscriptions(filter2.text)].length, 1, "@@fi lter2.subscriptionCount");
315 assert.ok([...filter2.subscriptions()][0] == subscription3, "@@filter2 added to the default exceptions group"); 314 assert.ok([...filterStorage.subscriptions(filter2.text)][0] == subscription3 , "@@filter2 added to the default exceptions group");
316 315
317 let subscription4 = Subscription.fromURL("http://test/"); 316 let subscription4 = Subscription.fromURL("http://test/");
318 filterStorage.updateSubscriptionFilters(subscription4, [filter3.text, filter 4.text, filter5.text]); 317 filterStorage.updateSubscriptionFilters(subscription4, [filter3.text, filter 4.text, filter5.text]);
319 checkKnownFilters("update subscription not in the list yet", {blacklist: [fi lter1.text], whitelist: [filter2.text]}); 318 checkKnownFilters("update subscription not in the list yet", {blacklist: [fi lter1.text], whitelist: [filter2.text]});
320 319
321 filterStorage.addSubscription(subscription4); 320 filterStorage.addSubscription(subscription4);
322 checkKnownFilters("add subscription to the list", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text, filter4.text]}); 321 checkKnownFilters("add subscription to the list", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text, filter4.text]});
323 322
324 filterStorage.updateSubscriptionFilters(subscription4, [filter3.text, filter 2.text, filter5.text]); 323 filterStorage.updateSubscriptionFilters(subscription4, [filter3.text, filter 2.text, filter5.text]);
325 checkKnownFilters("update subscription while in the list", {blacklist: [filt er1.text, filter3.text], whitelist: [filter2.text]}); 324 checkKnownFilters("update subscription while in the list", {blacklist: [filt er1.text, filter3.text], whitelist: [filter2.text]});
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 filterStorage.addSubscription(subscription3); 359 filterStorage.addSubscription(subscription3);
361 checkKnownFilters("add special subscription with filter2", {snippets: [filte r1.text, filter2.text]}); 360 checkKnownFilters("add special subscription with filter2", {snippets: [filte r1.text, filter2.text]});
362 361
363 let subscription4 = Subscription.fromURL("https://easylist-downloads.adblock plus.org/abp-filters-anti-cv.txt"); 362 let subscription4 = Subscription.fromURL("https://easylist-downloads.adblock plus.org/abp-filters-anti-cv.txt");
364 subscription4.addFilter(filter3); 363 subscription4.addFilter(filter3);
365 364
366 filterStorage.addSubscription(subscription4); 365 filterStorage.addSubscription(subscription4);
367 checkKnownFilters("add ABP anti-circumvention subscription with filter3", {s nippets: [filter1.text, filter2.text, filter3.text]}); 366 checkKnownFilters("add ABP anti-circumvention subscription with filter3", {s nippets: [filter1.text, filter2.text, filter3.text]});
368 }); 367 });
369 }); 368 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld