Bug 1079919 - Part 4: Add Xray test for RegExp.prototype.toString. r=bholley

This commit is contained in:
Tooru Fujisawa 2015-03-18 18:22:05 +09:00
parent 51e5e0e8dd
commit 08010485eb

View File

@ -589,14 +589,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
function testRegExp() {
testXray('RegExp', new iwin.RegExp('foo'), new iwin.RegExp());
// Test the self-hosted |flags| property.
// Test the self-hosted |flags| property, toString, and toSource.
for (var flags of ["", "g", "i", "m", "y", "gimy"]) {
var re = new iwin.RegExp("foo", flags);
is(re.flags, re.wrappedJSObject.flags, "Results match");
isnot(re.toString, Cu.unwaiveXrays(re.wrappedJSObject.toString), "Different function identities");
is(Cu.getGlobalForObject(re.toString), window, "Xray global is correct");
is(Cu.getGlobalForObject(re.wrappedJSObject.toString), iwin, "Underlying global is correct");
is(re.toString(), re.wrappedJSObject.toString(), "Results match");
isnot(re.toSource, Cu.unwaiveXrays(re.wrappedJSObject.toSource), "Different function identities");
is(Cu.getGlobalForObject(re.toSource), window, "Xray global is correct");
is(Cu.getGlobalForObject(re.wrappedJSObject.toSource), iwin, "Underlying global is correct");
is(re.toSource(), re.wrappedJSObject.toSource(), "Results match");
// Test with modified flags accessors
iwin.eval(`
var props = ["global", "ignoreCase", "multiline", "sticky"];
var props = ["global", "ignoreCase", "multiline", "sticky", "source"];
var origDescs = {};
for (var prop of props) {
origDescs[prop] = Object.getOwnPropertyDescriptor(RegExp.prototype, prop);
@ -609,6 +619,8 @@ for (var prop of props) {
`);
try {
is(re.flags, flags, "Unmodified flags accessors are called");
is(re.toString(), "/foo/" + flags, "Unmodified flags and source accessors are called");
is(re.toSource(), "/foo/" + flags, "Unmodified flags and source accessors are called");
} finally {
iwin.eval(`
for (var prop of props) {