https://bugs.webkit.org/show_bug.cgi?id=150696
Re-landing, as this wasn't the culprit.
Source/JavaScriptCore:
* runtime/ArrayIteratorPrototype.cpp:
(JSC::ArrayIteratorPrototype::finishCreation):
* runtime/CommonIdentifiers.h:
* runtime/JSArrayBufferPrototype.cpp:
(JSC::JSArrayBufferPrototype::finishCreation):
(JSC::JSArrayBufferPrototype::create):
* runtime/JSDataViewPrototype.cpp:
(JSC::JSDataViewPrototype::create):
(JSC::JSDataViewPrototype::finishCreation):
(JSC::JSDataViewPrototype::createStructure):
* runtime/JSDataViewPrototype.h:
* runtime/JSModuleNamespaceObject.cpp:
(JSC::JSModuleNamespaceObject::finishCreation):
* runtime/JSONObject.cpp:
(JSC::JSONObject::finishCreation):
* runtime/JSPromisePrototype.cpp:
(JSC::JSPromisePrototype::finishCreation):
(JSC::JSPromisePrototype::getOwnPropertySlot):
* runtime/JSTypedArrayViewPrototype.cpp:
(JSC::typedArrayViewProtoFuncValues):
(JSC::typedArrayViewProtoGetterFuncToStringTag):
(JSC::JSTypedArrayViewPrototype::JSTypedArrayViewPrototype):
(JSC::JSTypedArrayViewPrototype::finishCreation):
* runtime/MapIteratorPrototype.cpp:
(JSC::MapIteratorPrototype::finishCreation):
(JSC::MapIteratorPrototypeFuncNext):
* runtime/MapPrototype.cpp:
(JSC::MapPrototype::finishCreation):
* runtime/MathObject.cpp:
(JSC::MathObject::finishCreation):
* runtime/ObjectPrototype.cpp:
(JSC::objectProtoFuncToString):
* runtime/SetIteratorPrototype.cpp:
(JSC::SetIteratorPrototype::finishCreation):
(JSC::SetIteratorPrototypeFuncNext):
* runtime/SetPrototype.cpp:
(JSC::SetPrototype::finishCreation):
* runtime/SmallStrings.cpp:
(JSC::SmallStrings::SmallStrings):
(JSC::SmallStrings::initializeCommonStrings):
(JSC::SmallStrings::visitStrongReferences):
* runtime/SmallStrings.h:
(JSC::SmallStrings::typeString):
(JSC::SmallStrings::objectStringStart):
(JSC::SmallStrings::nullObjectString):
(JSC::SmallStrings::undefinedObjectString):
* runtime/StringIteratorPrototype.cpp:
(JSC::StringIteratorPrototype::finishCreation):
* runtime/SymbolPrototype.cpp:
(JSC::SymbolPrototype::finishCreation):
* runtime/WeakMapPrototype.cpp:
(JSC::WeakMapPrototype::finishCreation):
(JSC::getWeakMapData):
* runtime/WeakSetPrototype.cpp:
(JSC::WeakSetPrototype::finishCreation):
(JSC::getWeakMapData):
* tests/es6.yaml:
* tests/modules/namespace.js:
* tests/stress/symbol-tostringtag.js: Copied from Source/JavaScriptCore/tests/stress/symbol-tostringtag.js.
LayoutTests:
* js/Object-getOwnPropertyNames-expected.txt:
* js/script-tests/Object-getOwnPropertyNames.js:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191864
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-11-01 Alexey Proskuryakov <ap@apple.com>
+
+ [ES6] Add support for toStringTag
+ https://bugs.webkit.org/show_bug.cgi?id=150696
+
+ Re-landing, as this wasn't the culprit.
+
+ * js/Object-getOwnPropertyNames-expected.txt:
+ * js/script-tests/Object-getOwnPropertyNames.js:
+
2015-11-01 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r191815 and r191821.
PASS getSortedOwnPropertyNames(Error.prototype) is ['constructor', 'message', 'name', 'toString']
PASS getSortedOwnPropertyNames(Math) is ['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','clz32','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sign','sin','sinh','sqrt','tan','tanh','trunc']
PASS getSortedOwnPropertyNames(JSON) is ['parse', 'stringify']
-PASS getSortedOwnPropertyNames(Symbol) is ['for', 'iterator', 'keyFor', 'length', 'name', 'prototype', 'unscopables']
+PASS getSortedOwnPropertyNames(Symbol) is ['for', 'iterator', 'keyFor', 'length', 'name', 'prototype', 'toStringTag', 'unscopables']
PASS getSortedOwnPropertyNames(Symbol.prototype) is ['constructor', 'toString', 'valueOf']
PASS globalPropertyNames.indexOf('NaN') != -1 is true
PASS globalPropertyNames.indexOf('Infinity') != -1 is true
"Error.prototype": "['constructor', 'message', 'name', 'toString']",
"Math": "['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','clz32','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sign','sin','sinh','sqrt','tan','tanh','trunc']",
"JSON": "['parse', 'stringify']",
- "Symbol": "['for', 'iterator', 'keyFor', 'length', 'name', 'prototype', 'unscopables']",
+ "Symbol": "['for', 'iterator', 'keyFor', 'length', 'name', 'prototype', 'toStringTag', 'unscopables']",
"Symbol.prototype": "['constructor', 'toString', 'valueOf']"
};
+2015-11-01 Alexey Proskuryakov <ap@apple.com>
+
+ [ES6] Add support for toStringTag
+ https://bugs.webkit.org/show_bug.cgi?id=150696
+
+ Re-landing, as this wasn't the culprit.
+
+ * runtime/ArrayIteratorPrototype.cpp:
+ (JSC::ArrayIteratorPrototype::finishCreation):
+ * runtime/CommonIdentifiers.h:
+ * runtime/JSArrayBufferPrototype.cpp:
+ (JSC::JSArrayBufferPrototype::finishCreation):
+ (JSC::JSArrayBufferPrototype::create):
+ * runtime/JSDataViewPrototype.cpp:
+ (JSC::JSDataViewPrototype::create):
+ (JSC::JSDataViewPrototype::finishCreation):
+ (JSC::JSDataViewPrototype::createStructure):
+ * runtime/JSDataViewPrototype.h:
+ * runtime/JSModuleNamespaceObject.cpp:
+ (JSC::JSModuleNamespaceObject::finishCreation):
+ * runtime/JSONObject.cpp:
+ (JSC::JSONObject::finishCreation):
+ * runtime/JSPromisePrototype.cpp:
+ (JSC::JSPromisePrototype::finishCreation):
+ (JSC::JSPromisePrototype::getOwnPropertySlot):
+ * runtime/JSTypedArrayViewPrototype.cpp:
+ (JSC::typedArrayViewProtoFuncValues):
+ (JSC::typedArrayViewProtoGetterFuncToStringTag):
+ (JSC::JSTypedArrayViewPrototype::JSTypedArrayViewPrototype):
+ (JSC::JSTypedArrayViewPrototype::finishCreation):
+ * runtime/MapIteratorPrototype.cpp:
+ (JSC::MapIteratorPrototype::finishCreation):
+ (JSC::MapIteratorPrototypeFuncNext):
+ * runtime/MapPrototype.cpp:
+ (JSC::MapPrototype::finishCreation):
+ * runtime/MathObject.cpp:
+ (JSC::MathObject::finishCreation):
+ * runtime/ObjectPrototype.cpp:
+ (JSC::objectProtoFuncToString):
+ * runtime/SetIteratorPrototype.cpp:
+ (JSC::SetIteratorPrototype::finishCreation):
+ (JSC::SetIteratorPrototypeFuncNext):
+ * runtime/SetPrototype.cpp:
+ (JSC::SetPrototype::finishCreation):
+ * runtime/SmallStrings.cpp:
+ (JSC::SmallStrings::SmallStrings):
+ (JSC::SmallStrings::initializeCommonStrings):
+ (JSC::SmallStrings::visitStrongReferences):
+ * runtime/SmallStrings.h:
+ (JSC::SmallStrings::typeString):
+ (JSC::SmallStrings::objectStringStart):
+ (JSC::SmallStrings::nullObjectString):
+ (JSC::SmallStrings::undefinedObjectString):
+ * runtime/StringIteratorPrototype.cpp:
+ (JSC::StringIteratorPrototype::finishCreation):
+ * runtime/SymbolPrototype.cpp:
+ (JSC::SymbolPrototype::finishCreation):
+ * runtime/WeakMapPrototype.cpp:
+ (JSC::WeakMapPrototype::finishCreation):
+ (JSC::getWeakMapData):
+ * runtime/WeakSetPrototype.cpp:
+ (JSC::WeakSetPrototype::finishCreation):
+ (JSC::getWeakMapData):
+ * tests/es6.yaml:
+ * tests/modules/namespace.js:
+ * tests/stress/symbol-tostringtag.js: Copied from Source/JavaScriptCore/tests/stress/symbol-tostringtag.js.
+
2015-11-01 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r191815 and r191821.
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Array Iterator"), DontEnum | ReadOnly);
vm.prototypeMap.addPrototype(this);
}
macro(search) \
macro(species) \
macro(split) \
- macro(toPrimitive) \
- macro(toStringTag)
+ macro(toPrimitive)
#define JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(macro) \
macro(iterator) \
- macro(unscopables)
+ macro(unscopables) \
+ macro(toStringTag)
#define JSC_COMMON_BYTECODE_INTRINSICS_EACH_NAME(macro) \
macro(putByValDirect) \
Base::finishCreation(vm);
JSC_NATIVE_FUNCTION(vm.propertyNames->slice, arrayBufferProtoFuncSlice, DontEnum, 2);
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "ArrayBuffer"), DontEnum | ReadOnly);
}
JSArrayBufferPrototype* JSArrayBufferPrototype::create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
return prototype;
}
+void JSDataViewPrototype::finishCreation(JSC::VM& vm)
+{
+ Base::finishCreation(vm);
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "DataView"), DontEnum | ReadOnly);
+}
+
Structure* JSDataViewPrototype::createStructure(
VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
protected:
JSDataViewPrototype(VM&, Structure*);
+ void finishCreation(VM&);
+
public:
static JSDataViewPrototype* create(VM&, Structure*);
m_moduleRecord.set(vm, this, moduleRecord);
JSC_NATIVE_FUNCTION(vm.propertyNames->iteratorSymbol, moduleNamespaceObjectSymbolIterator, DontEnum, 0);
+ putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Module"), DontEnum | ReadOnly);
// http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-getprototypeof
// http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-setprototypeof-v
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
+
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "JSON"), DontEnum | ReadOnly);
}
// PropertyNameForFunctionCall objects must be on the stack, since the JSValue that they create is not marked.
void JSPromisePrototype::finishCreation(VM& vm, Structure*)
{
Base::finishCreation(vm);
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Promise"), DontEnum | ReadOnly);
}
bool JSPromisePrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(typedArrayViewProtoFuncValues);
}
+static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoGetterFuncToStringTag(ExecState* exec)
+{
+ JSValue thisValue = exec->thisValue();
+ if (!thisValue.isObject())
+ return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
+
+ VM& vm = exec->vm();
+ switch (thisValue.getObject()->classInfo()->typedArrayStorageType) {
+ case TypeUint8Clamped:
+ return JSValue::encode(jsString(&vm, "Uint8ClampedArray"));
+ case TypeInt32:
+ return JSValue::encode(jsString(&vm, "Int32Array"));
+ case TypeUint32:
+ return JSValue::encode(jsString(&vm, "Uint32Array"));
+ case TypeFloat64:
+ return JSValue::encode(jsString(&vm, "Float64Array"));
+ case TypeFloat32:
+ return JSValue::encode(jsString(&vm, "Float32Array"));
+ case TypeInt8:
+ return JSValue::encode(jsString(&vm, "Int8Array"));
+ case TypeUint8:
+ return JSValue::encode(jsString(&vm, "Uint8Array"));
+ case TypeInt16:
+ return JSValue::encode(jsString(&vm, "Int16Array"));
+ case TypeUint16:
+ return JSValue::encode(jsString(&vm, "Uint16Array"));
+ case NotTypedArray:
+ case TypeDataView:
+ return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view"));
+ }
+ RELEASE_ASSERT_NOT_REACHED();
+}
+
+
#undef CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION
JSTypedArrayViewPrototype::JSTypedArrayViewPrototype(VM& vm, Structure* structure)
JSC_NATIVE_FUNCTION(vm.propertyNames->subarray, typedArrayViewProtoFuncSubarray, DontEnum, 2);
JSC_BUILTIN_FUNCTION(vm.propertyNames->toLocaleString, typedArrayPrototypeToLocaleStringCodeGenerator, DontEnum);
JSC_NATIVE_FUNCTION(vm.propertyNames->toString, arrayProtoFuncToString, DontEnum, 0);
+ JSC_NATIVE_GETTER(vm.propertyNames->toStringTagSymbol, typedArrayViewProtoGetterFuncToStringTag, DontEnum | ReadOnly);
JSFunction* valuesFunction = JSFunction::create(vm, globalObject, 0, vm.propertyNames->values.string(), typedArrayViewProtoFuncValues);
vm.prototypeMap.addPrototype(this);
JSC_NATIVE_FUNCTION(vm.propertyNames->next, MapIteratorPrototypeFuncNext, DontEnum, 0);
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Map Iterator"), DontEnum | ReadOnly);
}
EncodedJSValue JSC_HOST_CALL MapIteratorPrototypeFuncNext(CallFrame* callFrame)
JSFunction* entries = JSFunction::create(vm, globalObject, 0, vm.propertyNames->entries.string(), mapProtoFuncEntries);
putDirectWithoutTransition(vm, vm.propertyNames->entries, entries, DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, entries, DontEnum);
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Map"), DontEnum | ReadOnly);
GetterSetter* accessor = GetterSetter::create(vm, globalObject);
JSFunction* function = JSFunction::create(vm, globalObject, 0, vm.propertyNames->size.string(), mapProtoFuncSize);
putDirectWithoutTransition(vm, Identifier::fromString(&vm, "PI"), jsNumber(piDouble), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(vm, Identifier::fromString(&vm, "SQRT1_2"), jsNumber(sqrt(0.5)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(vm, Identifier::fromString(&vm, "SQRT2"), jsNumber(sqrt(2.0)), DontDelete | DontEnum | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Math"), DontEnum | ReadOnly);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "abs"), 1, mathProtoFuncAbs, AbsIntrinsic, DontEnum);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "acos"), 1, mathProtoFuncACos, NoIntrinsic, DontEnum);
#include "JSFunction.h"
#include "JSString.h"
#include "JSCInlines.h"
+#include "PropertySlot.h"
#include "StructureRareDataInlines.h"
namespace JSC {
return JSValue::encode(thisValue.isUndefined() ? vm.smallStrings.undefinedObjectString() : vm.smallStrings.nullObjectString());
JSObject* thisObject = thisValue.toObject(exec);
+ JSValue stringTag = thisObject->get(exec, exec->propertyNames().toStringTagSymbol);
+ if (stringTag.isString()) {
+ JSRopeString::RopeBuilder ropeBuilder(vm);
+ ropeBuilder.append(vm.smallStrings.objectStringStart());
+ ropeBuilder.append(jsCast<JSString*>(stringTag));
+ ropeBuilder.append(vm.smallStrings.singleCharacterString(']'));
+ return JSValue::encode(ropeBuilder.release());
+ }
+
JSString* result = thisObject->structure(vm)->objectToStringValue();
if (!result) {
String newString = WTF::tryMakeString("[object ", thisObject->methodTable(exec->vm())->className(thisObject), "]");
vm.prototypeMap.addPrototype(this);
JSC_NATIVE_FUNCTION(vm.propertyNames->next, SetIteratorPrototypeFuncNext, DontEnum, 0);
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Set Iterator"), DontEnum | ReadOnly);
}
EncodedJSValue JSC_HOST_CALL SetIteratorPrototypeFuncNext(CallFrame* callFrame)
putDirectWithoutTransition(vm, vm.propertyNames->values, values, DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->keys, values, DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, values, DontEnum);
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Set"), DontEnum | ReadOnly);
GetterSetter* accessor = GetterSetter::create(vm, globalObject);
JSFunction* function = JSFunction::create(vm, globalObject, 0, vm.propertyNames->size.string(), setProtoFuncSize);
#define JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE(name) , m_##name(0)
JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE)
#undef JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE
+ , m_objectStringStart(nullptr)
, m_nullObjectString(nullptr)
, m_undefinedObjectString(nullptr)
, m_needsToBeVisited(true)
#define JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE(name) initialize(&vm, m_##name, #name);
JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE)
#undef JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE
+ initialize(&vm, m_objectStringStart, "[object ");
initialize(&vm, m_nullObjectString, "[object Null]");
initialize(&vm, m_undefinedObjectString, "[object Undefined]");
}
#define JSC_COMMON_STRINGS_ATTRIBUTE_VISIT(name) visitor.appendUnbarrieredPointer(&m_##name);
JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ATTRIBUTE_VISIT)
#undef JSC_COMMON_STRINGS_ATTRIBUTE_VISIT
+ visitor.appendUnbarrieredPointer(&m_objectStringStart);
visitor.appendUnbarrieredPointer(&m_nullObjectString);
visitor.appendUnbarrieredPointer(&m_undefinedObjectString);
}
return nullptr;
}
+ JSString* objectStringStart() const { return m_objectStringStart; }
JSString* nullObjectString() const { return m_nullObjectString; }
JSString* undefinedObjectString() const { return m_undefinedObjectString; }
#define JSC_COMMON_STRINGS_ATTRIBUTE_DECLARATION(name) JSString* m_##name;
JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ATTRIBUTE_DECLARATION)
#undef JSC_COMMON_STRINGS_ATTRIBUTE_DECLARATION
+ JSString* m_objectStringStart;
JSString* m_nullObjectString;
JSString* m_undefinedObjectString;
JSString* m_singleCharacterStrings[singleCharacterStringCount];
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "String Iterator"), DontEnum | ReadOnly);
vm.prototypeMap.addPrototype(this);
}
#include "Error.h"
#include "JSCInlines.h"
+#include "JSString.h"
namespace JSC {
void SymbolPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Symbol"), DontEnum | ReadOnly);
ASSERT(inherits(info()));
}
JSC_NATIVE_FUNCTION(vm.propertyNames->get, protoFuncWeakMapGet, DontEnum, 1);
JSC_NATIVE_FUNCTION(vm.propertyNames->has, protoFuncWeakMapHas, DontEnum, 1);
JSC_NATIVE_FUNCTION(vm.propertyNames->set, protoFuncWeakMapSet, DontEnum, 2);
+
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "WeakMap"), DontEnum | ReadOnly);
}
static WeakMapData* getWeakMapData(CallFrame* callFrame, JSValue value)
JSC_NATIVE_FUNCTION(vm.propertyNames->deleteKeyword, protoFuncWeakSetDelete, DontEnum, 1);
JSC_NATIVE_FUNCTION(vm.propertyNames->has, protoFuncWeakSetHas, DontEnum, 1);
JSC_NATIVE_FUNCTION(vm.propertyNames->add, protoFuncWeakSetAdd, DontEnum, 1);
+
+ putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "WeakSet"), DontEnum | ReadOnly);
}
static WeakMapData* getWeakMapData(CallFrame* callFrame, JSValue value)
- path: es6/well-known_symbols_Symbol.toPrimitive.js
cmd: runES6 :fail
- path: es6/well-known_symbols_Symbol.toStringTag.js
- cmd: runES6 :fail
+ cmd: runES6 :normal
- path: es6/well-known_symbols_Symbol.toStringTag_misc._built-ins.js
- cmd: runES6 :fail
+ cmd: runES6 :normal
// These names should be shown in the code point order.
shouldBe(JSON.stringify(Object.getOwnPropertyNames(namespace)), `["Cappuccino","Cocoa","Matcha","Mocha","default"]`);
-shouldBe(Object.getOwnPropertySymbols(namespace).length, 1);
+shouldBe(Object.getOwnPropertySymbols(namespace).length, 2);
shouldBe(Object.getOwnPropertySymbols(namespace)[0], Symbol.iterator);
+shouldBe(Object.getOwnPropertySymbols(namespace)[1], Symbol.toStringTag);
shouldBe(typeof namespace[Symbol.iterator], 'function');
var array = Array.from(namespace);
--- /dev/null
+// This file tests the names of all the classes with builtin Symbol.toStringTags and Object.prototype.toString().
+
+foo = { };
+foo[Symbol.toStringTag] = "test the tag";
+
+if (foo != "[object test the tag]")
+ throw "failed on custom toStringTag";
+
+function toStr(obj) {
+ return Object.prototype.toString.call(obj);
+}
+
+function strName(str) { return "[object " + str + "]"; }
+
+if (toStr(Symbol()) !== strName("Symbol"))
+ throw "failed on Symbol";
+
+if (toStr(Symbol.prototype) !== strName("Symbol"))
+ throw "failed on Symbol.prototype";
+
+objects = ["JSON", "Math"];
+
+for (name of objects) {
+ value = eval(name)
+ if (toStr(value) !== strName(name))
+ throw "failed on " + name;
+}
+
+iterators = ['Array', 'Map', 'Set', 'String'];
+
+for (name of iterators) {
+ value = eval('new ' + name + '()[Symbol.iterator]()');
+ if (toStr(value) !== strName(name + ' Iterator'))
+ throw 'failed on Iterator of ' + name;
+ if (toStr(Object.getPrototypeOf(value)) !== strName(name + ' Iterator'))
+ throw 'failed on Iterator.prototype of ' + name;
+}
+
+classes = { "ArrayBuffer": 10, "DataView": new ArrayBuffer(10), "Promise": function() { return 1 }, "Set": undefined, "WeakMap": undefined, "WeakSet": undefined };
+
+for (name in classes) {
+ value = eval(name);
+ if (toStr(new value(classes[name])) !== strName(name))
+ throw "failed on new object of " + name;
+ if (toStr(value.prototype) !== strName(name))
+ throw "failed on prototype of " + name;
+}
+