зеркало из https://github.com/mozilla/pjs.git
Fix String.prototype.indexOf with empty searchString; r=brendan a=blocking-beta9+
This commit is contained in:
Родитель
28f0c39d50
Коммит
2b6a1da658
|
@ -1465,7 +1465,7 @@ str_indexOf(JSContext *cx, uintN argc, Value *vp)
|
|||
if (i <= 0) {
|
||||
start = 0;
|
||||
} else if (jsuint(i) > textlen) {
|
||||
start = 0;
|
||||
start = textlen;
|
||||
textlen = 0;
|
||||
} else {
|
||||
start = i;
|
||||
|
@ -1480,7 +1480,7 @@ str_indexOf(JSContext *cx, uintN argc, Value *vp)
|
|||
if (d <= 0) {
|
||||
start = 0;
|
||||
} else if (d > textlen) {
|
||||
start = 0;
|
||||
start = textlen;
|
||||
textlen = 0;
|
||||
} else {
|
||||
start = (jsint)d;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
*/
|
||||
|
||||
var BUGNUMBER = 612838;
|
||||
var summary = "String.prototype.indexOf with empty searchString";
|
||||
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
assertEq("123".indexOf("", -1), 0);
|
||||
assertEq("123".indexOf("", 0), 0);
|
||||
assertEq("123".indexOf("", 1), 1);
|
||||
assertEq("123".indexOf("", 3), 3);
|
||||
assertEq("123".indexOf("", 4), 3);
|
||||
assertEq("123".indexOf("", 12345), 3);
|
||||
|
||||
reportCompare(true, true);
|
||||
|
||||
print("All tests passed!");
|
|
@ -1,3 +1,4 @@
|
|||
url-prefix ../../jsreftest.html?test=ecma_5/String/
|
||||
script 15.5.4.2.js
|
||||
script 15.5.4.7.js
|
||||
script 15.5.4.11-01.js
|
||||
|
|
Загрузка…
Ссылка в новой задаче