Closed Bug 1815490 Opened 1 year ago Closed 1 year ago

JS error: can't access property "suggestion", lazy.QuickSuggest.weather is undefined

Categories

(Firefox :: Address Bar, defect, P1)

defect

Tracking

()

RESOLVED FIXED
111 Branch
Tracking Status
firefox-esr102 --- unaffected
firefox109 --- unaffected
firefox110 --- unaffected
firefox111 --- fixed

People

(Reporter: adw, Assigned: adw)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

There's a JS error in the new UrlbarProviderWeather when running unrelated xpcshell tests:

[task 2023-02-07T15:02:37.531Z] 15:02:37     INFO -  PID 24521 | console.error: (new TypeError("can't access property \\"suggestion\\", lazy.QuickSuggest.weather is undefined", "resource:///modules/UrlbarProviderWeather.sys.mjs", 201))

It's logged multiple times when running for example:

./mach test browser/components/urlbar/tests/unit/test_providerOmnibox.js

This JS error happens because QuickSuggest.weather is undefined when the
provider's isActive() is called while xpcshell tests perform searches. The
error is harmless because it's caught and reported by the urlbar providers
manager.

QuickSuggest.weather is defined when QuickSuggest.init() is called. In
normal app usage, init() is called by BrowserGlue on app startup. Xpcshell
tests that are related to quick suggest make sure init() is called by using
QuickSuggestTestUtils.ensureQuickSuggestInit(). The only problem is xpcshell
tests that are not related to quick suggest. For those tests, init() is never
called.

The fix is simple, just don't assume QuickSuggest.weather is defined inside
isActive(). Another fix would be to make isActive() return false if
UrlbarPrefs.get("quickSuggestEnabled") is false. That's what the quick suggest
provider does, and that's why it doesn't have this problem.
quickSuggestEnabled will remain false until QuickSuggest.init() is called. I
think it's nicer to only rely on QuickSuggest.weather though.

Blocks: 1815018

Set release status flags based on info from the regressing bug 1814732

Pushed by dwillcoxon@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/4524623b2006
Fix JS error in UrlbarProviderWeather when QuickSuggest is not initialized. r=daisuke
Flags: qe-verify-
Flags: in-testsuite-
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: