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 674809 6321ad706900be78df6aecc38e61fd6efcadc436
parent 674808 aa69a757a4c2fa43d0f5c5826360cf694d497be3
child 674810 ea75895145459f9f27c095c649a3bf61dc7a9279
push id82948
push userbmo:emilio@crisal.io
push dateWed, 04 Oct 2017 11:58:01 +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
@@ -754,27 +754,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 = "";
@@ -207,21 +202,21 @@ var generateCSSLines = function (resisti
   lines += ".suppress { background-color: " + (resisting ? "green" : "red") + ";}\n";
   suppressed_toggles.forEach(
     function (key) {
       let color = (resisting || toggles_enabled_in_content.indexOf(key) === -1)
         ? "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)");