test_media_query_serialization.html (1566B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test media query list serialization</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 7 <style> 8 @media PrInT {} 9 @media screen, PrInT, SPEECH {} 10 11 @media GARbAGE7 {} 12 @media AAAAA {} 13 @media ZZZZZ {} 14 15 @media NotAValidMediaType_!000 {} 16 @media NotAValidMediaType_!000, AlsoInvalid!!!! {} 17 18 @media PrInT, GARbAGE7, notAValidMediaType_!000 {} 19 </style> 20 <script type="application/javascript"> 21 22 let expectedValues = [ 23 // Valid types 24 ["print", "Valid media types are ascii lowercased."], 25 ["screen, print, speech", "Media query lists with only valid types are ascii lowercased."], 26 27 // Invalid types 28 ["garbage7", "Invalid media types are ascii lowercased."], 29 ["aaaaa", "Ascii conversion handles 'A' correctly."], 30 ["zzzzz", "Ascii conversion handles 'Z' correctly."], 31 32 // Malformed types 33 ["not all", "Malformed media types are serialized to 'not all'."], 34 ["not all, not all", "Multiple malformed media types are each serialized to 'not all'."], 35 36 // Mixes 37 ["print, garbage7, not all", "Media query lists with a mix of valid, invalid, and malformed types serialize " + 38 "as lowercase with malformed types changed to 'not all'."], 39 ]; 40 41 let sheet = document.styleSheets[1]; 42 43 expectedValues.forEach(function (entry, index) { 44 let rule = sheet.cssRules[index]; 45 let serializedList = rule.media.mediaText; 46 is(serializedList, entry[0], entry[1]); 47 }); 48 49 </script> 50 </head> 51 <body> 52 </body> 53 </html>