Bug 1417578: Add a test for non-content-accessible properties, and make stylo and Gecko consistent. r?xidorn
MozReview-Commit-ID: 2n773xkmAqX
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -4495,41 +4495,45 @@ CSS_PROP_UIRESET(
VARIANT_HK,
kWindowShadowKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
CSS_PROP_UIRESET(
-moz-window-opacity,
_moz_window_opacity,
CSS_PROP_DOMPROP_PREFIXED(WindowOpacity),
- CSS_PROPERTY_INTERNAL | CSS_PROPERTY_PARSE_VALUE,
+ CSS_PROPERTY_INTERNAL |
+ CSS_PROPERTY_PARSE_VALUE |
+ CSS_PROPERTY_ENABLED_IN_UA_SHEETS_AND_CHROME,
"",
VARIANT_HN,
nullptr,
offsetof(nsStyleUIReset, mWindowOpacity),
eStyleAnimType_float)
CSS_PROP_UIRESET(
-moz-window-transform,
_moz_window_transform,
CSS_PROP_DOMPROP_PREFIXED(WindowTransform),
CSS_PROPERTY_INTERNAL |
- CSS_PROPERTY_PARSE_FUNCTION |
+ CSS_PROPERTY_PARSE_VALUE |
+ CSS_PROPERTY_ENABLED_IN_UA_SHEETS_AND_CHROME |
CSS_PROPERTY_GETCS_NEEDS_LAYOUT_FLUSH,
"",
0,
nullptr,
offsetof(nsStyleUIReset, mSpecifiedWindowTransform),
eStyleAnimType_Custom)
CSS_PROP_UIRESET(
-moz-window-transform-origin,
_moz_window_transform_origin,
CSS_PROP_DOMPROP_PREFIXED(WindowTransformOrigin),
CSS_PROPERTY_INTERNAL |
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_STORES_CALC |
+ CSS_PROPERTY_ENABLED_IN_UA_SHEETS_AND_CHROME |
CSS_PROPERTY_GETCS_NEEDS_LAYOUT_FLUSH,
"",
0,
kImageLayerPositionKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_Custom)
#endif // CSS_PROP_LIST_EXCLUDE_INTERNAL
CSS_PROP_TEXT(
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -248,16 +248,17 @@ skip-if = !stylo
[test_media_queries.html]
skip-if = android_version == '18' #debug-only failure; timed out #Android 4.3 aws only; bug 1030419
[test_media_queries_dynamic.html]
[test_media_queries_dynamic_xbl.html]
[test_media_query_list.html]
[test_media_query_serialization.html]
[test_moz_device_pixel_ratio.html]
[test_namespace_rule.html]
+[test_non_content_accessible_properties.html]
[test_of_type_selectors.xhtml]
[test_page_parser.html]
[test_parse_eof.html]
[test_parse_ident.html]
[test_parse_rule.html]
[test_parse_url.html]
[test_parser_diagnostics_unprintables.html]
[test_pixel_lengths.html]
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_non_content_accessible_properties.html
@@ -0,0 +1,56 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style id="sheet"></style>
+<div></div>
+<script>
+const NON_CONTENT_ACCESSIBLE_PROPERTIES = [
+ "-x-span",
+ "-x-lang",
+ "-x-text-zoom",
+ "-moz-window-shadow",
+ "-moz-window-opacity",
+ "-moz-window-transform",
+ "-moz-window-transform-origin",
+ "-moz-top-layer",
+ "-moz-script-size-multiplier",
+ "-moz-script-level",
+ "-moz-math-display",
+ "-moz-math-variant",
+ "-moz-script-min-size",
+ "-moz-font-smoothing-background-color",
+ "-moz-min-font-size-ratio",
+ "-moz-script-size-multiplier",
+];
+
+const sheet = document.getElementById("sheet");
+const div = document.querySelector("div");
+
+test(function() {
+ sheet.textContent = `div { color: initial }`;
+ assert_equals(sheet.sheet.cssRules[0].style.length, 1);
+}, "sanity");
+
+for (const prop of NON_CONTENT_ACCESSIBLE_PROPERTIES) {
+ test(function() {
+ sheet.textContent = `div { ${prop}: initial }`;
+ let block = sheet.sheet.cssRules[0].style;
+ assert_equals(
+ block.length,
+ 0,
+ prop + " shouldn't be parsed in content"
+ );
+ block.setProperty(prop, "initial");
+ assert_equals(
+ block.length,
+ 0,
+ prop + " shouldn't be settable via CSSOM in content"
+ );
+ assert_equals(
+ getComputedStyle(div).getPropertyValue(prop),
+ "",
+ prop + " shouldn't be accessible via CSSOM in content"
+ );
+ }, prop);
+}
+</script>