browser_net_header-ref-policy.js (1712B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Tests if "Referrer Policy" is displayed in the header panel. 8 */ 9 add_task(async function () { 10 const { tab, monitor } = await initNetMonitor(POST_RAW_URL, { 11 requestCount: 1, 12 }); 13 info("Starting test... "); 14 15 const { document, store, windowRequire } = monitor.panelWin; 16 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); 17 store.dispatch(Actions.batchEnable(false)); 18 19 // Execute request. 20 await performRequests(monitor, tab, 1); 21 22 // Wait until the tab panel summary is displayed 23 const wait = waitUntil( 24 () => document.querySelectorAll(".tabpanel-summary-label")[0] 25 ); 26 EventUtils.sendMouseEvent( 27 { type: "mousedown" }, 28 document.querySelectorAll(".request-list-item")[0] 29 ); 30 await wait; 31 32 const referrerPolicyIndex = 3; 33 const referrerPolicyHeader = document.querySelectorAll( 34 ".tabpanel-summary-label" 35 )[referrerPolicyIndex]; 36 const referrerPolicyValue = document.querySelectorAll( 37 ".tabpanel-summary-value" 38 )[referrerPolicyIndex]; 39 40 is( 41 referrerPolicyHeader.textContent === "Referrer Policy", 42 true, 43 '"Referrer Policy" header is displayed in the header panel.' 44 ); 45 46 const defaultPolicy = Services.prefs.getIntPref( 47 "network.http.referer.defaultPolicy" 48 ); 49 const stringMap = { 50 0: "no-referrer", 51 1: "same-origin", 52 2: "strict-origin-when-cross-origin", 53 3: "no-referrer-when-downgrade", 54 }; 55 is( 56 referrerPolicyValue.textContent === stringMap[defaultPolicy], 57 true, 58 "The referrer policy value is reflected correctly." 59 ); 60 61 return teardown(monitor); 62 });