Consolidate the three duplicate loadBadCertPage test helpers
Categories
(Firefox :: Site Identity, task)
Tracking
()
People
(Reporter: dmehic, Assigned: ekerin.m.a)
References
Details
(Keywords: good-first-bug)
Attachments
(1 external file)
Three near-identical loadBadCertPage() helpers drive the certificate error page in browser-chrome tests, and they have drifted apart:
browser/base/content/test/siteIdentity/head.js— has both a felt-privacy and a legacy branchbrowser/base/content/test/general/head.js— has both branches, but they behave differently from the abovebrowser/components/urlbar/tests/browser-trustPanel/browser_trust_panel_cert_exception.js— felt-privacy only
Bug 1994840 fixes a race in the siteIdentity copy. #exceptionDialogButton has no disabled attribute in aboutNetError.html, so it is enabled from page load and only becomes disabled once revealing the advanced panel starts (aboutNetError.mjs). A waitForCondition(() => !exceptionButton.disabled) therefore returns on its very first poll, so if the click on #advancedButton is lost the test goes on to click a button inside the still-hidden panel, nothing navigates, and the test hangs until it times out.
That fix only touches one of the three copies. The other two still need attention:
browser_trust_panel_cert_exception.jsis a verbatim copy of thesiteIdentityfelt-privacy branch, including theEventUtils.synthesizeMouseAtCenter()calls that bug 1994840 replaces with.click().- The legacy branch in
general/head.jsclicks#exceptionDialogButtondirectly without revealing the advanced panel at all. That passes today only because the button happens to be enabled and unhidden at load, and it will break as soon as that markup gains adisabledattribute.
Suggested fix
Consolidate the three into a single shared helper, so that the next fix here does not have to be applied three times.
The one non-obvious part: these callers live in directories that do not share a head.js, so the helper needs a home that both browser/base/content/test/ and browser/components/urlbar/tests/ can pull in via support-files in their respective browser.toml files.
A reasonable incremental order, where each step is independently landable:
- Make
browser_trust_panel_cert_exception.jsuse the shared helper and delete its local copy. - Reconcile the
general/head.jslegacy branch with thesiteIdentityone, so that it reveals the advanced panel before clicking the exception button. - Collapse the remaining two definitions into one.
Each step can be verified with ./mach test <path> on the affected directory, for example:
./mach test browser/base/content/test/siteIdentity/
./mach test browser/base/content/test/general/browser_addCertException.js
./mach test browser/components/urlbar/tests/browser-trustPanel/
| Assignee | ||
Comment 1•2 months ago
|
||
New contributor here - I'm going to work on a patch for this.
| Assignee | ||
Comment 2•2 months ago
|
||
Hey, Dan, I'm looking for some clarification. Is the patch for this bug meant to land after the patch for bug 1994840 lands? Or is the idea that this patch extracts the helper, applies the changes proposed for 1994840 to that helper, and only changes the call-sites in general/ and urlbar/ (which would leave siteIdentity/ to be refactored in the 1994840 or another patch)? Just concerned that extracting the helper before the other patch lands would create a conflict.
Thanks for taking on the bug, much appreciated. I believe landing https://bugzilla.mozilla.org/show_bug.cgi?id=1994840 is the appropriate way forward. I'll ping emz to make a call and to review mentioned bug.
| Assignee | ||
Comment 4•2 months ago
|
||
Sounds good, Dan. Thank you.
| Assignee | ||
Comment 5•2 months ago
|
||
--WIP--
Copies use of toolkit/content/tests/browser/common/ pattern from
mockTransfer.js - used across multiple tests in browser/,
toolkit/, devtools/, uriloader/.
Implementation of loadBadCertPage.js is taken from proposed bug fix.
Will revisit and refactor as needed after that patch lands.
Comment 6•2 months ago
|
||
I see that Bug 1994840 has landed. Do you need anything else from me?
Updated•1 month ago
|
Description
•