mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 677820 - String.prototype.match should define properties for matches on the returned array, not set them. r=pbiggar
--HG-- extra : rebase_source : 9001b1f918f403c50fa4bba57f54cbb22e887a70
This commit is contained in:
parent
2485241198
commit
90876d8d1e
@ -1535,11 +1535,8 @@ MatchCallback(JSContext *cx, RegExpStatics *res, size_t count, void *p)
|
||||
}
|
||||
|
||||
Value v;
|
||||
if (!res->createLastMatch(cx, &v))
|
||||
return false;
|
||||
|
||||
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_ASSIGNING);
|
||||
return !!arrayobj->setProperty(cx, INT_TO_JSID(count), &v, false);
|
||||
return res->createLastMatch(cx, &v) &&
|
||||
arrayobj->defineProperty(cx, INT_TO_JSID(count), v);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -3,6 +3,7 @@ script 15.5.4.2.js
|
||||
script 15.5.4.7.js
|
||||
script 15.5.4.11-01.js
|
||||
script defaultvalue.js
|
||||
script match-defines-match-elements.js
|
||||
script split-01.js
|
||||
script split-undefined-separator.js
|
||||
script split-xregexp.js
|
||||
|
47
js/src/tests/ecma_5/String/match-defines-match-elements.js
Normal file
47
js/src/tests/ecma_5/String/match-defines-match-elements.js
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
*/
|
||||
|
||||
var BUGNUMBER = 677820;
|
||||
var summary =
|
||||
"String.prototype.match must define matches on the returned array, not set " +
|
||||
"them";
|
||||
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
/**************
|
||||
* BEGIN TEST *
|
||||
**************/
|
||||
|
||||
var called = false;
|
||||
function setterFunction(v) { called = true; }
|
||||
function getterFunction(v) { return "getter"; }
|
||||
|
||||
Object.defineProperty(Array.prototype, 1,
|
||||
{ get: getterFunction, set: setterFunction });
|
||||
|
||||
assertEq(called, false);
|
||||
var matches = "abcdef".match(/./g);
|
||||
assertEq(called, false);
|
||||
assertEq(matches.length, 6);
|
||||
assertEq(matches[0], "a");
|
||||
assertEq(matches[1], "b");
|
||||
assertEq(matches[2], "c");
|
||||
assertEq(matches[3], "d");
|
||||
assertEq(matches[4], "e");
|
||||
assertEq(matches[5], "f");
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(Array.prototype, 1);
|
||||
assertEq(desc.get, getterFunction);
|
||||
assertEq(desc.set, setterFunction);
|
||||
assertEq(desc.enumerable, false);
|
||||
assertEq(desc.configurable, false);
|
||||
assertEq([][1], "getter");
|
||||
|
||||
assertEq(called, false);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
|
||||
print("Tests complete");
|
Loading…
Reference in New Issue
Block a user