Fix for AVATAR_JS-123, create context with a Context constructor

Reviewed-by: kinsleyw
This commit is contained in:
Jean-Francois 2013-12-16 19:44:21 +01:00
parent ef3e50aed2
commit a7b784df3a
4 changed files with 11 additions and 35 deletions

View File

@ -311,7 +311,6 @@
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-pipe-unref.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-readline-interface.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-repl.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-repl-tab-complete.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-script-context.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-stream2-push.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-stream2-read-sync-stack.js"/>
@ -391,7 +390,6 @@
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-pipe-unref.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-readline-interface.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-repl.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-repl-tab-complete.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-script-context.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-stream2-push.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-stream2-read-sync-stack.js"/>

View File

@ -1,14 +1,5 @@
--- ../nodejs/lib/repl.js 2013-12-09 18:56:15.294402800 -0800
+++ src/main/js/lib/repl.js 2013-12-10 11:23:45.938789000 -0800
@@ -535,7 +535,7 @@
// Get global vars synchronously
if (this.useGlobal ||
this.context.constructor &&
- this.context.constructor.name === 'Context') {
+ this.context.constructor.name === 'Object') {
var contextProto = this.context;
while (contextProto = Object.getPrototypeOf(contextProto)) {
completionGroups.push(Object.getOwnPropertyNames(contextProto));
--- ../node/lib/repl.js 2013-12-16 17:07:31.000000000 +0100
+++ src/main/js/lib/repl.js 2013-12-16 16:16:00.000000000 +0100
@@ -923,5 +923,5 @@
// "strict mode" syntax errors
!e.match(/^SyntaxError: .*strict mode.*/i) &&

View File

@ -1,17 +0,0 @@
--- ../nodejs/test/simple/test-repl-tab-complete.js 2013-12-09 13:40:07.595157300 -0800
+++ test/simple/test-repl-tab-complete.js 2013-12-09 13:42:33.179597400 -0800
@@ -55,9 +55,11 @@
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});
-testMe.complete('console.lo', function(error, data) {
- assert.deepEqual(data, [['console.log'], 'console.lo']);
-});
+
+// Disabling this test because console is undefined in Nashorn
+//testMe.complete('console.lo', function(error, data) {
+// assert.deepEqual(data, [['console.log'], 'console.lo']);
+//});
// Tab Complete will return globaly scoped variables
putIn.run(['};']);

View File

@ -72,19 +72,23 @@
*
*/
function Context() {
}
/**
* Static creation of a new global context used for execution in a foreign global context.
* A shalow copy of the init instance is set in the returned context. There is no sharing between
* the current context and new context.
*/
exports.NodeScript.createContext = function(initSandbox) {
var context = {};
var init;
// Undocumented but, coffee-script expects this to be:
// sandbox instanceof Script.createContext().constructor
context.__proto__ = exports.NodeScript.createContext.prototype
// repl expects contructor.name === 'Context'
var context = new Context();
var init;
// The optional argument initSandbox will be shallow-copied to seed
// the initial contents of the global object used by the context.
if (initSandbox) {