зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1263139 - Apply ToString to non-standard flags argument of String.prototype.{match,search,replace}. r=till
This commit is contained in:
Родитель
b2564f6046
Коммит
c1b2d5b90a
|
@ -44,7 +44,7 @@ function String_match(regexp) {
|
|||
var flags = undefined;
|
||||
if (arguments.length > 1) {
|
||||
if (IsMatchFlagsArgumentEnabled())
|
||||
flags = arguments[1];
|
||||
flags = ToString(arguments[1]);
|
||||
WarnOnceAboutFlagsArgument();
|
||||
} else {
|
||||
if (isPatternString && IsStringMatchOptimizable()) {
|
||||
|
@ -166,7 +166,7 @@ function String_replace(searchValue, replaceValue) {
|
|||
if (arguments.length > 2) {
|
||||
WarnOnceAboutFlagsArgument();
|
||||
if (IsMatchFlagsArgumentEnabled()) {
|
||||
flags = arguments[2];
|
||||
flags = ToString(arguments[2]);
|
||||
var rx = RegExpCreate(RegExpEscapeMetaChars(searchString), flags);
|
||||
|
||||
return callContentFunction(GetMethod(rx, std_replace), rx, string, replaceValue);
|
||||
|
@ -257,7 +257,7 @@ function String_search(regexp) {
|
|||
var flags = undefined;
|
||||
if (arguments.length > 1) {
|
||||
if (IsMatchFlagsArgumentEnabled())
|
||||
flags = arguments[1];
|
||||
flags = ToString(arguments[1]);
|
||||
WarnOnceAboutFlagsArgument();
|
||||
} else {
|
||||
if (isPatternString && IsStringSearchOptimizable()) {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
var BUGNUMBER = 1263139;
|
||||
var summary = "String.prototype.match with non-string non-standard flags argument.";
|
||||
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
enableMatchFlagArgument();
|
||||
|
||||
var called;
|
||||
var flags = {
|
||||
toString() {
|
||||
called = true;
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
called = false;
|
||||
"a".match("a", flags);
|
||||
assertEq(called, true);
|
||||
|
||||
called = false;
|
||||
"a".search("a", flags);
|
||||
assertEq(called, true);
|
||||
|
||||
called = false;
|
||||
"a".replace("a", "b", flags);
|
||||
assertEq(called, true);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
Загрузка…
Ссылка в новой задаче