browser_net_set-cookie-same-site.js (2113B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Test if the 'Same site' cookie attribute is correctly set in the cookie panel 8 */ 9 add_task(async function () { 10 const { monitor } = await initNetMonitor(SET_COOKIE_SAME_SITE_SJS, { 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 18 store.dispatch(Actions.batchEnable(false)); 19 20 let wait = waitForNetworkEvents(monitor, 1); 21 await reloadBrowser(); 22 await wait; 23 24 wait = waitForDOM(document, ".headers-overview"); 25 EventUtils.sendMouseEvent( 26 { type: "mousedown" }, 27 document.querySelectorAll(".request-list-item")[0] 28 ); 29 await wait; 30 31 clickOnSidebarTab(document, "cookies"); 32 33 info("Checking the SameSite property"); 34 const expectedValues = [ 35 { 36 key: "foo", 37 value: "", 38 }, 39 { 40 key: "samesite", 41 value: '"Lax"', 42 }, 43 { 44 key: "value", 45 value: '"bar"', 46 }, 47 { 48 key: "foo", 49 value: '"bar"', 50 }, 51 ]; 52 const labelCells = document.querySelectorAll(".treeLabelCell"); 53 const valueCells = document.querySelectorAll(".treeValueCell"); 54 is( 55 valueCells.length, 56 labelCells.length, 57 "Number of labels " + 58 labelCells.length + 59 " different from number of values " + 60 valueCells.length 61 ); 62 63 // Go through the cookie properties and check if each one has the expected 64 // label and value 65 for (let index = 0; index < labelCells.length; ++index) { 66 is( 67 labelCells[index].innerText, 68 expectedValues[index].key, 69 "Actual label " + 70 labelCells[index].innerText + 71 " not equal to expected label " + 72 expectedValues[index].key 73 ); 74 is( 75 valueCells[index].innerText, 76 expectedValues[index].value, 77 "Actual value " + 78 valueCells[index].innerText + 79 " not equal to expected value " + 80 expectedValues[index].value 81 ); 82 } 83 84 await teardown(monitor); 85 });