Replace Annex-B __proto__ with Object.[gs]etPrototypeOf

This commit is contained in:
André Bargull 2018-01-17 10:39:16 -08:00 committed by Rick Waldron
parent f3911d7ae4
commit 8b50602099
4 changed files with 6 additions and 6 deletions

View File

@ -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;

View File

@ -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>"));

View File

@ -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);

View File

@ -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]);