| <!DOCTYPE HTML> |
| <html> |
| <head> |
| <script src="../resources/js-test.js"></script> |
| </head> |
| <body> |
| <script> |
| // Test from https://github.com/mathiasbynens/CSS.escape |
| description("Test window.CSS.escape()"); |
| |
| shouldBe("CSS.escape.length", "1"); |
| |
| shouldBeEqualToString("CSS.escape('\0')", "\ufffd"); |
| shouldBeEqualToString("CSS.escape('a\0')", "a\ufffd"); |
| shouldBeEqualToString("CSS.escape('\0b')", "\ufffdb"); |
| shouldBeEqualToString("CSS.escape('a\0b')", "a\ufffdb"); |
| |
| shouldBeEqualToString("CSS.escape('\ufffd')", "\ufffd"); |
| shouldBeEqualToString("CSS.escape('a\ufffd')", "a\ufffd"); |
| shouldBeEqualToString("CSS.escape('\ufffdb')", "\ufffdb"); |
| shouldBeEqualToString("CSS.escape('a\ufffdb')", "a\ufffdb"); |
| |
| shouldThrow("CSS.escape()"); |
| shouldBeEqualToString("CSS.escape(undefined)", "undefined"); |
| shouldBeEqualToString("CSS.escape(true)", "true"); |
| shouldBeEqualToString("CSS.escape(false)", "false"); |
| shouldBeEqualToString("CSS.escape(null)", "null"); |
| shouldBeEqualToString("CSS.escape('')", ""); |
| |
| shouldBeEqualToString("CSS.escape('\x01\x02\x1E\x1F')", "\\1 \\2 \\1e \\1f "); |
| |
| shouldBeEqualToString("CSS.escape('0a')", "\\30 a"); |
| shouldBeEqualToString("CSS.escape('1a')", "\\31 a"); |
| shouldBeEqualToString("CSS.escape('2a')", "\\32 a"); |
| shouldBeEqualToString("CSS.escape('3a')", "\\33 a"); |
| shouldBeEqualToString("CSS.escape('4a')", "\\34 a"); |
| shouldBeEqualToString("CSS.escape('5a')", "\\35 a"); |
| shouldBeEqualToString("CSS.escape('6a')", "\\36 a"); |
| shouldBeEqualToString("CSS.escape('7a')", "\\37 a"); |
| shouldBeEqualToString("CSS.escape('8a')", "\\38 a"); |
| shouldBeEqualToString("CSS.escape('9a')", "\\39 a"); |
| |
| shouldBeEqualToString("CSS.escape('a0b')", "a0b"); |
| shouldBeEqualToString("CSS.escape('a1b')", "a1b"); |
| shouldBeEqualToString("CSS.escape('a2b')", "a2b"); |
| shouldBeEqualToString("CSS.escape('a3b')", "a3b"); |
| shouldBeEqualToString("CSS.escape('a4b')", "a4b"); |
| shouldBeEqualToString("CSS.escape('a5b')", "a5b"); |
| shouldBeEqualToString("CSS.escape('a6b')", "a6b"); |
| shouldBeEqualToString("CSS.escape('a7b')", "a7b"); |
| shouldBeEqualToString("CSS.escape('a8b')", "a8b"); |
| shouldBeEqualToString("CSS.escape('a9b')", "a9b"); |
| |
| shouldBeEqualToString("CSS.escape('-0a')", "-\\30 a"); |
| shouldBeEqualToString("CSS.escape('-1a')", "-\\31 a"); |
| shouldBeEqualToString("CSS.escape('-2a')", "-\\32 a"); |
| shouldBeEqualToString("CSS.escape('-3a')", "-\\33 a"); |
| shouldBeEqualToString("CSS.escape('-4a')", "-\\34 a"); |
| shouldBeEqualToString("CSS.escape('-5a')", "-\\35 a"); |
| shouldBeEqualToString("CSS.escape('-6a')", "-\\36 a"); |
| shouldBeEqualToString("CSS.escape('-7a')", "-\\37 a"); |
| shouldBeEqualToString("CSS.escape('-8a')", "-\\38 a"); |
| shouldBeEqualToString("CSS.escape('-9a')", "-\\39 a"); |
| |
| shouldBeEqualToString("CSS.escape('-')", "\\-"); |
| shouldBeEqualToString("CSS.escape('-a')", "-a"); |
| shouldBeEqualToString("CSS.escape('--')", "--"); |
| shouldBeEqualToString("CSS.escape('--a')", "--a"); |
| |
| shouldBeEqualToString("CSS.escape('\x80\x2D\x5F\xA9')", "\x80\x2D\x5F\xA9"); |
| shouldBeEqualToString("CSS.escape('\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F')", "\\7f \x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F"); |
| shouldBeEqualToString("CSS.escape('\xA0\xA1\xA2')", "\xA0\xA1\xA2"); |
| shouldBeEqualToString("CSS.escape('a0123456789b')", "a0123456789b"); |
| shouldBeEqualToString("CSS.escape('abcdefghijklmnopqrstuvwxyz')", "abcdefghijklmnopqrstuvwxyz"); |
| shouldBeEqualToString("CSS.escape('ABCDEFGHIJKLMNOPQRSTUVWXYZ')", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
| |
| shouldBeEqualToString("CSS.escape('\x20\x21\x78\x79')", "\\ \\!xy"); |
| |
| // astral symbol (U+1D306 TETRAGRAM FOR CENTRE) |
| shouldBeEqualToString("CSS.escape('\uD834\uDF06')", "\uD834\uDF06"); |
| // lone surrogates |
| shouldBeEqualToString("CSS.escape('\uDF06')", '\uDF06'); |
| shouldBeEqualToString("CSS.escape('\uD834')", '\uD834'); |
| </script> |
| </body> |
| </html> |