Bug 1371395 Part 5: Add a test of media query list serialization of valid, invalid, and malformed types.
MozReview-Commit-ID: IzKmbIuCZ5c
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -235,16 +235,17 @@ skip-if = !stylo
[test_keyframes_vendor_prefix.html]
[test_load_events_on_stylesheets.html]
[test_logical_properties.html]
[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_of_type_selectors.xhtml]
[test_page_parser.html]
[test_parse_eof.html]
[test_parse_ident.html]
[test_parse_rule.html]
[test_parse_url.html]
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_media_query_serialization.html
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Test media query list serialization</title>
+<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+<style>
+ @media PrInT {}
+ @media screen, PrInT, SPEECH {}
+
+ @media GARbAGE7 {}
+ @media AAAAA {}
+ @media ZZZZZ {}
+
+ @media NotAValidMediaType_!000 {}
+ @media NotAValidMediaType_!000, AlsoInvalid!!!! {}
+
+ @media PrInT, GARbAGE7, notAValidMediaType_!000 {}
+</style>
+<script type="application/javascript">
+
+let expectedValues = [
+ // Valid types
+ ["print", "Valid media types are ascii lowercased."],
+ ["screen, print, speech", "Media query lists with only valid types are ascii lowercased."],
+
+ // Invalid types
+ ["garbage7", "Invalid media types are ascii lowercased."],
+ ["aaaaa", "Ascii conversion handles 'A' correctly."],
+ ["zzzzz", "Ascii conversion handles 'Z' correctly."],
+
+ // Malformed types
+ ["not all", "Malformed media types are serialized to 'not all'."],
+ ["not all, not all", "Multiple malformed media types are each serialized to 'not all'."],
+
+ // Mixes
+ ["print, garbage7, not all", "Media query lists with a mix of valid, invalid, and malformed types serialize " +
+ "as lowercase with malformed types changed to 'not all'."],
+];
+
+let sheet = document.styleSheets[1];
+
+expectedValues.forEach(function (entry, index) {
+ let rule = sheet.cssRules[index];
+ let serializedList = rule.media.mediaText;
+ is(serializedList, entry[0], entry[1]);
+});
+
+</script>
+</head>
+<body>
+</body>
+</html>