summaryrefslogtreecommitdiffstats
path: root/net/adblock-fast/tests/03_functional/01_check_domain
blob: 63f1e88d96af61a0d9462c421c50276b7c1a9be0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Test that check() correctly identifies blocked and unblocked domains.
check() output goes to stderr via output.info/output.print.

-- Testcase --
import adb from 'adblock-fast';
let ti = adb._test_internals;

// Build the blocklist with verbosity=0 (from mock config) to suppress progress
adb.env.load_config();
ti.set_cfg('dns', 'dnsmasq.servers');
ti.set_cfg('dnsmasq_sanity_check', false);
ti.set_cfg('dnsmasq_validity_check', false);
ti.set_cfg('heartbeat_domain', null);
ti.set_cfg('config_update_enabled', false);
ti.set_cfg('update_config_sizes', false);
ti.env.dns_set_output_values('dnsmasq.servers');
ti.append_urls();
ti.download_lists();

// Set verbosity=2 for check() output, then call check() directly
// (bypassing check()'s internal load_config() which would reset to 0)
ti.set_cfg('verbosity', 2);
adb.env.load_config = function() {};
adb.check('ad.doubleclick.test.example.com this-domain-not-in-list.test.example.com');
-- End --

-- Expect stderr --
[PROC] Found 1 match for 'ad.doubleclick.test.example.com' in 'TESTDIR/var_run/adblock-fast/dnsmasq.servers'.
ad.doubleclick.test.example.com
[PROC] The 'this-domain-not-in-list.test.example.com' is not found in current block-list ('TESTDIR/var_run/adblock-fast/dnsmasq.servers').
-- End --