Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: LayoutTests/css3/escape-dom-api.html

Issue 1253403005: Implement CSS.escape (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix final test Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/css3/escape-dom-api-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/css3/escape-dom-api.html
diff --git a/LayoutTests/css3/escape-dom-api.html b/LayoutTests/css3/escape-dom-api.html
new file mode 100644
index 0000000000000000000000000000000000000000..b4cbfe6cd8517d718260bc47cf3c457976a70437
--- /dev/null
+++ b/LayoutTests/css3/escape-dom-api.html
@@ -0,0 +1,75 @@
+<!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()");
+
+ shouldThrow("CSS.escape('\0')");
+ shouldThrow("CSS.escape('a\0')");
+ shouldThrow("CSS.escape('\0b')");
+ shouldThrow("CSS.escape('a\0b')");
+
+ shouldThrow("CSS.escape()");
+ 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('--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>
« no previous file with comments | « no previous file | LayoutTests/css3/escape-dom-api-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698