matchMedia matches object not fully updated before first listener fired in Windows Firefox
Categories
(Core :: DOM: CSS Object Model, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox80 | --- | fixed |
People
(Reporter: zach, Assigned: emilio)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Steps to reproduce:
In Firefox on Windows (Mac seems fine), create more than one matchMedia objects and add listeners to each. Inside of the listeners, loop through ALL of the matchMedia matches objects and check their values.
Demo: https://codepen.io/GreenSock/pen/a032bd02b4a8802b07f65a3b2a814002?editors=0011
Actual results:
In the beginning listeners, the matches values for the later media queries are not yet updated like they should be.
Example result (going from larger than the breakpoint to smaller):
"checking. window.innerWidth:" 752
0 "matches:" false
1 "matches:" false
"checking. window.innerWidth:" 752
0 "matches:" false
1 "matches:" true
Expected results:
All of the matches objects should be updated BEFORE the first listener callback is fired.
Example result (going from larger than the breakpoint to smaller):
"checking. window.innerWidth:" 752
0 "matches:" false
1 "matches:" true
"checking. window.innerWidth:" 752
0 "matches:" false
1 "matches:" true
Comment 1•4 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Reporter | ||
Comment 2•4 years ago
|
||
I think Bubbug's classification may be incorrect unless media queries fit under WebRTC...
Updated•4 years ago
|
Assignee | ||
Comment 3•4 years ago
|
||
MaybeNotify()
fires the event synchronously. Should be pretty easy to fix to update them and keep track of the changed ones, then notify in one go.
Assignee | ||
Comment 4•4 years ago
|
||
Bug 1648064 does some changes to related code so I'll move them here too while at it.
Assignee | ||
Comment 5•4 years ago
|
||
We need to notify unconditionally because even if we didn't have
stylesheets, we could have responsive content which needs to change
source.
We need to notify the document even if the pres shell is not
initialized, as it might be our last chance to notify the responsive
content. This happens for printing, and makes my srcset test fail.
Assignee | ||
Comment 6•4 years ago
|
||
This ensures that you can't observe an inconsistent state while we go
through the list.
It should also be marginally better as we don't build an array with all
the media queries unconditionally.
Depends on D81778
Pushed by emilio@crisal.io: https://hg.mozilla.org/integration/autoland/rev/cff48285254b Fix two issues with notifications for media feature value changes. r=nordzilla
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b13a90288742 Evaluate changes in all media queries, then fire change events. r=jwatt
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/24551 for changes under testing/web-platform/tests
Comment 10•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/cff48285254b
https://hg.mozilla.org/mozilla-central/rev/b13a90288742
Upstream PR merged by moz-wptsync-bot
Description
•