diff --git a/test/test.js b/test/test.js index 28a646d0b..0b3cc3a80 100644 --- a/test/test.js +++ b/test/test.js @@ -54,6 +54,7 @@ objToString = objectProto.toString, params = root.arguments, push = arrayProto.push, + realm = {}, Set = root.Set, slice = arrayProto.slice, Symbol = root.Symbol, @@ -447,27 +448,27 @@ // Add other realm values from the `vm` module. _.attempt(function() { - _.extend(_, require('vm').runInNewContext([ + _.extend(realm, require('vm').runInNewContext([ '(function() {', ' var root = this;', '', ' var object = {', - " '_arguments': (function() { return arguments; }(1, 2, 3)),", - " '_array': [1, 2, 3],", - " '_arrayBuffer': new (this.ArrayByffer || Object),", - " '_boolean': Object(false),", - " '_date': new Date,", - " '_errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],", - " '_function': function() {},", - " '_map': new (root.Map || Object),", - " '_nan': NaN,", - " '_null': null,", - " '_number': Object(0),", - " '_object': { 'a': 1, 'b': 2, 'c': 3 },", - " '_regexp': /x/,", - " '_set': new (root.Set || Object),", - " '_string': Object('a'),", - " '_undefined': undefined", + " 'arguments': (function() { return arguments; }(1, 2, 3)),", + " 'array': [1, 2, 3],", + " 'arrayBuffer': new (this.ArrayByffer || Object),", + " 'boolean': Object(false),", + " 'date': new Date,", + " 'errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],", + " 'function': function() {},", + " 'map': new (root.Map || Object),", + " 'nan': NaN,", + " 'null': null,", + " 'number': Object(0),", + " 'object': { 'a': 1, 'b': 2, 'c': 3 },", + " 'regexp': /x/,", + " 'set': new (root.Set || Object),", + " 'string': Object('a'),", + " 'undefined': undefined", ' };', '', " ['" + typedArrays.join("', '") + "'].forEach(function(type) {", @@ -484,6 +485,8 @@ // Add other realm values from an iframe. _.attempt(function() { + _._realm = realm; + var iframe = document.createElement('iframe'); iframe.frameBorder = iframe.height = iframe.width = 0; body.appendChild(iframe); @@ -491,35 +494,42 @@ var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc; idoc.write([ '