Figure out why, on some systems, Onboarding::_addScriptsAndRender is able to run twice per sidebar even when the event listener has `once: true`
Categories
(Firefox :: Messaging System, task, P3)
Tracking
()
People
(Reporter: aminomancer, Unassigned)
References
Details
Punam and I found a mysterious phenomenon while working on bug 1900486. For me, on Windows 10, it was necessary to remove once: true
from this event listener to make Onboarding render the opt-in message after having previously seen a survey in the same sidebar. Without once: true
, if you view the survey, "Turn off Review Checker," then reopen the sidebar with the urlbar button, it will just show a blank sidebar. This is because, although the RenderWelcome
event is dispatched by AboutWelcomeShoppingChild, there is no event listener to hear that event, as the event listener removed itself after showing the opt-in message (due to once: true
).
But when Punam tested the same thing, instead of showing a blank sidebar, it correctly showed the opt-in message. It's mysterious because the event listener should have been removed after showing the first message, making it impossible to render 2 messages in the same sidebar. And that event listener can't have been re-added, because it's only added in Onboarding's constructor, which has no consumers. The only thing that calls the constructor is the file itself, as part of the file's side effects. So that event listener can only be added once per load of onboarding.mjs. Yet, onboarding.mjs is only loaded by one file: shopping.html. It just has a script tag. That means the only way it could be added twice is if shopping.html was reloaded. But it doesn't seem like shopping.html was reloaded, because that would also cause the whole DOM to reset, which didn't seem to happen.
So this is quite strange and I'd like if we could test this on multiple systems to see if it can be reproduced. It could have been anything, from a mere build issue in Punam's local environment, to a lower-level bug with event listeners. So testing this on other environments would be helpful. All you have to do to test it is make sure you have bug 1900486's patch (should land on m-c soon), then go to onboarding.mjs and add back once: true
to the event listener. Then follow these steps:
- Run Firefox on a new profile
- Set these prefs:
browser.shopping.experience2023.enabled=true browser.shopping.experience2023.autoOpen.enabled=true
- Go to amazon and find a product page so the sidebar opens. Opt in to RC via the opt-in message in the sidebar.
- Close the amazon tab
- Go to about:config
- Set these prefs:
browser.shopping.experience2023.survey.optedInTime=1696550403 browser.shopping.experience2023.survey.pdpVisits=5
- Go to about:profiles and click "Restart normally..."
- Having restarted Firefox, go to amazon.com and find a product page again
- The sidebar should show, and a survey should be visible
- Complete the survey and quickly, when the green thank you card appears, scroll down to Settings, expand it, and click "Turn off Review Checker"
- A feature callout should show; dismiss it
- Click the urlbar shopping button the feature callout was anchored to, to reopen the sidebar
- The sidebar should now be empty, except perhaps for the thank you card (which should disappear after 5 seconds) depending on your speed
- This is the point of divergence, where for me the sidebar is empty but for Punam it shows the opt-in message
Reporter | ||
Updated•3 months ago
|
Description
•