Diff
Modified: trunk/LayoutTests/ChangeLog (109274 => 109275)
--- trunk/LayoutTests/ChangeLog 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/ChangeLog 2012-02-29 23:23:58 UTC (rev 109275)
@@ -1,3 +1,31 @@
+2012-02-29 Gavin Barraclough <[email protected]>
+
+ 'source' property of RegExp instance cannot be ""
+ https://bugs.webkit.org/show_bug.cgi?id=79938
+
+ Reviewed by Oliver Hunt.
+
+ 15.10.6.4 specifies that RegExp.prototype.toString must return '/' + source + '/',
+ and also states that the result must be a valid RegularExpressionLiteral. '//' is
+ not a valid RegularExpressionLiteral (since it is a single line comment), and hence
+ source cannot ever validly be "". If the source is empty, return a different Pattern
+ that would match the same thing.
+
+ * fast/js/kde/RegExp-expected.txt:
+ * fast/js/kde/script-tests/RegExp.js:
+ * fast/regex/script-tests/toString.js:
+ * fast/regex/toString-expected.txt:
+ - Update these tests to check for the correct result.
+ * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T1-expected.txt:
+ * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T2-expected.txt:
+ * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T3-expected.txt:
+ * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T4-expected.txt:
+ * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T5-expected.txt:
+ * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T2-expected.txt:
+ * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T3-expected.txt:
+ * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T5-expected.txt:
+ - Check in failing results, these tests are all incorrect.
+
2012-02-29 Joshua Bell <[email protected]>
IndexedDB: Resource leak with IDBObjectStore.openCursor
Modified: trunk/LayoutTests/fast/js/kde/RegExp-expected.txt (109274 => 109275)
--- trunk/LayoutTests/fast/js/kde/RegExp-expected.txt 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/fast/js/kde/RegExp-expected.txt 2012-02-29 23:23:58 UTC (rev 109275)
@@ -3,7 +3,7 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS (new RegExp()).source is ''
+PASS (new RegExp()).source is '(?:)'
PASS Boolean(new RegExp()) is true
PASS isNaN(Number(new RegExp())) is true
PASS RegExp(/x/).source is 'x'
Modified: trunk/LayoutTests/fast/js/kde/script-tests/RegExp.js (109274 => 109275)
--- trunk/LayoutTests/fast/js/kde/script-tests/RegExp.js 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/fast/js/kde/script-tests/RegExp.js 2012-02-29 23:23:58 UTC (rev 109275)
@@ -1,4 +1,4 @@
-shouldBe("(new RegExp()).source", "''");
+shouldBe("(new RegExp()).source", "'(?:)'");
shouldBe("Boolean(new RegExp())", "true");
shouldBeTrue("isNaN(Number(new RegExp()))");
Modified: trunk/LayoutTests/fast/regex/script-tests/toString.js (109274 => 109275)
--- trunk/LayoutTests/fast/regex/script-tests/toString.js 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/fast/regex/script-tests/toString.js 2012-02-29 23:23:58 UTC (rev 109275)
@@ -18,8 +18,8 @@
}
shouldBe("RegExp('/').source", '"\\\\/"');
-shouldBe("RegExp('').source", '""');
-shouldBe("RegExp.prototype.source", '""');
+shouldBe("RegExp('').source", '"(?:)"');
+shouldBe("RegExp.prototype.source", '"(?:)"');
shouldBe("RegExp('/').toString()", '"/\\\\//"');
shouldBe("RegExp('').toString()", '"/(?:)/"');
@@ -53,3 +53,12 @@
shouldBe("RegExp('[/]').source", "'[/]'");
shouldBe("RegExp('\\\\[/]').source", "'\\\\[\\\\/]'");
+
+// See 15.10.6.4
+// The first half of this checks that:
+// Return the String value formed by concatenating the Strings "/", the
+// String value of the source property of this RegExp object, and "/";
+// The second half checks that:
+// The returned String has the form of a RegularExpressionLiteral that
+// evaluates to another RegExp object with the same behaviour as this object.
+shouldBe("var o = new RegExp(); o.toString() === '/'+o.source+'/' && eval(o.toString()+'.exec(String())')", '[""]');
Modified: trunk/LayoutTests/fast/regex/toString-expected.txt (109274 => 109275)
--- trunk/LayoutTests/fast/regex/toString-expected.txt 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/fast/regex/toString-expected.txt 2012-02-29 23:23:58 UTC (rev 109275)
@@ -4,8 +4,8 @@
PASS RegExp('/').source is "\\/"
-PASS RegExp('').source is ""
-PASS RegExp.prototype.source is ""
+PASS RegExp('').source is "(?:)"
+PASS RegExp.prototype.source is "(?:)"
PASS RegExp('/').toString() is "/\\//"
PASS RegExp('').toString() is "/(?:)/"
PASS RegExp.prototype.toString() is "/(?:)/"
@@ -30,6 +30,7 @@
PASS testLineTerminator("\\u2029"); is false
PASS RegExp('[/]').source is '[/]'
PASS RegExp('\\[/]').source is '\\[\\/]'
+PASS var o = new RegExp(); o.toString() === '/'+o.source+'/' && eval(o.toString()+'.exec(String())') is [""]
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T1-expected.txt (109274 => 109275)
--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T1-expected.txt 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T1-expected.txt 2012-02-29 23:23:58 UTC (rev 109275)
@@ -1,6 +1,6 @@
S15.10.4.1_A3_T1
-PASS
+FAIL SputnikError: #1: __re = new RegExp; __re.source === "". Actual: (?:)
TEST COMPLETE
Modified: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T2-expected.txt (109274 => 109275)
--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T2-expected.txt 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T2-expected.txt 2012-02-29 23:23:58 UTC (rev 109275)
@@ -1,6 +1,6 @@
S15.10.4.1_A3_T2
-PASS
+FAIL SputnikError: #1: __re = new RegExp(void 0); __re.source === "". Actual: (?:)
TEST COMPLETE
Modified: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T3-expected.txt (109274 => 109275)
--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T3-expected.txt 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T3-expected.txt 2012-02-29 23:23:58 UTC (rev 109275)
@@ -1,6 +1,6 @@
S15.10.4.1_A3_T3
-PASS
+FAIL SputnikError: #1: __re = new RegExp(x); var x; __re.source === "". Actual: (?:)
TEST COMPLETE
Modified: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T4-expected.txt (109274 => 109275)
--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T4-expected.txt 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T4-expected.txt 2012-02-29 23:23:58 UTC (rev 109275)
@@ -1,6 +1,6 @@
S15.10.4.1_A3_T4
-PASS
+FAIL SputnikError: #1: __re = new RegExp(undefined); __re.source === "". Actual: (?:)
TEST COMPLETE
Modified: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T5-expected.txt (109274 => 109275)
--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T5-expected.txt 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T5-expected.txt 2012-02-29 23:23:58 UTC (rev 109275)
@@ -1,6 +1,6 @@
S15.10.4.1_A3_T5
-PASS
+FAIL SputnikError: #1: __re = new RegExp((function(){})()); __re.source === "". Actual: (?:)
TEST COMPLETE
Modified: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T2-expected.txt (109274 => 109275)
--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T2-expected.txt 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T2-expected.txt 2012-02-29 23:23:58 UTC (rev 109275)
@@ -1,6 +1,6 @@
S15.10.4.1_A4_T2
-PASS
+FAIL SputnikError: #1: __re = new RegExp(undefined, undefined); __re.source === "". Actual: (?:)
TEST COMPLETE
Modified: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T3-expected.txt (109274 => 109275)
--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T3-expected.txt 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T3-expected.txt 2012-02-29 23:23:58 UTC (rev 109275)
@@ -1,6 +1,6 @@
S15.10.4.1_A4_T3
-PASS
+FAIL SputnikError: #1: __re = new RegExp({}.p, {}.q); __re.source === "". Actual: (?:)
TEST COMPLETE
Modified: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T5-expected.txt (109274 => 109275)
--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T5-expected.txt 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T5-expected.txt 2012-02-29 23:23:58 UTC (rev 109275)
@@ -1,6 +1,6 @@
S15.10.4.1_A4_T5
-PASS
+FAIL SputnikError: #1: __re = new RegExp("", (function(){})()); __re.source === "". Actual: (?:)
TEST COMPLETE
Modified: trunk/Source/_javascript_Core/ChangeLog (109274 => 109275)
--- trunk/Source/_javascript_Core/ChangeLog 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-02-29 23:23:58 UTC (rev 109275)
@@ -22,6 +22,26 @@
2012-02-29 Gavin Barraclough <[email protected]>
+ 'source' property of RegExp instance cannot be ""
+ https://bugs.webkit.org/show_bug.cgi?id=79938
+
+ Reviewed by Oliver Hunt.
+
+ 15.10.6.4 specifies that RegExp.prototype.toString must return '/' + source + '/',
+ and also states that the result must be a valid RegularExpressionLiteral. '//' is
+ not a valid RegularExpressionLiteral (since it is a single line comment), and hence
+ source cannot ever validly be "". If the source is empty, return a different Pattern
+ that would match the same thing.
+
+ * runtime/RegExpObject.cpp:
+ (JSC::regExpObjectSource):
+ - Do not return "" if the source is empty, this would lead to invalid behaviour in toString.
+ * runtime/RegExpPrototype.cpp:
+ (JSC::regExpProtoFuncToString):
+ - No need to special case the empty string - this should be being done by 'source'.
+
+2012-02-29 Gavin Barraclough <[email protected]>
+
Writable attribute not set correctly when redefining an accessor to a data descriptor
https://bugs.webkit.org/show_bug.cgi?id=79931
Modified: trunk/Source/_javascript_Core/runtime/RegExpObject.cpp (109274 => 109275)
--- trunk/Source/_javascript_Core/runtime/RegExpObject.cpp 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/Source/_javascript_Core/runtime/RegExpObject.cpp 2012-02-29 23:23:58 UTC (rev 109275)
@@ -189,6 +189,14 @@
bool inBrackets = false;
bool shouldEscape = false;
+ // 15.10.6.4 specifies that RegExp.prototype.toString must return '/' + source + '/',
+ // and also states that the result must be a valid RegularExpressionLiteral. '//' is
+ // not a valid RegularExpressionLiteral (since it is a single line comment), and hence
+ // source cannot ever validly be "". If the source is empty, return a different Pattern
+ // that would match the same thing.
+ if (!length)
+ return jsString(exec, "(?:)");
+
// early return for strings that don't contain a forwards slash and LineTerminator
for (unsigned i = 0; i < length; ++i) {
UChar ch = characters[i];
Modified: trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp (109274 => 109275)
--- trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp 2012-02-29 23:10:26 UTC (rev 109274)
+++ trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp 2012-02-29 23:23:58 UTC (rev 109275)
@@ -155,7 +155,7 @@
postfix[index] = 'm';
UString source = thisObject->get(exec, exec->propertyNames().source).toString(exec)->value(exec);
// If source is empty, use "/(?:)/" to avoid colliding with comment syntax
- return JSValue::encode(jsMakeNontrivialString(exec, "/", source.length() ? source : UString("(?:)"), postfix));
+ return JSValue::encode(jsMakeNontrivialString(exec, "/", source, postfix));
}
} // namespace JSC