Title: [167951] trunk
Revision
167951
Author
gga...@apple.com
Date
2014-04-29 12:47:25 -0700 (Tue, 29 Apr 2014)

Log Message

String.prototype.trim removes U+200B from strings.
https://bugs.webkit.org/show_bug.cgi?id=130184

Reviewed by Michael Saboff.


Source/_javascript_Core: 
* runtime/StringPrototype.cpp:
(JSC::trimString):
(JSC::isTrimWhitespace): Deleted.

LayoutTests: 
* js/script-tests/string-trim.js:
* js/string-trim-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (167950 => 167951)


--- trunk/LayoutTests/ChangeLog	2014-04-29 19:23:08 UTC (rev 167950)
+++ trunk/LayoutTests/ChangeLog	2014-04-29 19:47:25 UTC (rev 167951)
@@ -1,3 +1,13 @@
+2014-04-29  Geoffrey Garen  <gga...@apple.com>
+
+        String.prototype.trim removes U+200B from strings.
+        https://bugs.webkit.org/show_bug.cgi?id=130184
+
+        Reviewed by Michael Saboff.
+
+        * js/script-tests/string-trim.js:
+        * js/string-trim-expected.txt:
+
 2014-04-29  Alexey Proskuryakov  <a...@apple.com>
 
         REGRESSION: Intermittent crash in SpeechSynthesis::didFinishSpeaking

Modified: trunk/LayoutTests/js/script-tests/string-trim.js (167950 => 167951)


--- trunk/LayoutTests/js/script-tests/string-trim.js	2014-04-29 19:23:08 UTC (rev 167950)
+++ trunk/LayoutTests/js/script-tests/string-trim.js	2014-04-29 19:47:25 UTC (rev 167951)
@@ -33,7 +33,6 @@
     {s : '\u3000', t : 'IDEOGRAPHIC SPACE'},
     {s : '\u2028', t : 'LINE SEPARATOR'},
     {s : '\u2029', t : 'PARAGRAPH SEPARATOR'},
-    {s : '\u200B', t : 'ZERO WIDTH SPACE (category Cf)'}
 ];
 
 for (var i = 0; i < whitespace.length; i++) {
@@ -63,10 +62,9 @@
 shouldBe("rightTrimString.trimLeft()",  "testString");
 shouldBe("rightTrimString.trimRight()", "rightTrimString");
 
-var testValues = ["0", "Infinity", "NaN", "true", "false", "({})", "({toString:function(){return 'wibble'}})", "['an','array']"];
+var testValues = ["0", "Infinity", "NaN", "true", "false", "({})", "({toString:function(){return 'wibble'}})", "['an','array']", "'\u200b'"];
 for (var i = 0; i < testValues.length; i++) {
     shouldBe("trim.call("+testValues[i]+")", "'"+eval(testValues[i])+"'");
     shouldBe("trimLeft.call("+testValues[i]+")", "'"+eval(testValues[i])+"'");
     shouldBe("trimRight.call("+testValues[i]+")", "'"+eval(testValues[i])+"'");
 }
-

Modified: trunk/LayoutTests/js/string-trim-expected.txt (167950 => 167951)


--- trunk/LayoutTests/js/string-trim-expected.txt	2014-04-29 19:23:08 UTC (rev 167950)
+++ trunk/LayoutTests/js/string-trim-expected.txt	2014-04-29 19:47:25 UTC (rev 167951)
@@ -66,9 +66,6 @@
 PASS whitespace[20].s.trim() is ''
 PASS whitespace[20].s.trimLeft() is ''
 PASS whitespace[20].s.trimRight() is ''
-PASS whitespace[21].s.trim() is ''
-PASS whitespace[21].s.trimLeft() is ''
-PASS whitespace[21].s.trimRight() is ''
 PASS wsString.trim() is ''
 PASS wsString.trimLeft() is ''
 PASS wsString.trimRight() is ''
@@ -105,6 +102,9 @@
 PASS trim.call(['an','array']) is 'an,array'
 PASS trimLeft.call(['an','array']) is 'an,array'
 PASS trimRight.call(['an','array']) is 'an,array'
+PASS trim.call('​') is '​'
+PASS trimLeft.call('​') is '​'
+PASS trimRight.call('​') is '​'
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/Source/_javascript_Core/ChangeLog (167950 => 167951)


--- trunk/Source/_javascript_Core/ChangeLog	2014-04-29 19:23:08 UTC (rev 167950)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-04-29 19:47:25 UTC (rev 167951)
@@ -1,3 +1,14 @@
+2014-04-29  Geoffrey Garen  <gga...@apple.com>
+
+        String.prototype.trim removes U+200B from strings.
+        https://bugs.webkit.org/show_bug.cgi?id=130184
+
+        Reviewed by Michael Saboff.
+
+        * runtime/StringPrototype.cpp:
+        (JSC::trimString):
+        (JSC::isTrimWhitespace): Deleted.
+
 2014-04-29  Mark Lam  <mark....@apple.com>
 
         Zombifying sweep should ignore retired blocks.

Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (167950 => 167951)


--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2014-04-29 19:23:08 UTC (rev 167950)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2014-04-29 19:47:25 UTC (rev 167951)
@@ -1505,11 +1505,6 @@
     TrimRight = 2
 };
 
-static inline bool isTrimWhitespace(UChar c)
-{
-    return isStrWhiteSpace(c) || c == 0x200b;
-}
-
 static inline JSValue trimString(ExecState* exec, JSValue thisValue, int trimKind)
 {
     if (!checkObjectCoercible(thisValue))
@@ -1517,12 +1512,12 @@
     String str = thisValue.toString(exec)->value(exec);
     unsigned left = 0;
     if (trimKind & TrimLeft) {
-        while (left < str.length() && isTrimWhitespace(str[left]))
+        while (left < str.length() && isStrWhiteSpace(str[left]))
             left++;
     }
     unsigned right = str.length();
     if (trimKind & TrimRight) {
-        while (right > left && isTrimWhitespace(str[right - 1]))
+        while (right > left && isStrWhiteSpace(str[right - 1]))
             right--;
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to