aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/jsruntime/qv4module.cpp24
-rw-r--r--src/qml/jsruntime/qv4module_p.h1
-rw-r--r--src/qml/jsruntime/qv4reflect.cpp4
-rw-r--r--src/qml/jsruntime/qv4typedarray.cpp7
-rw-r--r--src/qml/jsruntime/qv4typedarray_p.h1
-rw-r--r--tests/auto/qml/ecmascripttests/TestExpectations5
6 files changed, 32 insertions, 10 deletions
diff --git a/src/qml/jsruntime/qv4module.cpp b/src/qml/jsruntime/qv4module.cpp
index c892749a11..6b15637d49 100644
--- a/src/qml/jsruntime/qv4module.cpp
+++ b/src/qml/jsruntime/qv4module.cpp
@@ -109,8 +109,12 @@ ReturnedValue Module::virtualGet(const Managed *m, PropertyKey id, const Value *
const Value *v = module->d()->unit->resolveExport(expectedName);
if (hasProperty)
*hasProperty = v != nullptr;
- if (!v || v->isEmpty())
+ if (!v)
return Encode::undefined();
+ if (v->isEmpty()) {
+ ScopedValue propName(scope, id.toStringOrSymbol(scope.engine));
+ return scope.engine->throwReferenceError(propName);
+ }
return v->asReturnedValue();
}
@@ -129,10 +133,26 @@ PropertyAttributes Module::virtualGetOwnProperty(Managed *m, PropertyKey id, Pro
return Attr_Invalid;
}
if (p)
- p->value = v->asReturnedValue();
+ p->value = v->isEmpty() ? Encode::undefined() : v->asReturnedValue();
+ if (v->isEmpty()) {
+ ScopedValue propName(scope, id.toStringOrSymbol(scope.engine));
+ scope.engine->throwReferenceError(propName);
+ }
return Attr_Data | Attr_NotConfigurable;
}
+bool Module::virtualHasProperty(const Managed *m, PropertyKey id)
+{
+ if (id.isSymbol())
+ return Object::virtualHasProperty(m, id);
+
+ const Module *module = static_cast<const Module *>(m);
+ Scope scope(m->engine());
+ ScopedString expectedName(scope, id.toStringOrSymbol(scope.engine));
+ const Value *v = module->d()->unit->resolveExport(expectedName);
+ return v != nullptr;
+}
+
bool Module::virtualPreventExtensions(Managed *)
{
return true;
diff --git a/src/qml/jsruntime/qv4module_p.h b/src/qml/jsruntime/qv4module_p.h
index bb004b3b44..073e0d1e54 100644
--- a/src/qml/jsruntime/qv4module_p.h
+++ b/src/qml/jsruntime/qv4module_p.h
@@ -77,6 +77,7 @@ struct Q_QML_EXPORT Module : public Object {
static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
static PropertyAttributes virtualGetOwnProperty(Managed *m, PropertyKey id, Property *p);
+ static bool virtualHasProperty(const Managed *m, PropertyKey id);
static bool virtualPreventExtensions(Managed *);
static bool virtualDefineOwnProperty(Managed *, PropertyKey, const Property *, PropertyAttributes);
static bool virtualPut(Managed *, PropertyKey, const Value &, Value *);
diff --git a/src/qml/jsruntime/qv4reflect.cpp b/src/qml/jsruntime/qv4reflect.cpp
index 3dc0956e0c..766a0c4592 100644
--- a/src/qml/jsruntime/qv4reflect.cpp
+++ b/src/qml/jsruntime/qv4reflect.cpp
@@ -200,9 +200,7 @@ ReturnedValue Reflect::method_has(const FunctionObject *f, const Value *, const
if (scope.engine->hasException)
return false;
- bool hasProperty = false;
- (void) o->get(name, nullptr, &hasProperty);
- return Encode(hasProperty);
+ return Encode(o->hasProperty(name));
}
ReturnedValue Reflect::method_isExtensible(const FunctionObject *f, const Value *, const Value *argv, int argc)
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp
index 7606af80cb..7492f8872d 100644
--- a/src/qml/jsruntime/qv4typedarray.cpp
+++ b/src/qml/jsruntime/qv4typedarray.cpp
@@ -467,6 +467,13 @@ ReturnedValue TypedArray::virtualGet(const Managed *m, PropertyKey id, const Val
return a->d()->type->read(a->d()->buffer->data->data() + byteOffset);
}
+bool TypedArray::virtualHasProperty(const Managed *m, PropertyKey id)
+{
+ bool hasProperty = false;
+ virtualGet(m, id, nullptr, &hasProperty);
+ return hasProperty;
+}
+
bool TypedArray::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
{
if (!id.isArrayIndex())
diff --git a/src/qml/jsruntime/qv4typedarray_p.h b/src/qml/jsruntime/qv4typedarray_p.h
index d29599f31e..909334adb0 100644
--- a/src/qml/jsruntime/qv4typedarray_p.h
+++ b/src/qml/jsruntime/qv4typedarray_p.h
@@ -166,6 +166,7 @@ struct Q_QML_PRIVATE_EXPORT TypedArray : Object
using Object::get;
static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+ static bool virtualHasProperty(const Managed *m, PropertyKey id);
static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
};
diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations
index fd372abaf1..9a7e09ca3c 100644
--- a/tests/auto/qml/ecmascripttests/TestExpectations
+++ b/tests/auto/qml/ecmascripttests/TestExpectations
@@ -1051,13 +1051,8 @@ language/global-code/script-decl-var.js fails
language/identifiers/other_id_continue.js fails
language/identifiers/other_id_start-escaped.js fails
language/identifiers/other_id_start.js fails
-language/module-code/namespace/internals/delete-exported-uninit.js strictFails
language/module-code/namespace/internals/enumerate-binding-uninit.js strictFails
-language/module-code/namespace/internals/get-own-property-str-found-uninit.js strictFails
-language/module-code/namespace/internals/get-str-found-uninit.js strictFails
-language/module-code/namespace/internals/object-hasOwnProperty-binding-uninit.js strictFails
language/module-code/namespace/internals/object-keys-binding-uninit.js strictFails
-language/module-code/namespace/internals/object-propertyIsEnumerable-binding-uninit.js strictFails
language/statements/async-function/cptn-decl.js fails
language/statements/async-function/declaration-returns-promise.js fails
language/statements/async-function/evaluation-body.js fails