From af3289f596e0189eabc31589ac048215a0ed217b Mon Sep 17 00:00:00 2001 From: Hubert Boma Manilla Date: Tue, 23 Mar 2021 19:21:21 +0000 Subject: [PATCH] Bug 1666386 - [devtools] Find blocked request using url name fixes intermittent r=nchevobbe The test previously depended on the position of the blocked request in the request list view, This causes the test to fail intermittently when the list is out of order. This fix instead finds the request using the name in the url which is more consistent. Differential Revision: https://phabricator.services.mozilla.com/D109497 --- .../test/browser_net_block-extensions.js | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/devtools/client/netmonitor/test/browser_net_block-extensions.js b/devtools/client/netmonitor/test/browser_net_block-extensions.js index 9c4178056278..029ab3bfd3bf 100644 --- a/devtools/client/netmonitor/test/browser_net_block-extensions.js +++ b/devtools/client/netmonitor/test/browser_net_block-extensions.js @@ -61,34 +61,38 @@ add_task(async function() { waitForReload, ]); - const requests = document.querySelectorAll(".request-list-item"); + // Find the request list item that matches the blocked url + const request = document.querySelector( + "td.requests-list-url[title*=request_0]" + ).parentNode; info("Assert the blocked request"); ok( - !!requests[1].querySelector( - ".requests-list-status .status-code-blocked-icon" - ), + !!request.querySelector(".requests-list-status .status-code-blocked-icon"), "The request blocked status icon is visible" ); + is( - requests[1].querySelector( - ".requests-list-status .requests-list-status-code" - ).title, + request.querySelector(".requests-list-status .requests-list-status-code") + .title, "Blocked", "The request status title is 'Blocked'" ); + is( - requests[1].querySelector(".requests-list-type").innerText, + request.querySelector(".requests-list-type").innerText, "", "The request shows no type" ); + is( - requests[1].querySelector(".requests-list-transferred").innerText, + request.querySelector(".requests-list-transferred").innerText, `Blocked By ${extensionName}`, "The request shows the blocking extension name" ); + is( - requests[1].querySelector(".requests-list-size").innerText, + request.querySelector(".requests-list-size").innerText, "", "The request shows no size" );