diff --git a/deps/chakrashim/include/v8.h b/deps/chakrashim/include/v8.h index 057cd22b589..b16200c5bf9 100644 --- a/deps/chakrashim/include/v8.h +++ b/deps/chakrashim/include/v8.h @@ -1117,10 +1117,7 @@ class V8_EXPORT Value : public Data { bool IsFloat32Array() const; bool IsFloat64Array() const; bool IsDataView() const; - bool IsSharedArrayBuffer() const { - // CHAKRA-TODO Not implemented - return false; - } + bool IsSharedArrayBuffer() const; bool IsMapIterator() const; bool IsSetIterator() const; bool IsMap() const; diff --git a/deps/chakrashim/lib/chakra_shim.js b/deps/chakrashim/lib/chakra_shim.js index b8531358dcc..b92c622fcaa 100644 --- a/deps/chakrashim/lib/chakra_shim.js +++ b/deps/chakrashim/lib/chakra_shim.js @@ -30,11 +30,6 @@ const Object_setPrototypeOf = Object.setPrototypeOf; const Reflect_apply = Reflect.apply; const Reflect_construct = Reflect.construct; - const Map_keys = Map.prototype.keys; - const Map_values = Map.prototype.values; - const Map_entries = Map.prototype.entries; - const Set_entries = Set.prototype.entries; - const Set_values = Set.prototype.values; const Symbol_keyFor = Symbol.keyFor; const Symbol_for = Symbol.for; const Global_ParseInt = parseInt; @@ -324,41 +319,6 @@ Error.captureStackTrace = captureStackTrace; } - const mapIteratorProperty = 'MapIteratorIndicator'; - function patchMapIterator() { - const originalMapMethods = []; - originalMapMethods.push(['entries', Map_entries]); - originalMapMethods.push(['values', Map_values]); - originalMapMethods.push(['keys', Map_keys]); - - originalMapMethods.forEach(function(pair) { - Map.prototype[pair[0]] = function() { - const result = pair[1].apply(this); - Object_defineProperty( - result, mapIteratorProperty, - { value: true, enumerable: false, writable: false }); - return result; - }; - }); - } - - const setIteratorProperty = 'SetIteratorIndicator'; - function patchSetIterator() { - const originalSetMethods = []; - originalSetMethods.push(['entries', Set_entries]); - originalSetMethods.push(['values', Set_values]); - - originalSetMethods.forEach(function(pair) { - Set.prototype[pair[0]] = function() { - const result = pair[1].apply(this); - Object_defineProperty( - result, setIteratorProperty, - { value: true, enumerable: false, writable: false }); - return result; - }; - }); - } - // Ensure global Debug object if not already exists, and patch it. function ensureDebug(otherGlobal) { if (!global.Debug) { @@ -535,19 +495,19 @@ return captureStackTrace({}, undefined)(); }; - utils.isMapIterator = function(value) { - return value[mapIteratorProperty] === true; - }; - - utils.isSetIterator = function(value) { - return value[setIteratorProperty] === true; - }; - function compareType(o, expectedType) { return Object_prototype_toString.call(o) === '[object ' + expectedType + ']'; } + utils.isMapIterator = function(obj) { + return compareType(obj, 'Map Iterator'); + }; + + utils.isSetIterator = function(obj) { + return compareType(obj, 'Set Iterator'); + }; + utils.isBooleanObject = function(obj) { return compareType(obj, 'Boolean'); }; @@ -627,6 +587,10 @@ return compareType(obj, 'String') || compareType(obj, 'Symbol'); }; + utils.isSharedArrayBuffer = function(obj) { + return compareType(obj, 'SharedArrayBuffer'); + }; + utils.getSymbolKeyFor = function(symbol) { return Symbol_keyFor(symbol); }; @@ -707,8 +671,6 @@ patchErrorTypes(); patchErrorStack(); - patchMapIterator(); - patchSetIterator(); patchUtils(keepAlive); }); diff --git a/deps/chakrashim/src/jsrtcachedpropertyidref.inc b/deps/chakrashim/src/jsrtcachedpropertyidref.inc index d50b369f42b..4f542b5ec1a 100644 --- a/deps/chakrashim/src/jsrtcachedpropertyidref.inc +++ b/deps/chakrashim/src/jsrtcachedpropertyidref.inc @@ -161,6 +161,7 @@ DEF_IS_TYPE(isWeakMap) DEF_IS_TYPE(isWeakSet) DEF_IS_TYPE(isSymbolObject) DEF_IS_TYPE(isName) +DEF_IS_TYPE(isSharedArrayBuffer) #undef DEF diff --git a/deps/chakrashim/src/v8value.cc b/deps/chakrashim/src/v8value.cc index 6232bdfdf08..2dc76a297fc 100644 --- a/deps/chakrashim/src/v8value.cc +++ b/deps/chakrashim/src/v8value.cc @@ -179,6 +179,7 @@ IS_TYPE_FUNCTION(IsWeakMap, isWeakMap) IS_TYPE_FUNCTION(IsWeakSet, isWeakSet) IS_TYPE_FUNCTION(IsSymbolObject, isSymbolObject) IS_TYPE_FUNCTION(IsName, isName) +IS_TYPE_FUNCTION(IsSharedArrayBuffer, isSharedArrayBuffer) MaybeLocal Value::ToBoolean(Local context) const { JsValueRef value; diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js index 49ebb849353..1c3fd006336 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -26,14 +26,14 @@ if (process.jsEngine === 'chakracore') { // This file contains the V8-specific "%" syntax for accessing - // private functions. This is not supported on ChakraCore and causes a - // parser failure. Inject a cache entry to prevent the file from being - // parsed. + // private functions. This is not supported on ChakraCore and causes a + // parser failure. Inject a cache entry to prevent the file from being + // parsed. Return an array to mimmick behavior (required by util.inspect) NativeModule._cache['internal/v8'] = { loaded: true, exports: { - previewMapIterator: function() {}, - previewSetIterator: function() {}, + previewMapIterator: function() { return []; }, + previewSetIterator: function() { return []; }, }, }; } diff --git a/test/parallel/test-util-types.js b/test/parallel/test-util-types.js index f9211ddf420..7b20d966a10 100644 --- a/test/parallel/test-util-types.js +++ b/test/parallel/test-util-types.js @@ -49,7 +49,9 @@ for (const [ value, _method ] of [ { value: 'foo' }) ], [ new DataView(new ArrayBuffer()) ], [ new SharedArrayBuffer() ], - [ new Proxy({}, {}), 'isProxy' ], + // Node-ChakraCore does not support util.types.isProxy() due to + // Microsoft/ChakraCore#950 and node/node-chakracore#488 + !common.isChakraEngine ? [ new Proxy({}, {}), 'isProxy' ] : [ new Date() ], [ new WebAssembly.Module(wasmBuffer), 'isWebAssemblyCompiledModule' ], ]) { const method = _method || `is${value.constructor.name}`;