[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 00:59:37 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 6c304a5d7ce18d3a4a16ec4a28ed09412fea058f
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jan 11 04:55:26 2010 +0000

    2010-01-10  Kent Hansen  <kent.hansen at nokia.com>
    
            Reviewed by Darin Adler.
    
            RegExp.prototype.toString returns "//" for empty regular expressions
            https://bugs.webkit.org/show_bug.cgi?id=33319
    
            "//" starts a single-line comment, hence "/(?:)/" should be used, according to ECMA.
    
            * runtime/RegExpPrototype.cpp:
            (JSC::regExpProtoFuncToString):
    
            * tests/mozilla/ecma_2/RegExp/properties-001.js:
            (AddRegExpCases):
            * tests/mozilla/js1_2/regexp/toString.js:
            Update relevant Mozilla tests (Mozilla has had this behavior since November 2003).
    2010-01-10  Kent Hansen  <kent.hansen at nokia.com>
    
            Reviewed by Darin Adler.
    
            RegExp.prototype.toString returns "//" for empty regular expressions
            https://bugs.webkit.org/show_bug.cgi?id=33319
    
            Add new test cases and adapt existing ones.
    
            * fast/js/kde/RegExp-expected.txt:
            * fast/js/kde/script-tests/RegExp.js:
            * fast/js/regexp-compile-expected.txt:
            * fast/js/script-tests/regexp-compile.js:
            * fast/regex/non-pattern-characters-expected.txt:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53062 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 81728fc..c6af109 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,20 @@
+2010-01-10  Kent Hansen  <kent.hansen at nokia.com>
+
+        Reviewed by Darin Adler.
+
+        RegExp.prototype.toString returns "//" for empty regular expressions
+        https://bugs.webkit.org/show_bug.cgi?id=33319
+
+        "//" starts a single-line comment, hence "/(?:)/" should be used, according to ECMA.
+
+        * runtime/RegExpPrototype.cpp:
+        (JSC::regExpProtoFuncToString):
+
+        * tests/mozilla/ecma_2/RegExp/properties-001.js:
+        (AddRegExpCases):
+        * tests/mozilla/js1_2/regexp/toString.js:
+        Update relevant Mozilla tests (Mozilla has had this behavior since November 2003).
+
 2010-01-10  Darin Adler  <darin at apple.com>
 
         * tests/mozilla/ecma/Array/15.4.1.1.js: Added property allow-tabs.
diff --git a/JavaScriptCore/runtime/RegExpPrototype.cpp b/JavaScriptCore/runtime/RegExpPrototype.cpp
index c3ee565..5f9d357 100644
--- a/JavaScriptCore/runtime/RegExpPrototype.cpp
+++ b/JavaScriptCore/runtime/RegExpPrototype.cpp
@@ -114,8 +114,9 @@ JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec, JSObject*, JSValu
         postfix[index++] = 'i';
     if (asRegExpObject(thisValue)->get(exec, exec->propertyNames().multiline).toBoolean(exec))
         postfix[index] = 'm';
-    
-    return jsNontrivialString(exec, makeString("/", asRegExpObject(thisValue)->get(exec, exec->propertyNames().source).toString(exec), postfix));
+    UString source = asRegExpObject(thisValue)->get(exec, exec->propertyNames().source).toString(exec);
+    // If source is empty, use "/(?:)/" to avoid colliding with comment syntax
+    return jsNontrivialString(exec, makeString("/", source.size() ? source : UString("(?:)"), postfix));
 }
 
 } // namespace JSC
diff --git a/JavaScriptCore/tests/mozilla/ecma_2/RegExp/properties-001.js b/JavaScriptCore/tests/mozilla/ecma_2/RegExp/properties-001.js
index 16f265c..3eb51cb 100644
--- a/JavaScriptCore/tests/mozilla/ecma_2/RegExp/properties-001.js
+++ b/JavaScriptCore/tests/mozilla/ecma_2/RegExp/properties-001.js
@@ -56,8 +56,15 @@ function AddRegExpCases( re, s, g, i, m, l ) {
                  s,
                  re.source );
 
+/*
+ * http://bugzilla.mozilla.org/show_bug.cgi?id=225550 changed
+ * the behavior of toString() and toSource() on empty regexps.
+ * So branch if |s| is the empty string -
+ */
+    var S = s? s : '(?:)';
+
     AddTestCase( re + ".toString()",
-                 "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""),
+                 "/" + S +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""),
                  re.toString() );
 
     AddTestCase( re + ".global",
diff --git a/JavaScriptCore/tests/mozilla/js1_2/regexp/toString.js b/JavaScriptCore/tests/mozilla/js1_2/regexp/toString.js
index 554b934..b08b772 100644
--- a/JavaScriptCore/tests/mozilla/js1_2/regexp/toString.js
+++ b/JavaScriptCore/tests/mozilla/js1_2/regexp/toString.js
@@ -41,7 +41,7 @@
     // var re = new RegExp(); re.toString()
 	var re = new RegExp();
 	testcases[count++] = new TestCase ( SECTION, "var re = new RegExp(); re.toString()",
-	                                    '//', re.toString());
+	                                    '/(?:)/', re.toString());
 
     // re = /.+/; re.toString();
     re = /.+/;
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index c6a0c5c..2a57746 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2010-01-10  Kent Hansen  <kent.hansen at nokia.com>
+
+        Reviewed by Darin Adler.
+
+        RegExp.prototype.toString returns "//" for empty regular expressions
+        https://bugs.webkit.org/show_bug.cgi?id=33319
+
+        Add new test cases and adapt existing ones.
+
+        * fast/js/kde/RegExp-expected.txt:
+        * fast/js/kde/script-tests/RegExp.js:
+        * fast/js/regexp-compile-expected.txt:
+        * fast/js/script-tests/regexp-compile.js:
+        * fast/regex/non-pattern-characters-expected.txt:
+
 2010-01-10  Robert Hogan  <robert at roberthogan.net>
 
         Reviewed by Adam Barth.
