browser_net_tracking-resources.js (1451B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const { UrlClassifierTestUtils } = ChromeUtils.importESModule( 7 "resource://testing-common/UrlClassifierTestUtils.sys.mjs" 8 ); 9 10 const TEST_URI = 11 "https://example.com/browser/devtools/client/" + 12 "netmonitor/test/html_tracking-protection.html"; 13 14 registerCleanupFunction(function () { 15 UrlClassifierTestUtils.cleanupTestTrackers(); 16 }); 17 18 /** 19 * Test that tracking resources are properly marked in the Network panel. 20 */ 21 add_task(async function () { 22 await UrlClassifierTestUtils.addTestTrackers(); 23 24 const { monitor, tab } = await initNetMonitor(TEST_URI, { requestCount: 1 }); 25 info("Starting test..."); 26 27 const { document, store, windowRequire } = monitor.panelWin; 28 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); 29 30 store.dispatch(Actions.batchEnable(false)); 31 32 // Execute request with third party tracking protection flag. 33 await performRequests(monitor, tab, 1); 34 35 const domainRequests = document.querySelectorAll( 36 ".requests-list-domain .tracking-resource" 37 ); 38 const UrlRequests = document.querySelectorAll( 39 ".requests-list-url .tracking-resource" 40 ); 41 42 is( 43 domainRequests.length, 44 1, 45 "There should be one domain column tracking request" 46 ); 47 is(UrlRequests.length, 1, "There should be one URL column tracking request"); 48 49 await teardown(monitor); 50 });