+ JSObject* result = constructEmptyObject(exec);
+ result->putDirect(exec->vm(), Identifier::fromString(exec, "name"), jsString(exec, name));
+ result->putDirect(exec->vm(), Identifier::fromString(exec, "value"), value);
+ return result;
+}
+
+JSValue JSInjectedScriptHost::getInternalProperties(ExecState* exec)
+{
+ if (exec->argumentCount() < 1)
+ return jsUndefined();
+
+ JSValue value = exec->uncheckedArgument(0);
+
+#if ENABLE(PROMISES)
+ if (JSPromise* promise = jsDynamicCast<JSPromise*>(value)) {
+ unsigned index = 0;
+ JSArray* array = constructEmptyArray(exec, nullptr);
+ switch (promise->status(exec->vm())) {
+ case JSPromise::Status::Pending:
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("status"), jsNontrivialString(exec, ASCIILiteral("pending"))));
+ break;
+ case JSPromise::Status::Fulfilled:
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("status"), jsNontrivialString(exec, ASCIILiteral("resolved"))));
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("result"), promise->result(exec->vm())));
+ break;
+ case JSPromise::Status::Rejected:
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("status"), jsNontrivialString(exec, ASCIILiteral("rejected"))));
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("result"), promise->result(exec->vm())));
+ break;
+ }
+ // FIXME: <https://webkit.org/b/141664> Web Inspector: ES6: Improved Support for Promises - Promise Reactions
+ return array;
+ }
+#endif
+
+ if (JSBoundFunction* boundFunction = jsDynamicCast<JSBoundFunction*>(value)) {
+ unsigned index = 0;
+ JSArray* array = constructEmptyArray(exec, nullptr, 3);
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, "targetFunction", boundFunction->targetFunction()));
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, "boundThis", boundFunction->boundThis()));
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, "boundArgs", boundFunction->boundArgs()));
+ return array;
+ }
+
+ if (JSArrayIterator* arrayIterator = jsDynamicCast<JSArrayIterator*>(value)) {
+ String kind;
+ switch (arrayIterator->kind(exec)) {
+ case ArrayIterateKey:
+ kind = ASCIILiteral("key");
+ break;
+ case ArrayIterateValue:
+ kind = ASCIILiteral("value");
+ break;
+ case ArrayIterateKeyValue:
+ kind = ASCIILiteral("key+value");
+ break;
+ }
+ unsigned index = 0;
+ JSArray* array = constructEmptyArray(exec, nullptr, 2);
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, "array", arrayIterator->iteratedValue(exec)));
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, "kind", jsNontrivialString(exec, kind)));
+ return array;
+ }
+
+ if (JSMapIterator* mapIterator = jsDynamicCast<JSMapIterator*>(value)) {
+ String kind;
+ switch (mapIterator->kind()) {
+ case MapIterateKey:
+ kind = ASCIILiteral("key");
+ break;
+ case MapIterateValue:
+ kind = ASCIILiteral("value");
+ break;
+ case MapIterateKeyValue:
+ kind = ASCIILiteral("key+value");
+ break;
+ }
+ unsigned index = 0;
+ JSArray* array = constructEmptyArray(exec, nullptr, 2);
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, "map", mapIterator->iteratedValue()));
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, "kind", jsNontrivialString(exec, kind)));
+ return array;
+ }
+
+ if (JSSetIterator* setIterator = jsDynamicCast<JSSetIterator*>(value)) {
+ String kind;
+ switch (setIterator->kind()) {
+ case SetIterateKey:
+ kind = ASCIILiteral("key");
+ break;
+ case SetIterateValue:
+ kind = ASCIILiteral("value");
+ break;
+ case SetIterateKeyValue:
+ kind = ASCIILiteral("key+value");
+ break;
+ }
+ unsigned index = 0;
+ JSArray* array = constructEmptyArray(exec, nullptr, 2);
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, "set", setIterator->iteratedValue()));
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, "kind", jsNontrivialString(exec, kind)));
+ return array;
+ }
+
+ if (JSStringIterator* stringIterator = jsDynamicCast<JSStringIterator*>(value)) {
+ unsigned index = 0;
+ JSArray* array = constructEmptyArray(exec, nullptr, 1);
+ array->putDirectIndex(exec, index++, constructInternalProperty(exec, "string", stringIterator->iteratedValue(exec)));
+ return array;
+ }
+