diff --git a/deps/chakrashim/lib/chakra_shim.js b/deps/chakrashim/lib/chakra_shim.js index 4883f4dac71..bdd8bc6237c 100644 --- a/deps/chakrashim/lib/chakra_shim.js +++ b/deps/chakrashim/lib/chakra_shim.js @@ -19,11 +19,6 @@ // IN THE SOFTWARE. 'use strict'; -// CHAKRA-TODO doesn't implement the debugger. So add a dummy 'Debug' on -// global object for now. -Object.defineProperty(this, 'Debug', - { value: {}, enumerable: false, configurable: false, writable: false }); - (function() { // Save original builtIns var diff --git a/deps/chakrashim/src/v8debug.cc b/deps/chakrashim/src/v8debug.cc index e8e40dd8bd6..ce01fa416af 100644 --- a/deps/chakrashim/src/v8debug.cc +++ b/deps/chakrashim/src/v8debug.cc @@ -63,6 +63,23 @@ Local Debug::GetDebugContext() { HandleScope scope(isolate); g_debugContext = *Context::New(isolate); JsAddRef(g_debugContext, nullptr); + + // CHAKRA-TODO: Chakra doesn't fully implement the debugger without + // --debug flag. Add a dummy 'Debug' on global object if it doesn't + // already exist. + { + Context::Scope context_scope(g_debugContext); + wchar_t * debugScript = L"" + "if(this['Debug'] == undefined) { " + "Object.defineProperty(this, 'Debug', { value: {}, " + "enumerable : false, configurable : false, writable : false " + "}); " + "}"; + JsValueRef result; + if (JsRunScript(debugScript, JS_SOURCE_CONTEXT_NONE, L"", &result) != JsNoError) { + return Local(); + } + } } return static_cast(g_debugContext); diff --git a/test/parallel/test-cli-syntax.js b/test/parallel/test-cli-syntax.js index e893a64b604..66ec9bb4202 100644 --- a/test/parallel/test-cli-syntax.js +++ b/test/parallel/test-cli-syntax.js @@ -55,9 +55,9 @@ var syntaxArgs = [ // stderr should have a syntax error message var match = c.stderr.match(common.engineSpecificMessage({ - v8: /^SyntaxError: Unexpected identifier$/m, - chakracore: /^SyntaxError: Expected ';'$/m}) - ); + v8: /^SyntaxError: Unexpected identifier$/m, + chakracore: /^SyntaxError: Expected ';'$/m}) + ); assert(match, 'stderr incorrect'); assert.equal(c.status, 1, 'code == ' + c.status);