Closed Bug 926974 Opened 6 years ago Closed 6 years ago

[markup view] Theme does not immediately apply after switching

Categories

(DevTools :: Inspector, defect)

x86
macOS
defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 27

People

(Reporter: bgrins, Assigned: bgrins)

Details

Attachments

(2 files)

Steps to reproduce:

Open devtools
Open the inspector panel and note the theme applied to the markup view
Open the devtools settings
Switch the theme
Go back to inspector panel

Expected behavior:
The markup view's theme will have been updated

Actual behavior:
The markup view's theme is still the same as the old one.


This appears to have been triggered by Bug 918996, somehow related to this line:

    window.matchMedia("(-moz-overlay-scrollbars)").matches

If this is replaced with either true or false, the theme switches as expected.

https://hg.mozilla.org/mozilla-central/rev/18e092a846a8#l2.12
Attached patch 926974.patchSplinter Review
theme-switching.js is throwing an exception the first time this is run on markup-view.xhtml in line 38 of theme-switching.js: https://hg.mozilla.org/mozilla-central/file/18e092a846a8/browser/devtools/shared/theme-switching.js#l38.

     "TypeError: window.matchMedia(...) is null"

This is causing the markup view to not bind to the "pref-changed" event and causes the error.  We could work around this issue using the hiddenDOMWindow instead of window.  It seems like maybe this is this a bug in the implementation that we need to get fixed?  According to https://developer.mozilla.org/en-US/docs/Web/API/window.matchMedia, this function should be returning a MediaQueryList, it doesn't specify any times that it should be returning null.  The main difference with this one place where it fails is that it seems to be that it is running inside of an HTML window.

Here is a patch that works around the problem by using the hiddenDOMWindow.  Should we go with this or deal with it some other way?
Attachment #817233 - Flags: review?(paul)
Attachment #817233 - Flags: review?(paul) → review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/a167805ff62e
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 27
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.