mirror of
https://github.com/tc39/test262.git
synced 2025-07-28 16:34:27 +02:00
Replace Annex-B __proto__ with Object.[gs]etPrototypeOf
This commit is contained in:
parent
f3911d7ae4
commit
8b50602099
@ -27,11 +27,11 @@ class FakeRegExp extends RegExp {
|
|||||||
|
|
||||||
const re = new FakeRegExp();
|
const re = new FakeRegExp();
|
||||||
const result = re.exec("ab");
|
const result = re.exec("ab");
|
||||||
assert.sameValue(result.__proto__, Array.prototype);
|
assert.sameValue(Object.getPrototypeOf(result), Array.prototype);
|
||||||
assert.sameValue(false, result.hasOwnProperty("groups"));
|
assert.sameValue(false, result.hasOwnProperty("groups"));
|
||||||
|
|
||||||
Array.prototype.groups = { a: "b" };
|
Array.prototype.groups = { a: "b" };
|
||||||
Array.prototype.groups.__proto__.b = "c";
|
Object.getPrototypeOf(Array.prototype.groups).b = "c";
|
||||||
assert.sameValue("b", "ab".replace(re, "$<a>"));
|
assert.sameValue("b", "ab".replace(re, "$<a>"));
|
||||||
assert.sameValue("c", "ab".replace(re, "$<b>"));
|
assert.sameValue("c", "ab".replace(re, "$<b>"));
|
||||||
Array.prototype.groups = undefined;
|
Array.prototype.groups = undefined;
|
||||||
|
@ -21,14 +21,14 @@ class FakeRegExp extends RegExp {
|
|||||||
const fakeResult = ["ab", "a"];
|
const fakeResult = ["ab", "a"];
|
||||||
fakeResult.index = 0;
|
fakeResult.index = 0;
|
||||||
fakeResult.groups = { a: "b" };
|
fakeResult.groups = { a: "b" };
|
||||||
fakeResult.groups.__proto__.b = "c";
|
Object.getPrototypeOf(fakeResult.groups).b = "c";
|
||||||
return fakeResult;
|
return fakeResult;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const re = new FakeRegExp();
|
const re = new FakeRegExp();
|
||||||
const result = re.exec("ab");
|
const result = re.exec("ab");
|
||||||
assert.sameValue(result.__proto__, Array.prototype);
|
assert.sameValue(Object.getPrototypeOf(result), Array.prototype);
|
||||||
assert(result.hasOwnProperty("groups"));
|
assert(result.hasOwnProperty("groups"));
|
||||||
assert.sameValue("b", result.groups.a);
|
assert.sameValue("b", result.groups.a);
|
||||||
assert.sameValue("b", "ab".replace(re, "$<a>"));
|
assert.sameValue("b", "ab".replace(re, "$<a>"));
|
||||||
|
@ -17,7 +17,7 @@ info: |
|
|||||||
|
|
||||||
const re = /./;
|
const re = /./;
|
||||||
const result = re.exec("a");
|
const result = re.exec("a");
|
||||||
assert.sameValue(result.__proto__, Array.prototype);
|
assert.sameValue(Object.getPrototypeOf(result), Array.prototype);
|
||||||
assert(result.hasOwnProperty("groups"));
|
assert(result.hasOwnProperty("groups"));
|
||||||
assert.sameValue("a", result[0]);
|
assert.sameValue("a", result[0]);
|
||||||
assert.sameValue(0, result.index);
|
assert.sameValue(0, result.index);
|
||||||
|
@ -18,7 +18,7 @@ info: |
|
|||||||
|
|
||||||
const re = /(?<a>a).|(?<x>x)/;
|
const re = /(?<a>a).|(?<x>x)/;
|
||||||
const result = re.exec("ab");
|
const result = re.exec("ab");
|
||||||
assert.sameValue(result.__proto__, Array.prototype);
|
assert.sameValue(Object.getPrototypeOf(result), Array.prototype);
|
||||||
assert(result.hasOwnProperty("groups"));
|
assert(result.hasOwnProperty("groups"));
|
||||||
assert.sameValue("ab", result[0]);
|
assert.sameValue("ab", result[0]);
|
||||||
assert.sameValue("a", result[1]);
|
assert.sameValue("a", result[1]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user