diff --git a/LayoutTests/fast/js/kde/RegExp-expected.txt b/LayoutTests/fast/js/kde/RegExp-expected.txt
index 52dbba1..6151bbf 100644
--- a/LayoutTests/fast/js/kde/RegExp-expected.txt
+++ b/LayoutTests/fast/js/kde/RegExp-expected.txt
@@ -92,6 +92,10 @@ PASS /\u0061/.source is '\\u0061'
 PASS 'abc'.match(/\u0062/).toString() is 'b'
 FAIL Object.prototype.toString.apply(RegExp.prototype) should be [object RegExp]. Was [object RegExpPrototype].
 PASS typeof RegExp.prototype.toString() is 'string'
+PASS new RegExp().toString() is '/(?:)/'
+PASS (new RegExp('(?:)')).source is '(?:)'
+PASS /(?:)/.toString() is '/(?:)/'
+PASS /(?:)/.source is '(?:)'
 Done.
 PASS successfullyParsed is true
 
diff --git a/LayoutTests/fast/js/kde/script-tests/RegExp.js b/LayoutTests/fast/js/kde/script-tests/RegExp.js
index cb7a142..fbab840 100644
--- a/LayoutTests/fast/js/kde/script-tests/RegExp.js
+++ b/LayoutTests/fast/js/kde/script-tests/RegExp.js
@@ -148,5 +148,11 @@ shouldBe("Object.prototype.toString.apply(RegExp.prototype)",
 // it doesn't throw an exception
 shouldBe("typeof RegExp.prototype.toString()", "'string'");
 
+// Empty regular expressions have string representation /(?:)/
+shouldBe("new RegExp().toString()", "'/(?:)/'");
+shouldBe("(new RegExp('(?:)')).source", "'(?:)'");
+shouldBe("/(?:)/.toString()", "'/(?:)/'");
+shouldBe("/(?:)/.source", "'(?:)'");
+
 debug("Done.");
 successfullyParsed = true
diff --git a/LayoutTests/fast/js/regexp-compile-expected.txt b/LayoutTests/fast/js/regexp-compile-expected.txt
index 854d50a..a6bee52 100644
--- a/LayoutTests/fast/js/regexp-compile-expected.txt
+++ b/LayoutTests/fast/js/regexp-compile-expected.txt
@@ -19,7 +19,7 @@ PASS re.toString() is '/c/i'
 PASS re.compile(new RegExp('+')); threw exception SyntaxError: Invalid regular expression: nothing to repeat.
 PASS re.toString() is '/undefined/'
 PASS re.toString() is '/null/'
-PASS re.toString() is '//'
+PASS re.toString() is '/(?:)/'
 PASS re.toString() is '/z/'
 PASS re.lastIndex is 0
 PASS re.lastIndex is 1
diff --git a/LayoutTests/fast/js/script-tests/regexp-compile.js b/LayoutTests/fast/js/script-tests/regexp-compile.js
index eae5787..5a21300 100644
--- a/LayoutTests/fast/js/script-tests/regexp-compile.js
+++ b/LayoutTests/fast/js/script-tests/regexp-compile.js
@@ -38,7 +38,7 @@ re.compile(null);
 shouldBe("re.toString()", "'/null/'");
 
 re.compile();
-shouldBe("re.toString()", "'//'"); // /(?:)/ in Firefox
+shouldBe("re.toString()", "'/(?:)/'");
 
 re.compile("z", undefined);
 shouldBe("re.toString()", "'/z/'");
diff --git a/LayoutTests/fast/regex/non-pattern-characters-expected.txt b/LayoutTests/fast/regex/non-pattern-characters-expected.txt
index c6c7bcb..de39fed 100644
--- a/LayoutTests/fast/regex/non-pattern-characters-expected.txt
+++ b/LayoutTests/fast/regex/non-pattern-characters-expected.txt
@@ -156,7 +156,7 @@ Testing regexp: /a}/gm
 PASS regexp.test('a}') is true
 PASS regexp.lastIndex is 2
 
-Testing regexp: //gm
+Testing regexp: /(?:)/gm
 PASS regexp.test('') is true
 PASS regexp.lastIndex is 0
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list