Bug 169835

Summary: MediaQueryList instances do not update for `prefers-reduced-motion`
Product: WebKit Reporter: Dean Jackson <dino>
Component: AccessibilityAssignee: Dean Jackson <dino>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch andersca: review+

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?)

Summary:
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`.

Results:
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
<rdar://problem/30339378>
Comment 2 Dean Jackson 2017-03-17 16:02:27 PDT
Created attachment 304831 [details]
Patch
Comment 3 Dean Jackson 2017-03-17 16:41:56 PDT
Committed r214129: <http://trac.webkit.org/changeset/214129>