From e7ffb808775861d16fadb886623e1dfca3c3ade4 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 14 Nov 2013 08:30:34 -0800 Subject: [PATCH] Enable other realm tests for Node too. --- test/test.js | 111 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 44 deletions(-) diff --git a/test/test.js b/test/test.js index b0fe13cf6..2a7dc3dca 100644 --- a/test/test.js +++ b/test/test.js @@ -183,34 +183,52 @@ /*--------------------------------------------------------------------------*/ - // add object from iframe + // add values from other realms (function() { - if (!document) { - return; - } - var iframe = document.createElement('iframe'); - iframe.frameBorder = iframe.height = iframe.width = 0; - body.appendChild(iframe); + try { + _.extend(_, require('vm').runInNewContext([ + '({', + "'_arguments': (function() { return arguments; }(1, 2, 3)),", + "'_array': [1, 2, 3],", + "'_boolean': new Boolean(false),", + "'_date': new Date,", + "'_function': function() {},", + "'_nan': NaN,", + "'_null': null,", + "'_number': new Number(0),", + "'_object': { 'a': 1, 'b': 2, 'c': 3 },", + "'_regexp': /x/,", + "'_string': new String('a'),", + "'_undefined': undefined,", + '})' + ].join('\n'))); + } catch(e) { } - var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc; - idoc.write([ - '