From 819bc9a2f9f86260af8a76027a712b2a310a088d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 30 Jul 2009 23:31:01 +0200 Subject: QScriptValueIterator: fix missing non-enumerable values Added an extra argument to JSObject::getPropertyNames() that specifies if the non-enumerable properties (those with the DontEnum attribute set) should be included or not. Tried looking at using a unsigned as an attribute-inclusion or exclusion filter, but the semantics of either the calling or the callee code would be very strange so I opted out. --- .../webkit/JavaScriptCore/API/JSCallbackObject.h | 2 +- .../JavaScriptCore/API/JSCallbackObjectFunctions.h | 6 +++--- src/3rdparty/webkit/JavaScriptCore/API/JSObjectRef.h | 3 ++- .../JavaScriptCore/debugger/DebuggerActivation.cpp | 4 ++-- .../JavaScriptCore/debugger/DebuggerActivation.h | 2 +- src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.cpp | 4 ++-- src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.h | 2 +- .../webkit/JavaScriptCore/runtime/JSByteArray.cpp | 4 ++-- .../webkit/JavaScriptCore/runtime/JSByteArray.h | 2 +- .../webkit/JavaScriptCore/runtime/JSNotAnObject.cpp | 2 +- .../webkit/JavaScriptCore/runtime/JSNotAnObject.h | 2 +- .../webkit/JavaScriptCore/runtime/JSObject.cpp | 4 ++-- src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h | 2 +- .../webkit/JavaScriptCore/runtime/JSVariableObject.cpp | 6 +++--- .../webkit/JavaScriptCore/runtime/JSVariableObject.h | 2 +- .../webkit/JavaScriptCore/runtime/RegExpMatchesArray.h | 4 ++-- .../webkit/JavaScriptCore/runtime/StringObject.cpp | 4 ++-- .../webkit/JavaScriptCore/runtime/StringObject.h | 2 +- .../webkit/JavaScriptCore/runtime/Structure.cpp | 18 ++++++++++-------- src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h | 6 +++--- .../webkit/WebCore/bindings/js/JSDOMWindowShell.cpp | 4 ++-- .../webkit/WebCore/bindings/js/JSDOMWindowShell.h | 2 +- .../WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp | 4 ++-- .../WebCore/bindings/js/JSQuarantinedObjectWrapper.h | 2 +- .../webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm | 6 +++--- src/3rdparty/webkit/WebCore/bridge/c/c_instance.cpp | 2 +- src/3rdparty/webkit/WebCore/bridge/c/c_instance.h | 2 +- src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp | 2 +- src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.h | 2 +- src/3rdparty/webkit/WebCore/bridge/runtime.h | 2 +- src/3rdparty/webkit/WebCore/bridge/runtime_object.cpp | 4 ++-- src/3rdparty/webkit/WebCore/bridge/runtime_object.h | 2 +- src/script/api/qscriptengine.cpp | 12 ++++++------ src/script/api/qscriptvalueiterator.cpp | 2 +- src/script/bridge/qscriptclassobject.cpp | 5 +++-- src/script/bridge/qscriptclassobject_p.h | 2 +- src/script/bridge/qscriptobject.cpp | 11 ++++++----- src/script/bridge/qscriptobject_p.h | 5 +++-- src/script/bridge/qscriptqobject.cpp | 11 ++++++----- src/script/bridge/qscriptqobject_p.h | 6 ++++-- tests/auto/qscriptengine/tst_qscriptengine.cpp | 4 ++-- 41 files changed, 91 insertions(+), 82 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObject.h b/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObject.h index 9d22ad9..4f1d51c 100644 --- a/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObject.h +++ b/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObject.h @@ -66,7 +66,7 @@ private: virtual bool hasInstance(ExecState* exec, JSValue value, JSValue proto); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); + virtual void getPropertyNames(ExecState*, PropertyNameArray&, bool includeNonEnumerable = false); virtual double toNumber(ExecState*) const; virtual UString toString(ExecState*) const; diff --git a/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObjectFunctions.h b/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObjectFunctions.h index 987c59f..8bcf8ad 100644 --- a/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObjectFunctions.h +++ b/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObjectFunctions.h @@ -372,7 +372,7 @@ JSValue JSCallbackObject::call(ExecState* exec, JSObject* functionObject, } template -void JSCallbackObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +void JSCallbackObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, bool includeNonEnumerable) { JSContextRef execRef = toRef(exec); JSObjectRef thisRef = toRef(this); @@ -380,7 +380,7 @@ void JSCallbackObject::getPropertyNames(ExecState* exec, PropertyNameArray for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) { JSLock::DropAllLocks dropAllLocks(exec); - getPropertyNames(execRef, thisRef, toRef(&propertyNames)); + getPropertyNames(execRef, thisRef, toRef(&propertyNames), includeNonEnumerable); } if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { @@ -406,7 +406,7 @@ void JSCallbackObject::getPropertyNames(ExecState* exec, PropertyNameArray } } - Base::getPropertyNames(exec, propertyNames); + Base::getPropertyNames(exec, propertyNames, includeNonEnumerable); } template diff --git a/src/3rdparty/webkit/JavaScriptCore/API/JSObjectRef.h b/src/3rdparty/webkit/JavaScriptCore/API/JSObjectRef.h index 3e8b0eb..4dedc57 100644 --- a/src/3rdparty/webkit/JavaScriptCore/API/JSObjectRef.h +++ b/src/3rdparty/webkit/JavaScriptCore/API/JSObjectRef.h @@ -187,6 +187,7 @@ typedef bool @param ctx The execution context to use. @param object The JSObject whose property names are being collected. @param accumulator A JavaScript property name accumulator in which to accumulate the names of object's properties. +@param includeNonEnumerable Flag deciding if properties with the DontEnum attribute should be included. @discussion If you named your function GetPropertyNames, you would declare it like this: void GetPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); @@ -196,7 +197,7 @@ Property name accumulators are used by JSObjectCopyPropertyNames and JavaScript Use JSPropertyNameAccumulatorAddName to add property names to accumulator. A class's getPropertyNames callback only needs to provide the names of properties that the class vends through a custom getProperty or setProperty callback. Other properties, including statically declared properties, properties vended by other classes, and properties belonging to object's prototype, are added independently. */ typedef void -(*JSObjectGetPropertyNamesCallback) (JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); +(*JSObjectGetPropertyNamesCallback) (JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames, bool includeNonEnumerable); /*! @typedef JSObjectCallAsFunctionCallback diff --git a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.cpp b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.cpp index 4b2568f..1a1b2a1 100644 --- a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.cpp @@ -70,9 +70,9 @@ bool DebuggerActivation::deleteProperty(ExecState* exec, const Identifier& prope return m_activation->deleteProperty(exec, propertyName); } -void DebuggerActivation::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +void DebuggerActivation::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, bool includeNonEnumerable) { - m_activation->getPropertyNames(exec, propertyNames); + m_activation->getPropertyNames(exec, propertyNames, includeNonEnumerable); } bool DebuggerActivation::getPropertyAttributes(JSC::ExecState* exec, const Identifier& propertyName, unsigned& attributes) const diff --git a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.h b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.h index 9e1f9f5..dcefe5e 100644 --- a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.h +++ b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.h @@ -42,7 +42,7 @@ namespace JSC { virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&); virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValue, unsigned attributes); virtual bool deleteProperty(ExecState*, const Identifier& propertyName); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); + virtual void getPropertyNames(ExecState*, PropertyNameArray&, bool includeNonEnumerable = false); virtual bool getPropertyAttributes(ExecState*, const Identifier& propertyName, unsigned& attributes) const; virtual void defineGetter(ExecState*, const Identifier& propertyName, JSObject* getterFunction); virtual void defineSetter(ExecState*, const Identifier& propertyName, JSObject* setterFunction); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.cpp index 296ac9d..a50fc86 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.cpp @@ -427,7 +427,7 @@ bool JSArray::deleteProperty(ExecState* exec, unsigned i) return false; } -void JSArray::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +void JSArray::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, bool includeNonEnumerable) { // FIXME: Filling PropertyNameArray with an identifier for every integer // is incredibly inefficient for large arrays. We need a different approach, @@ -447,7 +447,7 @@ void JSArray::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames propertyNames.add(Identifier::from(exec, it->first)); } - JSObject::getPropertyNames(exec, propertyNames); + JSObject::getPropertyNames(exec, propertyNames, includeNonEnumerable); } bool JSArray::increaseVectorLength(unsigned newLength) diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.h index ea490d8..aaeb810 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.h @@ -87,7 +87,7 @@ namespace JSC { virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&); virtual bool deleteProperty(ExecState*, const Identifier& propertyName); virtual bool deleteProperty(ExecState*, unsigned propertyName); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); + virtual void getPropertyNames(ExecState*, PropertyNameArray&, bool includeNonEnumerable = false); virtual void mark(); void* lazyCreationData(); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSByteArray.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSByteArray.cpp index 2a5e72f..fad7451 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSByteArray.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSByteArray.cpp @@ -85,12 +85,12 @@ void JSByteArray::put(ExecState* exec, unsigned propertyName, JSValue value) setIndex(exec, propertyName, value); } -void JSByteArray::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +void JSByteArray::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, bool includeNonEnumerable) { unsigned length = m_storage->length(); for (unsigned i = 0; i < length; ++i) propertyNames.add(Identifier::from(exec, i)); - JSObject::getPropertyNames(exec, propertyNames); + JSObject::getPropertyNames(exec, propertyNames, includeNonEnumerable); } } diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSByteArray.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSByteArray.h index 57374e0..ff57488 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSByteArray.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSByteArray.h @@ -81,7 +81,7 @@ namespace JSC { virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); virtual void put(JSC::ExecState*, unsigned propertyName, JSC::JSValue); - virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&); + virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, bool includeNonEnumerable = false); virtual const ClassInfo* classInfo() const { return m_classInfo; } static const ClassInfo s_defaultInfo; diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSNotAnObject.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSNotAnObject.cpp index 937dc2b..e4aa23c 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSNotAnObject.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSNotAnObject.cpp @@ -116,7 +116,7 @@ bool JSNotAnObject::deleteProperty(ExecState* exec, unsigned) return false; } -void JSNotAnObject::getPropertyNames(ExecState* exec, PropertyNameArray&) +void JSNotAnObject::getPropertyNames(ExecState* exec, PropertyNameArray&, bool) { ASSERT_UNUSED(exec, exec->hadException() && exec->exception() == m_exception); } diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSNotAnObject.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSNotAnObject.h index a8e36bd..dc89c66 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSNotAnObject.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSNotAnObject.h @@ -87,7 +87,7 @@ namespace JSC { virtual bool deleteProperty(ExecState*, const Identifier& propertyName); virtual bool deleteProperty(ExecState*, unsigned propertyName); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); + virtual void getPropertyNames(ExecState*, PropertyNameArray&, bool includeNonEnumerable = false); JSNotAnObjectErrorStub* m_exception; }; diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp index a54c322..8e5c398 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp @@ -447,9 +447,9 @@ bool JSObject::getPropertySpecificValue(ExecState*, const Identifier& propertyNa return false; } -void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, bool includeNonEnumerable) { - m_structure->getEnumerablePropertyNames(exec, propertyNames, this); + m_structure->getPropertyNames(exec, propertyNames, this, includeNonEnumerable); } bool JSObject::toBoolean(ExecState*) const diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h index db47ac7..9838bb1 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h @@ -117,7 +117,7 @@ namespace JSC { virtual bool hasInstance(ExecState*, JSValue, JSValue prototypeProperty); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); + virtual void getPropertyNames(ExecState*, PropertyNameArray&, bool includeNonEnumerable = false); virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const; virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSVariableObject.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSVariableObject.cpp index a36cefa..e67bca6 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSVariableObject.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSVariableObject.cpp @@ -41,15 +41,15 @@ bool JSVariableObject::deleteProperty(ExecState* exec, const Identifier& propert return JSObject::deleteProperty(exec, propertyName); } -void JSVariableObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +void JSVariableObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, bool includeNonEnumerable) { SymbolTable::const_iterator end = symbolTable().end(); for (SymbolTable::const_iterator it = symbolTable().begin(); it != end; ++it) { - if (!(it->second.getAttributes() & DontEnum)) + if (includeNonEnumerable || !(it->second.getAttributes() & DontEnum)) propertyNames.add(Identifier(exec, it->first.get())); } - JSObject::getPropertyNames(exec, propertyNames); + JSObject::getPropertyNames(exec, propertyNames, includeNonEnumerable); } bool JSVariableObject::getPropertyAttributes(ExecState* exec, const Identifier& propertyName, unsigned& attributes) const diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSVariableObject.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSVariableObject.h index b969da5..84ffe6c 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSVariableObject.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSVariableObject.h @@ -49,7 +49,7 @@ namespace JSC { virtual void putWithAttributes(ExecState*, const Identifier&, JSValue, unsigned attributes) = 0; virtual bool deleteProperty(ExecState*, const Identifier&); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); + virtual void getPropertyNames(ExecState*, PropertyNameArray&, bool includeNonEnumerable = false); virtual bool isVariableObject() const; virtual bool isDynamicScope() const = 0; diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/RegExpMatchesArray.h b/src/3rdparty/webkit/JavaScriptCore/runtime/RegExpMatchesArray.h index 9ae18b9..479a82c 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/RegExpMatchesArray.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/RegExpMatchesArray.h @@ -72,11 +72,11 @@ namespace JSC { return JSArray::deleteProperty(exec, propertyName); } - virtual void getPropertyNames(ExecState* exec, PropertyNameArray& arr) + virtual void getPropertyNames(ExecState* exec, PropertyNameArray& arr, bool includeNonEnumerable = false) { if (lazyCreationData()) fillArrayInstance(exec); - JSArray::getPropertyNames(exec, arr); + JSArray::getPropertyNames(exec, arr, includeNonEnumerable); } void fillArrayInstance(ExecState*); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.cpp index df40691..927ea73 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.cpp @@ -79,12 +79,12 @@ bool StringObject::deleteProperty(ExecState* exec, const Identifier& propertyNam return JSObject::deleteProperty(exec, propertyName); } -void StringObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +void StringObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, bool includeNonEnumerable) { int size = internalValue()->value().size(); for (int i = 0; i < size; ++i) propertyNames.add(Identifier(exec, UString::from(i))); - return JSObject::getPropertyNames(exec, propertyNames); + return JSObject::getPropertyNames(exec, propertyNames, includeNonEnumerable); } bool StringObject::getPropertyAttributes(ExecState* exec, const Identifier& propertyName, unsigned& attributes) const diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.h b/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.h index 0b643a6..8ed038b 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.h @@ -38,7 +38,7 @@ namespace JSC { virtual void put(ExecState* exec, const Identifier& propertyName, JSValue, PutPropertySlot&); virtual bool deleteProperty(ExecState*, const Identifier& propertyName); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); + virtual void getPropertyNames(ExecState*, PropertyNameArray&, bool includeNonEnumerable = false); virtual bool getPropertyAttributes(ExecState*, const Identifier& propertyName, unsigned& attributes) const; virtual const ClassInfo* classInfo() const { return &info; } diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.cpp index 5dfd919..1e4c429 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.cpp @@ -285,7 +285,7 @@ void Structure::materializePropertyMap() } } -void Structure::getEnumerablePropertyNames(ExecState* exec, PropertyNameArray& propertyNames, JSObject* baseObject) +void Structure::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, JSObject* baseObject, bool includeNonEnumerable) { bool shouldCache = propertyNames.shouldCache() && !(propertyNames.size() || m_isDictionary); @@ -297,8 +297,8 @@ void Structure::getEnumerablePropertyNames(ExecState* exec, PropertyNameArray& p clearEnumerationCache(); } - getEnumerableNamesFromPropertyTable(propertyNames); - getEnumerableNamesFromClassInfoTable(exec, baseObject->classInfo(), propertyNames); + getNamesFromPropertyTable(propertyNames, includeNonEnumerable); + getNamesFromClassInfoTable(exec, baseObject->classInfo(), propertyNames, includeNonEnumerable); if (m_prototype.isObject()) { propertyNames.setShouldCache(false); // No need for our prototypes to waste memory on caching, since they're not being enumerated directly. @@ -1008,7 +1008,7 @@ static int comparePropertyMapEntryIndices(const void* a, const void* b) return 0; } -void Structure::getEnumerableNamesFromPropertyTable(PropertyNameArray& propertyNames) +void Structure::getNamesFromPropertyTable(PropertyNameArray& propertyNames, bool includeNonEnumerable) { materializePropertyMapIfNecessary(); if (!m_propertyTable) @@ -1019,7 +1019,8 @@ void Structure::getEnumerableNamesFromPropertyTable(PropertyNameArray& propertyN int i = 0; unsigned entryCount = m_propertyTable->keyCount + m_propertyTable->deletedSentinelCount; for (unsigned k = 1; k <= entryCount; k++) { - if (m_propertyTable->entries()[k].key && !(m_propertyTable->entries()[k].attributes & DontEnum)) { + if (m_propertyTable->entries()[k].key + && (includeNonEnumerable || !(m_propertyTable->entries()[k].attributes & DontEnum))) { PropertyMapEntry* value = &m_propertyTable->entries()[k]; int j; for (j = i - 1; j >= 0 && a[j]->index > value->index; --j) @@ -1046,7 +1047,8 @@ void Structure::getEnumerableNamesFromPropertyTable(PropertyNameArray& propertyN PropertyMapEntry** p = sortedEnumerables.data(); unsigned entryCount = m_propertyTable->keyCount + m_propertyTable->deletedSentinelCount; for (unsigned i = 1; i <= entryCount; i++) { - if (m_propertyTable->entries()[i].key && !(m_propertyTable->entries()[i].attributes & DontEnum)) + if (m_propertyTable->entries()[i].key + && (includeNonEnumerable || !(m_propertyTable->entries()[i].attributes & DontEnum))) *p++ = &m_propertyTable->entries()[i]; } @@ -1065,7 +1067,7 @@ void Structure::getEnumerableNamesFromPropertyTable(PropertyNameArray& propertyN } } -void Structure::getEnumerableNamesFromClassInfoTable(ExecState* exec, const ClassInfo* classInfo, PropertyNameArray& propertyNames) +void Structure::getNamesFromClassInfoTable(ExecState* exec, const ClassInfo* classInfo, PropertyNameArray& propertyNames, bool includeNonEnumerable) { // Add properties from the static hashtables of properties for (; classInfo; classInfo = classInfo->parentClass) { @@ -1078,7 +1080,7 @@ void Structure::getEnumerableNamesFromClassInfoTable(ExecState* exec, const Clas int hashSizeMask = table->compactSize - 1; const HashEntry* entry = table->table; for (int i = 0; i <= hashSizeMask; ++i, ++entry) { - if (entry->key() && !(entry->attributes() & DontEnum)) + if (entry->key() && (includeNonEnumerable || !(entry->attributes() & DontEnum))) propertyNames.add(entry->key()); } } diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h index 866999d..6c5e82f 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h @@ -106,7 +106,7 @@ namespace JSC { return get(propertyName._ustring.rep(), attributes, specificValue); } - void getEnumerablePropertyNames(ExecState*, PropertyNameArray&, JSObject*); + void getPropertyNames(ExecState*, PropertyNameArray&, JSObject*, bool includeNonEnumerable = false); bool hasGetterSetterProperties() const { return m_hasGetterSetterProperties; } void setHasGetterSetterProperties(bool hasGetterSetterProperties) { m_hasGetterSetterProperties = hasGetterSetterProperties; } @@ -121,8 +121,8 @@ namespace JSC { size_t put(const Identifier& propertyName, unsigned attributes, JSCell* specificValue); size_t remove(const Identifier& propertyName); - void getEnumerableNamesFromPropertyTable(PropertyNameArray&); - void getEnumerableNamesFromClassInfoTable(ExecState*, const ClassInfo*, PropertyNameArray&); + void getNamesFromPropertyTable(PropertyNameArray&, bool includeNonEnumerable = false); + void getNamesFromClassInfoTable(ExecState*, const ClassInfo*, PropertyNameArray&, bool includeNonEnumerable = false); void expandPropertyMapHashTable(); void rehashPropertyMapHashTable(); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.cpp index 1bf478b..5a82d09 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.cpp @@ -103,9 +103,9 @@ bool JSDOMWindowShell::deleteProperty(ExecState* exec, const Identifier& propert return m_window->deleteProperty(exec, propertyName); } -void JSDOMWindowShell::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +void JSDOMWindowShell::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, bool includeNonEnumerable) { - m_window->getPropertyNames(exec, propertyNames); + m_window->getPropertyNames(exec, propertyNames, includeNonEnumerable); } bool JSDOMWindowShell::getPropertyAttributes(JSC::ExecState* exec, const Identifier& propertyName, unsigned& attributes) const diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.h b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.h index 6f21892..086bfa0 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.h @@ -70,7 +70,7 @@ namespace WebCore { virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); virtual void putWithAttributes(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, unsigned attributes); virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier& propertyName); - virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&); + virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, bool includeNonEnumerable = false); virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier& propertyName, unsigned& attributes) const; virtual void defineGetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction); virtual void defineSetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp index ad1e556..129a46a 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp @@ -268,12 +268,12 @@ CallType JSQuarantinedObjectWrapper::getCallData(CallData& callData) return CallTypeHost; } -void JSQuarantinedObjectWrapper::getPropertyNames(ExecState*, PropertyNameArray& array) +void JSQuarantinedObjectWrapper::getPropertyNames(ExecState*, PropertyNameArray& array, bool includeNonEnumerable) { if (!allowsGetPropertyNames()) return; - m_unwrappedObject->getPropertyNames(unwrappedExecState(), array); + m_unwrappedObject->getPropertyNames(unwrappedExecState(), array, includeNonEnumerable); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.h b/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.h index bf8fddb..9e54991 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.h @@ -70,7 +70,7 @@ namespace WebCore { virtual bool hasInstance(JSC::ExecState*, JSC::JSValue, JSC::JSValue proto); - virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&); + virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, bool includeNonEnumerable = false); virtual JSC::UString className() const { return m_unwrappedObject->className(); } diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm index 26cf3f5..dd3c10b 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -516,7 +516,7 @@ sub GenerateHeader push(@headerContent, " virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier&);\n") if $dataNode->extendedAttributes->{"CustomDeleteProperty"}; # Custom getPropertyNames function - push(@headerContent, " virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);\n") if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}); + push(@headerContent, " virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, bool includeNonEnumerable = false);\n") if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}); # Custom getPropertyAttributes function push(@headerContent, " virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier&, unsigned& attributes) const;\n") if $dataNode->extendedAttributes->{"CustomGetPropertyAttributes"}; @@ -1334,13 +1334,13 @@ sub GenerateImplementation } if (($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}) && !$dataNode->extendedAttributes->{"CustomGetPropertyNames"}) { - push(@implContent, "void ${className}::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)\n"); + push(@implContent, "void ${className}::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, bool includeNonEnumerable)\n"); push(@implContent, "{\n"); if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}) { push(@implContent, " for (unsigned i = 0; i < static_cast<${implClassName}*>(impl())->length(); ++i)\n"); push(@implContent, " propertyNames.add(Identifier::from(exec, i));\n"); } - push(@implContent, " Base::getPropertyNames(exec, propertyNames);\n"); + push(@implContent, " Base::getPropertyNames(exec, propertyNames, includeNonEnumerable);\n"); push(@implContent, "}\n\n"); } diff --git a/src/3rdparty/webkit/WebCore/bridge/c/c_instance.cpp b/src/3rdparty/webkit/WebCore/bridge/c/c_instance.cpp index fcdd166..cd4db01 100644 --- a/src/3rdparty/webkit/WebCore/bridge/c/c_instance.cpp +++ b/src/3rdparty/webkit/WebCore/bridge/c/c_instance.cpp @@ -238,7 +238,7 @@ JSValue CInstance::valueOf(ExecState* exec) const return stringValue(exec); } -void CInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArray) +void CInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArray, bool includeNonEnumerable) { if (!NP_CLASS_STRUCT_VERSION_HAS_ENUM(_object->_class) || !_object->_class->enumerate) return; diff --git a/src/3rdparty/webkit/WebCore/bridge/c/c_instance.h b/src/3rdparty/webkit/WebCore/bridge/c/c_instance.h index f9e9de3..a7354fd 100644 --- a/src/3rdparty/webkit/WebCore/bridge/c/c_instance.h +++ b/src/3rdparty/webkit/WebCore/bridge/c/c_instance.h @@ -65,7 +65,7 @@ public: virtual bool supportsConstruct() const; virtual JSValue invokeConstruct(ExecState*, const ArgList&); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); + virtual void getPropertyNames(ExecState*, PropertyNameArray&, bool includeNonEnumerable = false); JSValue stringValue(ExecState*) const; JSValue numberValue(ExecState*) const; diff --git a/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp b/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp index 506697a..e5fd8e6 100644 --- a/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp +++ b/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp @@ -222,7 +222,7 @@ void QtInstance::end() // Do nothing. } -void QtInstance::getPropertyNames(ExecState* exec, PropertyNameArray& array) +void QtInstance::getPropertyNames(ExecState* exec, PropertyNameArray& array, bool includeNonEnumerable) { // This is the enumerable properties, so put: // properties diff --git a/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.h b/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.h index 23766b1..8379114 100644 --- a/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.h +++ b/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.h @@ -52,7 +52,7 @@ public: virtual JSValue invokeMethod(ExecState*, const MethodList&, const ArgList&); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); + virtual void getPropertyNames(ExecState*, PropertyNameArray&, bool includeNonEnumerable = false); JSValue stringValue(ExecState* exec) const; JSValue numberValue(ExecState* exec) const; diff --git a/src/3rdparty/webkit/WebCore/bridge/runtime.h b/src/3rdparty/webkit/WebCore/bridge/runtime.h index 2f74a4e..bf24851 100644 --- a/src/3rdparty/webkit/WebCore/bridge/runtime.h +++ b/src/3rdparty/webkit/WebCore/bridge/runtime.h @@ -100,7 +100,7 @@ public: virtual bool supportsConstruct() const { return false; } virtual JSValue invokeConstruct(ExecState*, const ArgList&) { return JSValue(); } - virtual void getPropertyNames(ExecState*, PropertyNameArray&) { } + virtual void getPropertyNames(ExecState*, PropertyNameArray&, bool includeNonEnumerable = false) { } virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const = 0; diff --git a/src/3rdparty/webkit/WebCore/bridge/runtime_object.cpp b/src/3rdparty/webkit/WebCore/bridge/runtime_object.cpp index 385f914..4b9e6ec 100644 --- a/src/3rdparty/webkit/WebCore/bridge/runtime_object.cpp +++ b/src/3rdparty/webkit/WebCore/bridge/runtime_object.cpp @@ -241,7 +241,7 @@ ConstructType RuntimeObjectImp::getConstructData(ConstructData& constructData) return ConstructTypeHost; } -void RuntimeObjectImp::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +void RuntimeObjectImp::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, bool includeNonEnumerable) { if (!instance) { throwInvalidAccessError(exec); @@ -249,7 +249,7 @@ void RuntimeObjectImp::getPropertyNames(ExecState* exec, PropertyNameArray& prop } instance->begin(); - instance->getPropertyNames(exec, propertyNames); + instance->getPropertyNames(exec, propertyNames, includeNonEnumerable); instance->end(); } diff --git a/src/3rdparty/webkit/WebCore/bridge/runtime_object.h b/src/3rdparty/webkit/WebCore/bridge/runtime_object.h index f01fe1e..eb4a20f 100644 --- a/src/3rdparty/webkit/WebCore/bridge/runtime_object.h +++ b/src/3rdparty/webkit/WebCore/bridge/runtime_object.h @@ -44,7 +44,7 @@ public: virtual CallType getCallData(CallData&); virtual ConstructType getConstructData(ConstructData&); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); + virtual void getPropertyNames(ExecState*, PropertyNameArray&, bool includeNonEnumerable = false); virtual void invalidate(); Bindings::Instance* getInternalInstance() const { return instance.get(); } diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index ee5b076..6bf7354 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -367,7 +367,7 @@ public: const JSC::Identifier& propertyName); virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier&, unsigned&) const; - virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&); + virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, bool includeNonEnumerable = false); public: JSC::JSObject *customGlobalObject; @@ -404,8 +404,8 @@ public: virtual bool getPropertyAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, unsigned& attributes) const { return originalGlobalObject->JSC::JSGlobalObject::getPropertyAttributes(exec, propertyName, attributes); } - virtual void getPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames) - { originalGlobalObject->JSC::JSGlobalObject::getPropertyNames(exec, propertyNames); } + virtual void getPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames, bool includeNonEnumerable = false) + { originalGlobalObject->JSC::JSGlobalObject::getPropertyNames(exec, propertyNames, includeNonEnumerable); } private: JSC::JSGlobalObject *originalGlobalObject; }; @@ -712,12 +712,12 @@ bool GlobalObject::getPropertyAttributes(JSC::ExecState* exec, const JSC::Identi return JSC::JSGlobalObject::getPropertyAttributes(exec, propertyName, attributes); } -void GlobalObject::getPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames) +void GlobalObject::getPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames, bool includeNonEnumerable) { if (customGlobalObject) - customGlobalObject->getPropertyNames(exec, propertyNames); + customGlobalObject->getPropertyNames(exec, propertyNames, includeNonEnumerable); else - JSC::JSGlobalObject::getPropertyNames(exec, propertyNames); + JSC::JSGlobalObject::getPropertyNames(exec, propertyNames, includeNonEnumerable); } static JSC::JSValue JSC_HOST_CALL functionPrint(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); diff --git a/src/script/api/qscriptvalueiterator.cpp b/src/script/api/qscriptvalueiterator.cpp index 45486ff..a7642b5 100644 --- a/src/script/api/qscriptvalueiterator.cpp +++ b/src/script/api/qscriptvalueiterator.cpp @@ -116,7 +116,7 @@ public: QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(object.engine()); JSC::ExecState *exec = eng_p->globalExec(); propertyNames = new JSC::PropertyNameArray(exec); - JSC::asObject(QScriptValuePrivate::get(object)->jscValue)->getPropertyNames(exec, *propertyNames); + JSC::asObject(QScriptValuePrivate::get(object)->jscValue)->getPropertyNames(exec, *propertyNames, true); it = propertyNames->begin(); } diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index 512c00e..2a26049 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -179,7 +179,8 @@ bool ClassObjectDelegate::getPropertyAttributes(const QScriptObject* object, JSC } void ClassObjectDelegate::getPropertyNames(QScriptObject* object, JSC::ExecState *exec, - JSC::PropertyNameArray &propertyNames) + JSC::PropertyNameArray &propertyNames, + bool includeNonEnumerable) { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); @@ -192,7 +193,7 @@ void ClassObjectDelegate::getPropertyNames(QScriptObject* object, JSC::ExecState } delete it; } - QScriptObjectDelegate::getPropertyNames(object, exec, propertyNames); + QScriptObjectDelegate::getPropertyNames(object, exec, propertyNames, includeNonEnumerable); } JSC::CallType ClassObjectDelegate::getCallData(QScriptObject*, JSC::CallData &callData) diff --git a/src/script/bridge/qscriptclassobject_p.h b/src/script/bridge/qscriptclassobject_p.h index bafcbcd..61ece04 100644 --- a/src/script/bridge/qscriptclassobject_p.h +++ b/src/script/bridge/qscriptclassobject_p.h @@ -89,7 +89,7 @@ public: const JSC::Identifier&, unsigned&) const; virtual void getPropertyNames(QScriptObject*, JSC::ExecState*, - JSC::PropertyNameArray&); + JSC::PropertyNameArray&, bool includeNonEnumerable = false); virtual JSC::CallType getCallData(QScriptObject*, JSC::CallData&); static JSC::JSValue JSC_HOST_CALL call(JSC::ExecState*, JSC::JSObject*, diff --git a/src/script/bridge/qscriptobject.cpp b/src/script/bridge/qscriptobject.cpp index 8f74a93..65c4754 100644 --- a/src/script/bridge/qscriptobject.cpp +++ b/src/script/bridge/qscriptobject.cpp @@ -132,13 +132,13 @@ bool QScriptObject::getPropertyAttributes(JSC::ExecState* exec, const JSC::Ident return d->delegate->getPropertyAttributes(this, exec, propertyName, attributes); } -void QScriptObject::getPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames) +void QScriptObject::getPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames, bool includeNonEnumerable) { if (!d || !d->delegate) { - JSC::JSObject::getPropertyNames(exec, propertyNames); + JSC::JSObject::getPropertyNames(exec, propertyNames, includeNonEnumerable); return; } - d->delegate->getPropertyNames(this, exec, propertyNames); + d->delegate->getPropertyNames(this, exec, propertyNames, includeNonEnumerable); } void QScriptObject::mark() @@ -217,9 +217,10 @@ bool QScriptObjectDelegate::getPropertyAttributes(const QScriptObject* object, } void QScriptObjectDelegate::getPropertyNames(QScriptObject* object, JSC::ExecState* exec, - JSC::PropertyNameArray& propertyNames) + JSC::PropertyNameArray& propertyNames, + bool includeNonEnumerable) { - object->JSC::JSObject::getPropertyNames(exec, propertyNames); + object->JSC::JSObject::getPropertyNames(exec, propertyNames, includeNonEnumerable); } void QScriptObjectDelegate::mark(QScriptObject* object) diff --git a/src/script/bridge/qscriptobject_p.h b/src/script/bridge/qscriptobject_p.h index e124cbf..17e5e6b 100644 --- a/src/script/bridge/qscriptobject_p.h +++ b/src/script/bridge/qscriptobject_p.h @@ -88,7 +88,7 @@ public: const JSC::Identifier& propertyName); virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier&, unsigned&) const; - virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&); + virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, bool includeNonEnumerable = false); virtual void mark(); virtual JSC::CallType getCallData(JSC::CallData&); virtual JSC::ConstructType getConstructData(JSC::ConstructData&); @@ -142,7 +142,8 @@ public: const JSC::Identifier& propertyName); virtual bool getPropertyAttributes(const QScriptObject*, JSC::ExecState*, const JSC::Identifier&, unsigned&) const; - virtual void getPropertyNames(QScriptObject*, JSC::ExecState*, JSC::PropertyNameArray&); + virtual void getPropertyNames(QScriptObject*, JSC::ExecState*, JSC::PropertyNameArray&, + bool includeNonEnumerable = false); virtual void mark(QScriptObject*); virtual JSC::CallType getCallData(QScriptObject*, JSC::CallData&); virtual JSC::ConstructType getConstructData(QScriptObject*, JSC::ConstructData&); diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index ad43e55..9c15233 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -1490,7 +1490,8 @@ bool QObjectDelegate::getPropertyAttributes(const QScriptObject *object, } void QObjectDelegate::getPropertyNames(QScriptObject *object, JSC::ExecState *exec, - JSC::PropertyNameArray &propertyNames) + JSC::PropertyNameArray &propertyNames, + bool includeNonEnumerable) { QObject *qobject = data->value; if (!qobject) { @@ -1506,7 +1507,7 @@ void QObjectDelegate::getPropertyNames(QScriptObject *object, JSC::ExecState *ex ? meta->propertyOffset() : 0; for ( ; i < meta->propertyCount(); ++i) { QMetaProperty prop = meta->property(i); - if (isEnumerableMetaProperty(prop, meta, i)) { + if (includeNonEnumerable || isEnumerableMetaProperty(prop, meta, i)) { QString name = QString::fromLatin1(prop.name()); propertyNames.add(JSC::Identifier(exec, qtStringToJSCUString(name))); } @@ -1534,7 +1535,7 @@ void QObjectDelegate::getPropertyNames(QScriptObject *object, JSC::ExecState *ex } } - QScriptObjectDelegate::getPropertyNames(object, exec, propertyNames); + QScriptObjectDelegate::getPropertyNames(object, exec, propertyNames, includeNonEnumerable); } void QObjectDelegate::mark(QScriptObject *object) @@ -1768,7 +1769,7 @@ bool QMetaObjectWrapperObject::getPropertyAttributes(JSC::ExecState *exec, return JSC::JSObject::getPropertyAttributes(exec, propertyName, attributes); } -void QMetaObjectWrapperObject::getPropertyNames(JSC::ExecState *exec, JSC::PropertyNameArray &propertyNames) +void QMetaObjectWrapperObject::getPropertyNames(JSC::ExecState *exec, JSC::PropertyNameArray &propertyNames, bool includeNonEnumerable) { const QMetaObject *meta = data->value; if (!meta) @@ -1778,7 +1779,7 @@ void QMetaObjectWrapperObject::getPropertyNames(JSC::ExecState *exec, JSC::Prope for (int j = 0; j < e.keyCount(); ++j) propertyNames.add(JSC::Identifier(exec, e.key(j))); } - JSC::JSObject::getPropertyNames(exec, propertyNames); + JSC::JSObject::getPropertyNames(exec, propertyNames, includeNonEnumerable); } void QMetaObjectWrapperObject::mark() diff --git a/src/script/bridge/qscriptqobject_p.h b/src/script/bridge/qscriptqobject_p.h index 6128c9f..14b426e 100644 --- a/src/script/bridge/qscriptqobject_p.h +++ b/src/script/bridge/qscriptqobject_p.h @@ -106,7 +106,8 @@ public: virtual bool getPropertyAttributes(const QScriptObject*, JSC::ExecState*, const JSC::Identifier&, unsigned&) const; - virtual void getPropertyNames(QScriptObject*, JSC::ExecState*, JSC::PropertyNameArray&); + virtual void getPropertyNames(QScriptObject*, JSC::ExecState*, JSC::PropertyNameArray&, + bool includeNonEnumerable = false); virtual void mark(QScriptObject*); inline QObject *value() const { return data->value; } @@ -293,7 +294,8 @@ public: const JSC::Identifier& propertyName); virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier&, unsigned&) const; - virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&); + virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, + bool includeNonEnumerable = false); virtual void mark(); virtual JSC::CallType getCallData(JSC::CallData&); diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 1f7a857..7b019c1 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -1046,17 +1046,17 @@ void tst_QScriptEngine::globalObjectProperties() actualNames.insert(it.name()); } } + QSet remainingNames = actualNames; { QSet::const_iterator it; for (it = expectedNames.constBegin(); it != expectedNames.constEnd(); ++it) { QString name = *it; - if (!actualNames.contains(name)) - QEXPECT_FAIL("", "JSC getPropertyNames() doesn't include DontEnum properties", Abort); QVERIFY(actualNames.contains(name)); remainingNames.remove(name); } } + QEXPECT_FAIL("", "JSC global object has extra properties (JSON and jscprint)", Abort); QVERIFY(remainingNames.isEmpty()); } -- cgit v0.12