Open Bug 1746513 Opened 3 years ago Updated 3 years ago

Determine pattern for handling test prefs in Form Autofill

Categories

(Toolkit :: Form Autofill, task, P3)

task

Tracking

()

People

(Reporter: tgiles, Unassigned)

References

(Blocks 1 open bug)

Details

Currently in Form Autofill, we sometimes establish prefs as consts in the head.js files of the various test suites, sometimes we just use the pref string in various tests. We should determine a strategy for how we want to address this papercut.

On one hand, we could create a test_prefs.js file that exports each const into the various head.js files so that we can utilize one const in our tests (especially if there's IDE support for this reference, to help prevent typos and all that). On the other hand, we could use the full pref string everywhere we need it so that we don't need to remember a pref variable.

There's probably other ways to deal with this, but these are the two I immediately recall throughout our conversations.

Component: about:logins → Form Autofill
Product: Firefox → Toolkit
Blocks: 1737329
No longer depends on: 1737329

My preference would be to stop using const 😱 for pref names. Here is my rationale:

  1. There is no compile time validation that const name has no typos. Same as for pref name string has, so no win by using const.
  2. Many files defining same consts is a mess. We better keep it in one file, but even then we still need these names in test config files.
  3. The chance we need to change const value is very low. We are most likely to create a new pref instead of renaming existing.
  4. Using same string everywhere enables "Find in All Files".

Today I'm trying to find browser.search.region and I hit 32 search results. Some of them are:

const BROWSER_SEARCH_REGION_PREF = "browser.search.region";
const SEARCH_REGION_PREF = "browser.search.region";
const REGION_PREF = "browser.search.region";
browser.search.region='DE'

I will need to search for BROWSER_SEARCH_REGION_PREF, SEARCH_REGION_PREF and REGION_PREF. Then I'll need to combine results of 4 searchers to see places where we use that pref. I could search by REGION_PREF in this particular case, but that's still many searches vs one.

Severity: -- → N/A
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.