2006-11-02 W. Andy Carrel <wac@google.com>
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Nov 2006 03:23:02 +0000 (03:23 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Nov 2006 03:23:02 +0000 (03:23 +0000)
        Reviewed by Maciej, landed by Anders.

        Adding tests for Unicode RegExp behavior to match IE and Firefox.
        * fast/js/regexp-unicode-handling-expected.txt: Added.
        * fast/js/regexp-unicode-handling.html: Added.
        * fast/js/resources/regexp-unicode-handling.js: Added.

2006-11-02  Alexey Proskuryakov  <ap@nypop.com>

        Reviewed by Maciej, landed by Anders.

        Test for bugs 7253 and 7445, based on reductions made by Parag Shah and W. Andy Carrel.

        * fast/js/gmail-re-re-expected.txt: Added.
        * fast/js/gmail-re-re.html: Added.
        * fast/js/resources/gmail-re-re.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17556 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/js/gmail-re-re-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/gmail-re-re.html [new file with mode: 0644]
LayoutTests/fast/js/regexp-unicode-handling-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/regexp-unicode-handling.html [new file with mode: 0644]
LayoutTests/fast/js/resources/gmail-re-re.js [new file with mode: 0644]
LayoutTests/fast/js/resources/regexp-unicode-handling.js [new file with mode: 0644]

index ad9bc4915ed652788b5d7aad562fe275feccd28b..f9f745f4694dceb64a4bb67cb38b8a0b4371c481 100644 (file)
@@ -1,3 +1,22 @@
+2006-11-02  W. Andy Carrel  <wac@google.com>
+
+        Reviewed by Maciej, landed by Anders.
+        
+        Adding tests for Unicode RegExp behavior to match IE and Firefox.
+        * fast/js/regexp-unicode-handling-expected.txt: Added.
+        * fast/js/regexp-unicode-handling.html: Added.
+        * fast/js/resources/regexp-unicode-handling.js: Added.
+
+2006-11-02  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Maciej, landed by Anders.
+
+        Test for bugs 7253 and 7445, based on reductions made by Parag Shah and W. Andy Carrel.
+
+        * fast/js/gmail-re-re-expected.txt: Added.
+        * fast/js/gmail-re-re.html: Added.
+        * fast/js/resources/gmail-re-re.js: Added.
+
 2006-11-02  Geoffrey Garen  <ggaren@apple.com>
 
         Updated results to fix failure seen when running layout tests. Justin 
diff --git a/LayoutTests/fast/js/gmail-re-re-expected.txt b/LayoutTests/fast/js/gmail-re-re-expected.txt
new file mode 100644 (file)
index 0000000..1e88b88
--- /dev/null
@@ -0,0 +1,12 @@
+Bug 7445, bug 7253: Handle Unicode escapes in regexps.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS cy("Re: Hello") is "Hello"
+PASS cy("Ответ: Hello") is "Hello"
+PASS regex.exec("24#Midnight").toString() is "24#Midnight,24,#,Midnight"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/js/gmail-re-re.html b/LayoutTests/fast/js/gmail-re-re.html
new file mode 100644 (file)
index 0000000..19dc1f4
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/js-test-style.css">
+<script src="resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/gmail-re-re.js"></script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/js/regexp-unicode-handling-expected.txt b/LayoutTests/fast/js/regexp-unicode-handling-expected.txt
new file mode 100644 (file)
index 0000000..1416afb
--- /dev/null
@@ -0,0 +1,49 @@
+Test for proper handling of Unicode RegExps and bug 7445: Gmail puts wrong subject in replies.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS cy('Re: Moose') is 'Moose'
+PASS cy('\u8f6c\u53d1: Moose') is 'Moose'
+PASS inlineRe.source is newFromInlineRe.source
+PASS inlineRe.source is evalFromInlineRe.source
+PASS inlineRe.source is evalInlineRe.source
+PASS inlineRe.source is newFromEvalInlineRe.source
+PASS inlineRe.source is evalFromEvalInlineRe.source
+PASS inlineRe.source is explicitRe.source
+PASS inlineRe.source is newFromExplicitRe.source
+PASS inlineRe.source is evalFromExplicitRe.source
+PASS inlineRe.toString() is newFromInlineRe.toString()
+PASS inlineRe.toString() is evalFromInlineRe.toString()
+PASS inlineRe.toString() is evalInlineRe.toString()
+PASS inlineRe.toString() is newFromEvalInlineRe.toString()
+PASS inlineRe.toString() is evalFromEvalInlineRe.toString()
+PASS inlineRe.toString() is explicitRe.toString()
+PASS inlineRe.toString() is newFromExplicitRe.toString()
+PASS inlineRe.toString() is evalFromExplicitRe.toString()
+PASS inlineRe.exec(sample)[0] is 'bm⠠p'
+PASS evalInlineRe.exec(sample)[0] is 'bm⠠p'
+PASS explicitRe.exec(sample)[0] is 'bm⠠p'
+PASS binlineRe.source is bnewFromInlineRe.source
+PASS binlineRe.source is bevalFromInlineRe.source
+PASS binlineRe.source is bevalInlineRe.source
+PASS binlineRe.source is bnewFromEvalInlineRe.source
+PASS binlineRe.source is bevalFromEvalInlineRe.source
+PASS binlineRe.source is bexplicitRe.source
+PASS binlineRe.source is bnewFromExplicitRe.source
+PASS binlineRe.source is bevalFromExplicitRe.source
+PASS binlineRe.toString() is bnewFromInlineRe.toString()
+PASS binlineRe.toString() is bevalFromInlineRe.toString()
+PASS binlineRe.toString() is bevalInlineRe.toString()
+PASS binlineRe.toString() is bnewFromEvalInlineRe.toString()
+PASS binlineRe.toString() is bevalFromEvalInlineRe.toString()
+PASS binlineRe.toString() is bexplicitRe.toString()
+PASS binlineRe.toString() is bnewFromExplicitRe.toString()
+PASS binlineRe.toString() is bevalFromExplicitRe.toString()
+PASS binlineRe.exec(bsample)[0] is 'bm|p'
+PASS bevalInlineRe.exec(bsample)[0] is 'bm|p'
+PASS bexplicitRe.exec(bsample)[0] is 'bm|p'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/js/regexp-unicode-handling.html b/LayoutTests/fast/js/regexp-unicode-handling.html
new file mode 100644 (file)
index 0000000..dcdd51e
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/js-test-style.css">
+<script src="resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/regexp-unicode-handling.js"></script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/js/resources/gmail-re-re.js b/LayoutTests/fast/js/resources/gmail-re-re.js
new file mode 100644 (file)
index 0000000..b0de12e
--- /dev/null
@@ -0,0 +1,38 @@
+description(
+"Bug 7445, bug 7253: Handle Unicode escapes in regexps."
+);
+
+var I3=/^\s*(fwd|re|aw|antw|antwort|wg|sv|ang|odp|betreff|betr|transf|reenv\.|reenv|in|res|resp|resp\.|enc|\u8f6c\u53d1|\u56DE\u590D|\u041F\u0435\u0440\u0435\u0441\u043B|\u041E\u0442\u0432\u0435\u0442):\s*(.*)$/i;
+
+// Other RegExs from Gmail source
+var Ci=/\s+/g;
+var BC=/^ /;
+var BG=/ $/;
+
+// Strips leading Re or similar (from Gmail source)
+function cy(a) {
+    //var b = I3.exec(a);
+    var b = I3.exec(a);
+
+    if (b) {
+        a = b[2];
+    }
+
+    return Gn(a);
+}
+
+// This function replaces consecutive whitespace with a single space
+// then removes a leading and trailing space if they exist. (From Gmail)
+function Gn(a) {
+    return a.replace(Ci, " ").replace(BC, "").replace(BG, "");
+}
+
+shouldBe('cy("Re: Hello")', '"Hello"');
+shouldBe('cy("Ответ: Hello")', '"Hello"');
+
+// ---------------------------------------------------------------
+
+var regex = /^([^#<\u2264]+)([#<\u2264])(.*)$/;
+shouldBe('regex.exec("24#Midnight").toString()', '"24#Midnight,24,#,Midnight"');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/js/resources/regexp-unicode-handling.js b/LayoutTests/fast/js/resources/regexp-unicode-handling.js
new file mode 100644 (file)
index 0000000..9efa0bb
--- /dev/null
@@ -0,0 +1,107 @@
+description(
+
+'Test for proper handling of Unicode RegExps and <a href="http://bugzilla.webkit.org/show_bug.cgi?id=7445">bug 7445</a>: Gmail puts wrong subject in replies.'
+
+);
+
+// Regex to match Re in various languanges straight from Gmail source
+var I3=/^\s*(fwd|re|aw|antw|antwort|wg|sv|ang|odp|betreff|betr|transf|reenv\.|reenv|in|res|resp|resp\.|enc|\u8f6c\u53d1|\u56DE\u590D|\u041F\u0435\u0440\u0435\u0441\u043B|\u041E\u0442\u0432\u0435\u0442):\s*(.*)$/i;
+
+// Other RegExs from Gmail source
+var Ci=/\s+/g;
+var BC=/^ /;
+var BG=/ $/;
+
+// Strips leading Re or similar (from Gmail source)
+function cy(a) {
+    //var b = I3.exec(a);
+    var b = I3.exec(a);
+
+    if (b) {
+        a = b[2];
+    }
+
+    return Gn(a);
+}
+
+// This function replaces consecutive whitespace with a single space
+// then removes a leading and trailing space if they exist. (From Gmail)
+function Gn(a) {
+    return a.replace(Ci, " ").replace(BC, "").replace(BG, "");
+}
+
+shouldBe("cy('Re: Moose')", "'Moose'")
+shouldBe("cy('\\u8f6c\\u53d1: Moose')", "'Moose'")
+
+// Test handling of \u2820 (skull and crossbones)
+var sample="sample bm\u2820p cm\\u2820p";
+
+var inlineRe=/.m\u2820p/
+var evalInlineRe=eval("/.m\\u2820p/")
+var explicitRe=new RegExp(".m\\u2820p")
+var newFromInlineRe=new RegExp(inlineRe.source)
+var evalFromInlineRe=eval(inlineRe.toString())
+var newFromEvalInlineRe=new RegExp(evalInlineRe.source)
+var evalFromEvalInlineRe=eval(evalInlineRe.toString())
+var newFromExplicitRe=new RegExp(explicitRe.source)
+var evalFromExplicitRe=eval(explicitRe.toString())
+
+shouldBe("inlineRe.source", "newFromInlineRe.source")
+shouldBe("inlineRe.source", "evalFromInlineRe.source")
+shouldBe("inlineRe.source", "evalInlineRe.source")
+shouldBe("inlineRe.source", "newFromEvalInlineRe.source")
+shouldBe("inlineRe.source", "evalFromEvalInlineRe.source")
+shouldBe("inlineRe.source", "explicitRe.source")
+shouldBe("inlineRe.source", "newFromExplicitRe.source")
+shouldBe("inlineRe.source", "evalFromExplicitRe.source")
+
+shouldBe("inlineRe.toString()", "newFromInlineRe.toString()")
+shouldBe("inlineRe.toString()", "evalFromInlineRe.toString()")
+shouldBe("inlineRe.toString()", "evalInlineRe.toString()")
+shouldBe("inlineRe.toString()", "newFromEvalInlineRe.toString()")
+shouldBe("inlineRe.toString()", "evalFromEvalInlineRe.toString()")
+shouldBe("inlineRe.toString()", "explicitRe.toString()")
+shouldBe("inlineRe.toString()", "newFromExplicitRe.toString()")
+shouldBe("inlineRe.toString()", "evalFromExplicitRe.toString()")
+
+shouldBe("inlineRe.exec(sample)[0]", "'bm\u2820p'")
+shouldBe("evalInlineRe.exec(sample)[0]", "'bm\u2820p'")
+shouldBe("explicitRe.exec(sample)[0]", "'bm\u2820p'")
+
+
+// Test handling of \u007c "|"
+var bsample="sample bm\u007cp cm\\u007cp";
+
+var binlineRe=/.m\u007cp/
+var bevalInlineRe=eval("/.m\\u007cp/")
+var bexplicitRe=new RegExp(".m\\u007cp")
+var bnewFromInlineRe=new RegExp(binlineRe.source)
+var bevalFromInlineRe=eval(binlineRe.toString())
+var bnewFromEvalInlineRe=new RegExp(bevalInlineRe.source)
+var bevalFromEvalInlineRe=eval(bevalInlineRe.toString())
+var bnewFromExplicitRe=new RegExp(bexplicitRe.source)
+var bevalFromExplicitRe=eval(bexplicitRe.toString())
+
+shouldBe("binlineRe.source", "bnewFromInlineRe.source")
+shouldBe("binlineRe.source", "bevalFromInlineRe.source")
+shouldBe("binlineRe.source", "bevalInlineRe.source")
+shouldBe("binlineRe.source", "bnewFromEvalInlineRe.source")
+shouldBe("binlineRe.source", "bevalFromEvalInlineRe.source")
+shouldBe("binlineRe.source", "bexplicitRe.source")
+shouldBe("binlineRe.source", "bnewFromExplicitRe.source")
+shouldBe("binlineRe.source", "bevalFromExplicitRe.source")
+
+shouldBe("binlineRe.toString()", "bnewFromInlineRe.toString()")
+shouldBe("binlineRe.toString()", "bevalFromInlineRe.toString()")
+shouldBe("binlineRe.toString()", "bevalInlineRe.toString()")
+shouldBe("binlineRe.toString()", "bnewFromEvalInlineRe.toString()")
+shouldBe("binlineRe.toString()", "bevalFromEvalInlineRe.toString()")
+shouldBe("binlineRe.toString()", "bexplicitRe.toString()")
+shouldBe("binlineRe.toString()", "bnewFromExplicitRe.toString()")
+shouldBe("binlineRe.toString()", "bevalFromExplicitRe.toString()")
+
+shouldBe("binlineRe.exec(bsample)[0]", "'bm|p'")
+shouldBe("bevalInlineRe.exec(bsample)[0]", "'bm|p'")
+shouldBe("bexplicitRe.exec(bsample)[0]", "'bm|p'")
+
+var successfullyParsed = true;