tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ee661ef511d82f1db62701569c139ad8057d0e88
parent 3bcfc371da7089be3137d5c2a4910a5a0ca33487
Author: Valentin Gosu <valentin.gosu@gmail.com>
Date:   Tue, 16 Dec 2025 19:21:11 +0000

Bug 1915371 - Part 3: Make test_http_auth_cache mochitest automatically accept password prompt r=necko-reviewers,jesup

Differential Revision: https://phabricator.services.mozilla.com/D271583

Diffstat:
Mnetwerk/test/mochitests/mochitest.toml | 2+-
Mnetwerk/test/mochitests/test_http_auth_cache.html | 43+++++++++++++++++++++++++++++++------------
2 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/netwerk/test/mochitests/mochitest.toml b/netwerk/test/mochitests/mochitest.toml @@ -141,7 +141,7 @@ skip-if = [ ["test_fetch_lnk.html"] ["test_http_auth_cache.html"] -support-files = ["authenticate.sjs"] +support-files = ["authenticate.sjs", "../../../toolkit/components/prompts/test/prompt_common.js", "../../../toolkit/components/prompts/test/chromeScript.js"] ["test_idn_redirect.html"] skip-if = [ diff --git a/netwerk/test/mochitests/test_http_auth_cache.html b/netwerk/test/mochitests/test_http_auth_cache.html @@ -4,27 +4,24 @@ <html> <head> <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="../../../toolkit/components/prompts/test/prompt_common.js"></script> </head> <body> <script type="application/javascript"> - SimpleTest.waitForExplicitFinish(); - async function populateHttpAuthCache() { await fetch("authenticate.sjs"); } async function clearHttpAuthCacheTest() { let script = SpecialPowers.loadChromeScript(function () { - /* eslint-env mozilla/frame-script */ + /* eslint-env mozilla/chrome-script */ + const {addMessageListener, sendAsyncMessage} = this; addMessageListener("start", function () { try { let httpAuthCache = Cc["@mozilla.org/network/http-auth-cache;1"] .getService(Ci.nsIHttpAuthCache); - // for(let k in httpAuthCache) { - // console.log("Method:", k); - // } let entries = httpAuthCache.getEntries(); sendAsyncMessage("before", entries.length); @@ -33,7 +30,7 @@ httpAuthCache.clearEntry(entry); } - let afterEntries = httpAuthCache.getEntries(1); + let afterEntries = httpAuthCache.getEntries(); sendAsyncMessage("after", afterEntries.length); } catch (e) { console.error("Failed to get or clear the HTTP auth cache", e); @@ -52,11 +49,33 @@ }); } - add_task(async function () { - await populateHttpAuthCache(); - await clearHttpAuthCacheTest(); - SimpleTest.finish(); - }); +add_task(async function () { + const state = { + msg: "This site is asking you to sign in.", + title: "Authentication Required", + textValue: "", + passValue: "", + iconClass: "authentication-icon question-icon", + titleHidden: true, + textHidden: false, + passHidden: false, + checkHidden: true, + checkMsg: "", + checked: false, + focused: "textField", + defButton: "button0", + }; + const action = { + buttonClick: "ok", + textField: "user", + passField: "pass", + }; + let promptDone = handlePrompt(state, action); + + await populateHttpAuthCache(); + await promptDone; + await clearHttpAuthCacheTest(); +}); </script> </body>