www.sanicare.de - Does not add products to the cart
Categories
(Core :: DOM: Core & HTML, defect, P1)
Tracking
()
People
(Reporter: ctanase, Assigned: smaug)
References
()
Details
(Keywords: webcompat:platform-bug, webcompat:site-report, Whiteboard: [webcompat-source:product][autowebcompat:processed][autowebcompat:repro-success], [wptsync upstream])
User Story
autowebcompat-repro-status:success autowebcompat-repro-chrome-mask-fixed:false autowebcompat-repro-channels:nightly,stable,esr platform:windows,mac,linux,android impact:site-broken configuration:general affects:all branch:release diagnosis-team:dom user-impact-score:1000 autowebcompat-diagnosis-status:success
Attachments
(6 files, 2 external files)
Environment:
Operating system: Windows
Firefox version: Firefox 153.0.3 (release)/155
Preconditions:
- Clean profile
Steps to reproduce:
- Navigate to: https://www.sanicare.de/p/cationorm-sd-sine-augentropfen-30x0-4-einzeldosispipetten-09617771
- Click on "In den Warenkorb" to add the product to the cart.
Expected Behavior:
The product gets added to the cart.
Actual Behavior:
Nothing happens.
Notes:
- Reproducible on the latest Firefox Release and Nightly
- Reproducible regardless of the ETP setting
- Works as expected using Chrome
Created from webcompat-user-report:0dc37349-1f6a-485a-8546-92e6849e8fcd
Updated•3 months ago
|
Comment 1•3 months ago
|
||
Since nightly and release are affected, beta will likely be affected too.
For more information, please visit BugBot documentation.
Comment 2•3 months ago
|
||
Reproduced: this is a genuine Firefox web-compat issue on www.sanicare.de.
On the reported product page, clicking "In den Warenkorb" frequently does nothing in Firefox: the form's submit event fires, but no POST to /checkout/line-item/add is issued, no "Gute Wahl! 1 Produkt wurde hinzugefügt." confirmation appears, the header cart stays at 0,00 € and /checkout/cart is empty. Chrome, driven through the exact same steps on the same page, adds the product every single time.
The most reliable trigger is the site's own third-party newsletter pop-up ("1 von 3 Gutscheinen auswählen!", a full-viewport af2b1823.sibforms.com iframe inside #wpiam-message). While that overlay is on screen it covers the whole viewport and swallows the click in BOTH browsers (that part is not a compat difference). But after the overlay is dismissed with its own X button — at which point #wpiam-message is fully removed from the DOM in both browsers and document.elementFromPoint at the button's centre returns the button itself in both browsers — Chrome adds the product 3/3 and 5/5 times, while Firefox silently drops the add-to-cart in the majority of attempts. Firefox also fails occasionally (~1 in 4) when the button is clicked a few seconds after load without the pop-up ever being involved; it is consistently reliable only when the page has been left to settle for ~25-30 seconds. This matches the reporter's screenshot, which shows a normal-looking Firefox page with no pop-up and an empty cart after clicking.
Puppeteer confirmation script /app/repro/reproduction=huy0o_ll.mjs drives the real site (consent -> wait for pop-up -> close it via its X -> click "In den Warenkorb" -> verify the item on /checkout/cart): Firefox exits 1 (0/3 and 1/3 runs working), Chrome exits 0 (3/3 runs working).
No screenshot was taken because the breakage is a broken interaction, not a layout/rendering problem.
Updated•3 months ago
|
Comment 3•3 months ago
|
||
They also show a warning and recommending people to use Firefox.
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Comment 4•3 months ago
|
||
Root cause analysis generated by autowebcompat bot:
The site's add-to-cart is dropped because a Shopware plugin registration is torn down by a setTimeout(..., 0) before Shopware's DOMContentLoaded handler gets a chance to instantiate it — and in Firefox that 0 ms timer task runs before DOMContentLoaded is dispatched, whereas in Chrome DOMContentLoaded is dispatched first.
Mechanism, in the deferred theme bundle https://www.sanicare.de/s3/theme/…/js/all.js:
-
Shopware core registers, at module-evaluation time,
document.addEventListener("DOMContentLoaded", () => PluginManager.initializePlugins(), false).initializePlugins()walks the plugin registry and instantiates every plugin that is registered at that moment (withwindow.Feature.isActive("v6.6.0.0") === falseon this shop, that walk is fully synchronous). -
Later in the same bundle, the shop's own "ebiOffcanvas" module runs a function (minified
q). Becauseall.jsis adeferscript,document.readyStateis already"interactive"when it runs, so the branch"loading" === document.readyState ? addEventListener("DOMContentLoaded", q) : q()executesq()immediately.q():- deregisters the core
OffCanvasCartplugin and re-registers its own subclass for[data-off-canvas-cart]and[data-offcanvas-cart]; overridesAddToCartwith a subclass whoseredirectToisfrontend.cart.custom-offcanvas;- installs a delegated document-level submit handler:
document.addEventListener("submit", function (t) { if (t.defaultPrevented) return; const e = t.target; if (!e.hasAttribute("data-add-to-cart")) return; t.preventDefault(); const s = A.getPluginInstances("OffCanvasCart"); if (null == s || !s.length) return; // <-- silent early return const n = new FormData(e); n.delete("redirectTo"); n.delete("redirectParameters"); s.forEach(t => t.openOffCanvas(e.getAttribute("action"), n, null)); }); - and finally schedules the teardown of those registrations:
setTimeout(() => { deregister("OffCanvasCart", "[data-offcanvas-cart]"); deregister("OffCanvasCart", "[data-off-canvas-cart]"); deregister("OffCanvasCart"); }, 0).
- deregisters the core
So the code implicitly assumes that DOMContentLoaded (and therefore initializePlugins()) runs before the already-scheduled 0 ms timer. That assumption holds in Chrome, which dispatches DOMContentLoaded in the same task in which the last deferred script finishes, before yielding to expired timers. In Firefox the expired 0 ms timer task is run while the event loop is spun over the remaining deferred scripts, i.e. before DOMContentLoaded is dispatched (which the HTML spec does via a separately queued task). Consequently in Firefox OffCanvasCart is already deregistered when initializePlugins() runs, no OffCanvasCart instance is ever created, and both the delegated submit handler above and the overridden AddToCart plugin (_openOffCanvasCarts() iterates getPluginInstances("OffCanvasCart")) call preventDefault() and then do nothing: the submit event fires, the native POST is suppressed, and no XHR to /checkout/line-item/add is ever issued. Nothing about the newsletter overlay, click interception, or ETP is involved — the overlay only shifts timing, which is why the failure looks intermittent (whenever DOMContentLoaded happens to land in the same task as the deferred bundle, Firefox works too).
This is a race the site loses in Firefox, not a Firefox API gap: Firefox's ordering is the spec-conformant one (DOMContentLoaded is fired from a queued task), and Chrome's earlier dispatch is what accidentally makes the site work.
Evidence:
A. Live-site divergence isolated to one plugin instance (Firefox DevTools vs Chrome DevTools, same URL, consent accepted):
- Firefox:
PluginManager.getPluginInstances("OffCanvasCart")→ length 0;document.querySelector("[data-offcanvas-cart]").__plugins→ empty. - Chrome: 1 instance, options
{… additionalOffcanvasClass: "custom-cart-offcanvas", offcanvasPosition: "right" …}(i.e. the shop's custom subclass). - Both browsers identical for the neighbours:
AddToCart→ 3 instances (subclass withredirectTo: "frontend.cart.custom-offcanvas", so the shop'soverridedid run),CartWidget→ 1 instance, registration[data-add-to-cart]present.
B. The code path that silently drops the click (read out live from the page, and from the minified bundle):
AddToCart._formSubmit→t.preventDefault(); … this._openOffCanvasCarts(action, serialize(form))AddToCart._openOffCanvasCarts→const s = PluginManager.getPluginInstances("OffCanvasCart"); iterate(s, …)— an empty list means nothing is sent.- The ebi delegated
documentsubmit handler has the explicitif (null == s || !s.length) return;aftert.preventDefault(). PluginManager.initializePlugins()only instantiates plugins that have live entries inregistrations;window.Feature.isActive("v6.6.0.0")isfalseon this shop, so noawaithappens and the walk is synchronous.
C. Ordering instrumented before any page script ran (Puppeteer evaluateOnNewDocument hooking window.PluginManager's setter and wrapping register/deregister/initializePlugins, plus wrapping document.addEventListener("DOMContentLoaded", …)), /app/diagnosis/probe.mjs:
Firefox (ms since navigation start):
646 interactive PluginManager assigned
668 interactive register OffCanvasCart [data-offcanvas-cart] (core)
669 interactive addEventListener DOMContentLoaded ()=>l.Z.initializePlugins()
681 interactive deregister/register OffCanvasCart … (ebi q() runs inline)
704 interactive deregister OffCanvasCart x3 <-- the setTimeout(0) teardown FIRES HERE
757 interactive >> DCL listener start ()=>l.Z.initializePlugins()
757/799/810 initializePlugins() CALLED (asyncRegs=0)
825 interactive DCL done, OCC=header-cart{none}
1880 complete timeout1000 after DCL, OCC=header-cart{none}
final: header-cart{none}, Feature v6.6=false, ebiOffcanvasConfig={"active":true}
Chrome:
1097 interactive PluginManager assigned
1114 interactive register OffCanvasCart [data-offcanvas-cart]
1139 interactive deregister/register OffCanvasCart … (ebi q() runs inline)
1143 interactive >> DCL listener start ()=>l.Z.initializePlugins()
1187 interactive DCL done, OCC=header-cart{OffCanvasCart}
1242 interactive deregister OffCanvasCart x3 <-- setTimeout(0) teardown fires AFTER init
final: header-cart{OffCanvasCart}
Identical script order, identical registrations, asyncRegs=0 in both — the only difference is that Firefox ran the expired 0 ms timer at 704 ms, 53 ms before DOMContentLoaded was dispatched at 757 ms, while Chrome dispatched DOMContentLoaded 3.5 ms after the deferred bundle and only ran the timer 100 ms later. (In an earlier Firefox run the timer happened to fire at 1050 ms, i.e. after init — the same race the report describes as intermittent.)
D. Causal link to the reported symptom (/app/diagnosis/probe2.mjs, real page, overlay removed, real click on #productDetailPageBuyProductForm button.btn-buy, network sniffed for /checkout/line-item/add):
firefox run1: OffCanvasCartInstance=[none] addRequestSent=false
firefox run2: OffCanvasCartInstance=[none] addRequestSent=false
firefox run3: OffCanvasCartInstance=[none] addRequestSent=false
chrome run1: OffCanvasCartInstance=[OffCanvasCart] addRequestSent=true
chrome run2: OffCanvasCartInstance=[OffCanvasCart] addRequestSent=true
chrome run3: OffCanvasCartInstance=[OffCanvasCart] addRequestSent=true
Perfect 1:1 correlation between "an OffCanvasCart instance exists" and "the add-to-cart POST is sent". No page errors explain it: Firefox logs 4× Error: Element not found from initializePlugins()'s error collector but Chrome logs the same 4 errors too (Uncaught (in promise) Error: Element not found), so they are not the differentiator.
E. Reduced testcase /app/diagnosis/testcase=7b96mdwt.html, loaded from file:// in both browsers:
- Firefox:
order = ["deferred script 1 ran, document.readyState=interactive", "deferred script 2 ran", "setTimeout(0) callback: deregister OffCanvasCart (registry cleared)", "DOMContentLoaded: PluginManager.initializePlugins()"],timerRanBeforeDOMContentLoaded=true,instances=0; clicking the orange "In den Warenkorb" button → "ADD TO CART SILENTLY DROPPED (Firefox behaviour)". - Chrome:
order = ["deferred script 1 ran, document.readyState=interactive", "deferred script 2 ran", "DOMContentLoaded: PluginManager.initializePlugins()", "-> instantiated OffCanvasCart on [data-offcanvas-cart]", "setTimeout(0) callback: deregister OffCanvasCart (registry cleared)"],timerRanBeforeDOMContentLoaded=false,instances=1; clicking the button → "ADD TO CART WORKED (Chrome behaviour)".
The testcase reproduced deterministically on every load in both browsers.
Comment 5•3 months ago
|
||
Updated•3 months ago
|
Comment 6•3 months ago
|
||
Root cause analysis generated by autowebcompat bot:
Firefox runs an expired setTimeout(0) task before firing DOMContentLoaded; Chrome fires DOMContentLoaded first. In the deferred bundle all.js an ebi offcanvas module synchronously re-registers OffCanvasCart and overrides AddToCart, then calls setTimeout(deregister, 0), while the storefront instantiates plugins on DOMContentLoaded. Chrome creates the OffCanvasCart instance, Firefox never does. Both submit handlers call preventDefault then return silently when there are zero instances, so no POST to checkout line-item add is sent and the cart stays at 0,00 EUR.
Evidence:
PluginManager hooks, 5 loads each. Firefox 5 of 5: register 1449ms, setTimeout(0) deregister 1450ms, DOMContentLoaded plus initializePlugins 1507ms, 0 instances. Chrome 5 of 5: register 2737ms, DOMContentLoaded plus initializePlugins 2740ms, 1 instance, deregister 2815ms. Timer stack q() in all.js line 37. Firefox click with button topmost: submit defaultPrevented, no line-item add request, total 0,00 EUR, no errors. Creating one instance by hand made the next click POST line-item add and the total became 14,95 EUR. Testcase: Firefox FAIL, Chrome PASS.
Comment 7•3 months ago
|
||
Comment 8•3 months ago
|
||
Comment 9•3 months ago
|
||
Firefox logs:
DEFER
timeout
DCL inline
DCL
Chrome / WebKit:
DEFER
DCL inline
DCL
timeout
It seems we're resolving DOMContentLoaded async, which makes the timeout fire first. But if we're running the defer scripts at that point, firing DOMContentLoaded sync seems fine...
Updated•2 months ago
|
| Assignee | ||
Comment 10•2 months ago
•
|
||
We've had the more async behavior for normal Documents since https://bugzilla.mozilla.org/show_bug.cgi?id=344305.
Just backing out that ancient change would likely lead to similar crashes. But we could possibly use end-of-task model. Hmm, though, needs testing when promises are resolved in the other browsers, before or after DOMContentLoaded.
(Did the site work when we had still deferred setTimeout?)
(https://bugzilla.mozilla.org/show_bug.cgi?id=445330 changed behavior for data documents, but those are simple.)
| Assignee | ||
Comment 11•2 months ago
|
||
nsContentUtils::RunInStableState wouldn't work here, since we aren't allowed to dispatch DOM events there (for good reasons).
| Assignee | ||
Comment 12•2 months ago
|
||
Hmm, I can't reproduce the issue on the site.
| Assignee | ||
Comment 13•2 months ago
|
||
Comment 14•2 months ago
|
||
Your WIP patch fixes the problem for me.
| Assignee | ||
Comment 15•2 months ago
|
||
The patch does cause tons of test failures.
| Assignee | ||
Comment 16•2 months ago
•
|
||
Oh, found, https://wpt.fyi/results/html/syntax/parsing/DOMContentLoaded-defer.html?label=master&label=experimental&aligned&q=DOMContentLoaded-defer.html
There is even a test to check that what Gecko does is right.
Edit. Or that either behavior is fine.
Updated•2 months ago
|
| Assignee | ||
Updated•2 months ago
|
Comment 17•2 months ago
|
||
https://github.com/web-platform-tests/wpt/pull/2479 is what added that test, for what is worth.
Updated•2 months ago
|
Comment 18•2 months ago
|
||
https://html.spec.whatwg.org/multipage/parsing.html#the-end step 6 always fires DOMContentLoaded off a task, so we should probably fix the spec if we're changing this.
| Assignee | ||
Comment 19•2 months ago
•
|
||
The question is how. The ordering of tasks isn't guaranteed. Maybe we could remove that one task, and add another task later? Though, timeout might still run at random place.
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Comment 20•2 months ago
|
||
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/62568 for changes under testing/web-platform/tests
Comment 22•2 months ago
|
||
Comment 23•2 months ago
|
||
Backed out for causing mochitest failures @ browser_about_restricted.js
Backout link: https://hg.mozilla.org/integration/autoland/rev/00289483bd3e53bb97f9799c2f9fc2e738daf10b
Comment 24•2 months ago
|
||
also these xpc failures
Upstream PR was closed without merging
Updated•2 months ago
|
| Assignee | ||
Comment 26•2 months ago
|
||
Comment 27•2 months ago
|
||
Comment 28•2 months ago
|
||
Comment 29•2 months ago
|
||
Backed out for causing build bustages
Backout Link
Push with failures
Failure Log
Upstream PR was closed without merging
Comment 31•2 months ago
|
||
Comment 32•2 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/804c6b6730e6
https://hg.mozilla.org/mozilla-central/rev/9944515fa1ff
Upstream PR merged by moz-wptsync-bot
Updated•1 month ago
|
Updated•1 month ago
|
Comment 34•1 month ago
|
||
Verified as FIXED using the RC Build
Tested with:
Browser / Version: Firefox 158.0-candidate build 2
Operating System: Windows 10 PRO x64
Updated•1 month ago
|
Description
•