Fix realm assignments.

This commit is contained in:
John-David Dalton
2016-01-02 11:39:19 -06:00
parent 849f8e77ec
commit b0e0a20e96

View File

@@ -467,31 +467,33 @@
lodashStable.attempt(function() { lodashStable.attempt(function() {
lodashStable.assign(realm, require('vm').runInNewContext([ lodashStable.assign(realm, require('vm').runInNewContext([
'(function() {', '(function() {',
' var root = this;', ' var noop = function() {},',
' root = this;',
'', '',
' var object = {', ' var object = {',
" 'arguments': (function() { return arguments; }(1, 2, 3)),", " 'arguments': (function() { return arguments; }(1, 2, 3)),",
" 'array': [1, 2, 3],", " 'array': [1, 2, 3],",
" 'arrayBuffer': new (this.ArrayByffer || Object),", " 'arrayBuffer': new (root.ArrayBuffer || noop),",
" 'boolean': Object(false),", " 'boolean': Object(false),",
" 'date': new Date,", " 'date': new Date,",
" 'errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],", " 'errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],",
" 'function': function() {},", " 'function': noop,",
" 'map': new (root.Map || Object),", " 'map': new (root.Map || noop),",
" 'nan': NaN,", " 'nan': NaN,",
" 'null': null,", " 'null': null,",
" 'number': Object(0),", " 'number': Object(0),",
" 'object': { 'a': 1, 'b': 2, 'c': 3 },", " 'object': { 'a': 1, 'b': 2, 'c': 3 },",
" 'regexp': /x/,", " 'regexp': /x/,",
" 'set': new (root.Set || Object),", " 'set': new (root.Set || noop),",
" 'string': Object('a'),", " 'string': Object('a'),",
" 'symbol': Object((root.Symbol || noop)()),",
" 'undefined': undefined", " 'undefined': undefined",
' };', ' };',
'', '',
" ['" + typedArrays.join("', '") + "'].forEach(function(type) {", " ['" + typedArrays.join("', '") + "'].forEach(function(type) {",
" var Ctor = root[type]", " var Ctor = root[type]",
' if (Ctor) {', ' if (Ctor) {',
" object['_' + type.toLowerCase()] = new Ctor(new ArrayBuffer(24));", " object[type.toLowerCase()] = new Ctor(new ArrayBuffer(24));",
' }', ' }',
" });", " });",
'', '',
@@ -511,33 +513,35 @@
var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc; var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc;
idoc.write([ idoc.write([
'<script>', '<script>',
'var _ = parent.lodashStable;', 'var _ = parent._;',
'', '',
'var root = this;', ' var noop = function() {},',
' root = this;',
'', '',
'var object = {', 'var object = {',
" 'arguments': (function() { return arguments; }(1, 2, 3)),", " 'arguments': (function() { return arguments; }(1, 2, 3)),",
" 'array': [1, 2, 3],", " 'array': [1, 2, 3],",
" 'arrayBuffer': new (this.ArrayByffer || Object),", " 'arrayBuffer': new (root.ArrayBuffer || noop),",
" 'boolean': Object(false),", " 'boolean': Object(false),",
" 'date': new Date,", " 'date': new Date,",
" 'errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],", " 'errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],",
" 'function': function() {},", " 'function': noop,",
" 'map': new (root.Map || Object),", " 'map': new (root.Map || noop),",
" 'nan': NaN,", " 'nan': NaN,",
" 'null': null,", " 'null': null,",
" 'number': Object(0),", " 'number': Object(0),",
" 'object': { 'a': 1, 'b': 2, 'c': 3 },", " 'object': { 'a': 1, 'b': 2, 'c': 3 },",
" 'regexp': /x/,", " 'regexp': /x/,",
" 'set': new (root.Set || Object),", " 'set': new (root.Set || noop),",
" 'string': Object('a'),", " 'string': Object('a'),",
" 'symbol': Object((root.Symbol || noop)()),",
" 'undefined': undefined", " 'undefined': undefined",
'};', '};',
'', '',
"_.each(['" + typedArrays.join("', '") + "'], function(type) {", "_.each(['" + typedArrays.join("', '") + "'], function(type) {",
' var Ctor = root[type];', ' var Ctor = root[type];',
' if (Ctor) {', ' if (Ctor) {',
" object['_' + type.toLowerCase()] = new Ctor(new ArrayBuffer(24));", " object[type.toLowerCase()] = new Ctor(new ArrayBuffer(24));",
' }', ' }',
'});', '});',
'', '',