Bug 169835 - MediaQueryList instances do not update for `prefers-reduced-motion`
Summary: MediaQueryList instances do not update for `prefers-reduced-motion`
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dean Jackson
Keywords: InRadar
Depends on:
Reported: 2017-03-17 15:58 PDT by Dean Jackson
Modified: 2017-03-17 16:41 PDT (History)
1 user (show)

See Also:

Patch (4.74 KB, patch)
2017-03-17 16:02 PDT, Dean Jackson
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Jackson 2017-03-17 15:58:36 PDT
From Rob Brackett

This is in Safari Tech Preview 22 on OS X 10.12.3. The reduced motion query does not appear to work in the current WebKit nightly (is that also a bug?)

MediaQueryList instances (created with `window.matchMedia(query)`) for the CSS `prefers-reduced-motion` query do not update their `matches` property or dispatch event listeners when the underlying system status changes. New instances do get the correct current value.

Steps To Reproduce:
1. Ensure “reduce motion” is off in OS X accessibility settings
2. Create a query, check its status, and add a listener with the following JS:

	var prefersReducedMotion = matchMedia(`(prefers-reduced-motion)`);
	prefersReducedMotion.matches; // false
	prefersReducedMotion.addListener(function () {
	  var currentValue = prefersReducedMotion.matches;
	  console.log(`Motion changed: ${currentValue ? `reduced` : `normal`}`);

3. Change motion preferences in the OS X accessibility settings panel

Expected Result:
The message “Motion changed: reduced” should have been logged to the console. Checking the JS `prefersReducedMotion.matches` should be `true`.

Nothing is logged. Checking `prefersReducedMotion.matches` is `false`.
However, creating a new query yields `true`:
	matchMedia(`(prefers-reduced-motion)`).matches; // true
Comment 1 Dean Jackson 2017-03-17 15:58:59 PDT
Comment 2 Dean Jackson 2017-03-17 16:02:27 PDT
Created attachment 304831 [details]
Comment 3 Dean Jackson 2017-03-17 16:41:56 PDT
Committed r214129: <http://trac.webkit.org/changeset/214129>