Open Bug 2062136 Opened 3 months ago Updated 1 month ago

Consolidate the three duplicate loadBadCertPage test helpers

Categories

(Firefox :: Site Identity, task)

task

Tracking

()

ASSIGNED

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:

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.js is a verbatim copy of the siteIdentity felt-privacy branch, including the EventUtils.synthesizeMouseAtCenter() calls that bug 1994840 replaces with .click().
  • The legacy branch in general/head.js clicks #exceptionDialogButton directly 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 a disabled attribute.

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:

  1. Make browser_trust_panel_cert_exception.js use the shared helper and delete its local copy.
  2. Reconcile the general/head.js legacy branch with the siteIdentity one, so that it reveals the advanced panel before clicking the exception button.
  3. 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/

New contributor here - I'm going to work on a patch for this.

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.

Flags: needinfo?(dmehic)

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.

Flags: needinfo?(dmehic) → needinfo?(emz)

Sounds good, Dan. Thank you.

--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.

I see that Bug 1994840 has landed. Do you need anything else from me?

Flags: needinfo?(emz) → needinfo?(dmehic)

No, thank you!

Flags: needinfo?(dmehic)
Assignee: nobody → ekerin.m.a
Attachment #9632167 - Attachment description: WIP: Bug 2062136 - Consolidate the three duplicate loadBadCertPage test helpers. → Bug 2062136 - Consolidate three duplicate loadBadCertPage test helpers. r?emz!
Status: NEW → ASSIGNED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: