Bug 1396066: Restrict -moz-windows-theme and -moz-os-version to UA and chrome only. r?xidorn draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 02 Oct 2017 19:41:46 +0200
changeset 675933 45381639c6bc9651c2fa93df8e9aae778261ed97
parent 675932 77c763f82d33ca1bcdb3f03fdc9d5017eb885cb3
child 675934 775b6182e9c032e6dffe82a23978b0d2b360deec
push id83306
push userbmo:emilio@crisal.io
push dateFri, 06 Oct 2017 08:13:37 +0000
reviewersxidorn
bugs1396066
milestone58.0a1
Bug 1396066: Restrict -moz-windows-theme and -moz-os-version to UA and chrome only. r?xidorn MozReview-Commit-ID: 9iEhkcZb52C
layout/style/nsMediaFeatures.cpp
layout/style/test/chrome/bug418986-2.js
layout/style/test/test_media_queries.html
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -762,27 +762,25 @@ nsMediaFeatures::features[] = {
     nsMediaFeature::eUserAgentAndChromeOnly,
     { &nsGkAtoms::menubar_drag },
     GetSystemMetric
   },
   {
     &nsGkAtoms::_moz_windows_theme,
     nsMediaFeature::eMinMaxNotAllowed,
     nsMediaFeature::eIdent,
-    // TODO(emilio): Unship.
-    nsMediaFeature::eNoRequirements,
+    nsMediaFeature::eUserAgentAndChromeOnly,
     { nullptr },
     GetWindowsTheme
   },
   {
     &nsGkAtoms::_moz_os_version,
     nsMediaFeature::eMinMaxNotAllowed,
     nsMediaFeature::eIdent,
-    // TODO(emilio): Unship.
-    nsMediaFeature::eNoRequirements,
+    nsMediaFeature::eUserAgentAndChromeOnly,
     { nullptr },
     GetOperatingSystemVersion
   },
 
   {
     &nsGkAtoms::_moz_swipe_animation_enabled,
     nsMediaFeature::eMinMaxNotAllowed,
     nsMediaFeature::eBoolInteger,
--- a/layout/style/test/chrome/bug418986-2.js
+++ b/layout/style/test/chrome/bug418986-2.js
@@ -123,22 +123,17 @@ var testToggles = function (resisting) {
 // Runs a media query on the queryName with the given possible matching values.
 var testWindowsSpecific = function (resisting, queryName, possibleValues) {
   let foundValue = null;
   possibleValues.forEach(function (val) {
     if (keyValMatches(queryName, val)) {
       foundValue = val;
     }
   });
-  if (resisting) {
-    ok(!foundValue, queryName + " should have no match");
-  } else {
-    ok(foundValue, foundValue ? ("Match found: '" + queryName + ":" + foundValue + "'")
-                              : "Should have a match for '" + queryName + "'");
-  }
+  ok(!foundValue, queryName + " should have no match");
 };
 
 // __generateHtmlLines(resisting)__.
 // Create a series of div elements that look like:
 // `<div class='spoof' id='resolution'>resolution</div>`,
 // where each line corresponds to a different media query.
 var generateHtmlLines = function (resisting) {
   let lines = "";
@@ -206,21 +201,21 @@ var generateCSSLines = function (resisti
     });
   lines += ".suppress { background-color: " + (resisting ? "green" : "red") + ";}\n";
   suppressed_toggles.forEach(
     function (key) {
       let color = resisting ? "red" : "green";
       lines += suppressedMediaQueryCSSLine(key, color);
     });
   if (OS === "WINNT") {
-    lines += ".windows { background-color: " + (resisting ? "green" : "red") + ";}\n";
+    lines += ".windows { background-color: green; }\n";
     lines += windows_versions.map(val => "(-moz-os-version: " + val + ")").join(", ") +
-             " { #-moz-os-version { background-color: " + (resisting ? "red" : "green") + ";} }\n";
+             " { #-moz-os-version { background-color: red; } }\n";
     lines += windows_themes.map(val => "(-moz-windows-theme: " + val + ")").join(",") +
-             " { #-moz-windows-theme { background-color: " + (resisting ? "red" : "green") + ";} }\n";
+             " { #-moz-windows-theme { background-color: red; }\n";
   }
   return lines;
 };
 
 // __green__.
 // Returns the computed color style corresponding to green.
 var green = (function () {
   let temp = document.createElement("span");
--- a/layout/style/test/test_media_queries.html
+++ b/layout/style/test/test_media_queries.html
@@ -708,33 +708,33 @@ function run() {
   expression_should_not_be_parseable("-moz-mac-yosemite-theme: true");
   expression_should_not_be_parseable("-moz-windows-accent-color-in-titlebar: true");
   expression_should_not_be_parseable("-moz-windows-compositor: true");
   expression_should_not_be_parseable("-moz-windows-classic: true");
   expression_should_not_be_parseable("-moz-windows-glass: true");
   expression_should_not_be_parseable("-moz-touch-enabled: true");
   expression_should_not_be_parseable("-moz-swipe-animation-enabled: true");
 
-  // windows theme media queries
-  expression_should_be_parseable("-moz-windows-theme: aero");
-  expression_should_be_parseable("-moz-windows-theme: aero-lite");
-  expression_should_be_parseable("-moz-windows-theme: luna-blue");
-  expression_should_be_parseable("-moz-windows-theme: luna-olive");
-  expression_should_be_parseable("-moz-windows-theme: luna-silver");
-  expression_should_be_parseable("-moz-windows-theme: royale");
-  expression_should_be_parseable("-moz-windows-theme: generic");
-  expression_should_be_parseable("-moz-windows-theme: zune");
-  expression_should_be_parseable("-moz-windows-theme: garbage");
+  // windows theme media queries (internal too, so not parseable).
+  expression_should_not_be_parseable("-moz-windows-theme: aero");
+  expression_should_not_be_parseable("-moz-windows-theme: aero-lite");
+  expression_should_not_be_parseable("-moz-windows-theme: luna-blue");
+  expression_should_not_be_parseable("-moz-windows-theme: luna-olive");
+  expression_should_not_be_parseable("-moz-windows-theme: luna-silver");
+  expression_should_not_be_parseable("-moz-windows-theme: royale");
+  expression_should_not_be_parseable("-moz-windows-theme: generic");
+  expression_should_not_be_parseable("-moz-windows-theme: zune");
+  expression_should_not_be_parseable("-moz-windows-theme: garbage");
   expression_should_not_be_parseable("-moz-windows-theme: ''");
   expression_should_not_be_parseable("-moz-windows-theme: ");
 
-  // os version media queries (currently windows only)
-  expression_should_be_parseable("-moz-os-version: windows-win7");
-  expression_should_be_parseable("-moz-os-version: windows-win8");
-  expression_should_be_parseable("-moz-os-version: windows-win10");
+  // os version media queries (currently windows only, and internal)
+  expression_should_not_be_parseable("-moz-os-version: windows-win7");
+  expression_should_not_be_parseable("-moz-os-version: windows-win8");
+  expression_should_not_be_parseable("-moz-os-version: windows-win10");
   expression_should_not_be_parseable("-moz-os-version: ");
 
   // OpenType SVG media features
   query_should_be_parseable("(-moz-is-glyph)");
   query_should_not_be_parseable("not (-moz-is-glyph)");
   query_should_not_be_parseable("only (-moz-is-glyph)");
   query_should_be_parseable("all and (-moz-is-glyph)");
   query_should_be_parseable("not all and (-moz-is-glyph)");