diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-03-15 16:40:36 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-04-26 20:26:56 +0000 |
commit | 7e854bc568b662a068a1aea60da03653bc08a235 (patch) | |
tree | 7bee92ba2c7837f0837cc698fa2e3cbe44d5f201 | |
parent | c68dc99c92480b7794d4866602fc8a6fb0439a7a (diff) |
Clean up handling of the 'caller' property
This brings it closer in line with the ES8 spec. Also
remove a couple of tests testing the 'caller' property
of non strict functions, as it's not mandated by the
spec and we never set it.
Change-Id: Icece8a03989c474df1eae0e4e77b356e49575b32
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/qml/jsruntime/qv4argumentsobject.cpp | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4argumentsobject_p.h | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 9 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 9 | ||||
-rw-r--r-- | tests/auto/qml/ecmascripttests/TestExpectations | 6 | ||||
-rwxr-xr-x | tests/auto/qml/ecmascripttests/test262.py | 5 |
6 files changed, 12 insertions, 23 deletions
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 075e7afd8a..de00ac8984 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -75,11 +75,8 @@ void Heap::StrictArgumentsObject::init(QV4::CppStackFrame *frame) Object::init(); Q_ASSERT(CalleePropertyIndex == internalClass->find(v4->id_callee())); - Q_ASSERT(CallerPropertyIndex == internalClass->find(v4->id_caller())); setProperty(v4, CalleePropertyIndex + QV4::Object::GetterOffset, *v4->thrower()); setProperty(v4, CalleePropertyIndex + QV4::Object::SetterOffset, *v4->thrower()); - setProperty(v4, CallerPropertyIndex + QV4::Object::GetterOffset, *v4->thrower()); - setProperty(v4, CallerPropertyIndex + QV4::Object::SetterOffset, *v4->thrower()); Scope scope(v4); Scoped<QV4::StrictArgumentsObject> args(scope, this); diff --git a/src/qml/jsruntime/qv4argumentsobject_p.h b/src/qml/jsruntime/qv4argumentsobject_p.h index d163bbaf88..9264f938e2 100644 --- a/src/qml/jsruntime/qv4argumentsobject_p.h +++ b/src/qml/jsruntime/qv4argumentsobject_p.h @@ -95,8 +95,7 @@ DECLARE_HEAP_OBJECT(ArgumentsObject, Object) { DECLARE_HEAP_OBJECT(StrictArgumentsObject, Object) { enum { LengthPropertyIndex = 0, - CalleePropertyIndex = 1, - CallerPropertyIndex = 3 + CalleePropertyIndex = 1 }; void init(CppStackFrame *frame); }; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index dc9a37b406..10030a14e4 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -270,8 +270,7 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine) classes[Class_ArgumentsObject] = argsClass->addMember(id_callee(), Attr_Data|Attr_NotEnumerable); argsClass = newInternalClass(StrictArgumentsObject::staticVTable(), objectPrototype()); argsClass = argsClass->addMember(id_length(), Attr_NotEnumerable); - argsClass = argsClass->addMember(id_callee(), Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); - classes[Class_StrictArgumentsObject] = argsClass->addMember(id_caller(), Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); + classes[Class_StrictArgumentsObject] = argsClass->addMember(id_callee(), Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); *static_cast<Value *>(globalObject) = newObject(); Q_ASSERT(globalObject->d()->vtable()); @@ -490,6 +489,12 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine) ScopedString name(scope, newString(QStringLiteral("thrower"))); jsObjects[ThrowerObject] = FunctionObject::createBuiltinFunction(global, name, ::throwTypeError); + + ScopedProperty pd(scope); + pd->value = thrower(); + pd->set = thrower(); + functionPrototype()->insertMember(id_caller(), pd, Attr_Accessor|Attr_ReadOnly_ButConfigurable); + functionPrototype()->insertMember(id_arguments(), pd, Attr_Accessor|Attr_ReadOnly_ButConfigurable); } ExecutionEngine::~ExecutionEngine() diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 390e0d5161..1a26fc857c 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -277,7 +277,6 @@ void FunctionPrototype::init(ExecutionEngine *engine, Object *ctor) defineDefaultProperty(QStringLiteral("apply"), method_apply, 2); defineDefaultProperty(QStringLiteral("call"), method_call, 1); defineDefaultProperty(QStringLiteral("bind"), method_bind, 1); - } ReturnedValue FunctionPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int) @@ -424,14 +423,6 @@ void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function f->init(name, true); Q_ASSERT(internalClass && internalClass->find(s.engine->id_length()) == Index_Length); setProperty(s.engine, Index_Length, Primitive::fromInt32(f->formalParameterCount())); - - if (function->isStrict()) { - ScopedProperty pd(s); - pd->value = s.engine->thrower(); - pd->set = s.engine->thrower(); - f->insertMember(s.engine->id_caller(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); - f->insertMember(s.engine->id_arguments(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); - } } Heap::InternalClass *ScriptFunction::classForConstructor() const diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations index e862d36dc8..73dc62afd3 100644 --- a/tests/auto/qml/ecmascripttests/TestExpectations +++ b/tests/auto/qml/ecmascripttests/TestExpectations @@ -835,8 +835,6 @@ built-ins/Function/prototype/bind/instance-name-chained built-ins/Function/prototype/bind/instance-name-non-string built-ins/Function/prototype/bind/proto-from-ctor-realm built-ins/Function/prototype/name -built-ins/Function/prototype/restricted-property-arguments -built-ins/Function/prototype/restricted-property-caller built-ins/Function/prototype/Symbol.hasInstance/length built-ins/Function/prototype/Symbol.hasInstance/name built-ins/Function/prototype/Symbol.hasInstance/prop-desc @@ -895,7 +893,6 @@ built-ins/Function/prototype/toString/setter-class-statement-static built-ins/Function/prototype/toString/setter-object built-ins/Function/prototype/toString/symbol-named-builtins built-ins/Function/prototype/toString/unicode -built-ins/Function/StrictFunction_restricted-properties built-ins/GeneratorFunction/extensibility built-ins/GeneratorFunction/has-instance built-ins/GeneratorFunction/instance-construct-throws @@ -2854,7 +2851,6 @@ built-ins/ThrowTypeError/extensible built-ins/ThrowTypeError/frozen built-ins/ThrowTypeError/length built-ins/ThrowTypeError/name -built-ins/ThrowTypeError/unique-per-realm-function-proto built-ins/TypedArray/from/arylk-get-length-error built-ins/TypedArray/from/arylk-to-length-error built-ins/TypedArray/from/invoked-as-func @@ -4129,7 +4125,6 @@ language/expressions/array/spread-sngl-empty language/expressions/array/spread-sngl-expr language/expressions/array/spread-sngl-iter language/expressions/array/spread-sngl-literal -language/expressions/arrow-function/ArrowFunction_restricted-properties language/expressions/arrow-function/cannot-override-this-with-thisArg language/expressions/arrow-function/dflt-params-abrupt language/expressions/arrow-function/dflt-params-ref-later @@ -8873,7 +8868,6 @@ language/statements/function/dstr-obj-ptrn-prop-ary-init language/statements/function/dstr-obj-ptrn-prop-eval-err language/statements/function/length-dflt language/statements/function/param-dflt-yield-non-strict -language/statements/function/params-dflt-ref-arguments language/statements/function/params-trailing-comma-multiple language/statements/function/params-trailing-comma-single language/statements/function/S13_A15_T4 diff --git a/tests/auto/qml/ecmascripttests/test262.py b/tests/auto/qml/ecmascripttests/test262.py index 59e642e575..19551e3ba2 100755 --- a/tests/auto/qml/ecmascripttests/test262.py +++ b/tests/auto/qml/ecmascripttests/test262.py @@ -84,7 +84,10 @@ excludedFeatures = [ "string-trimming", "String.prototype.trimEnd", "String.prototype.trimStart", - "numeric-separator-literal" + "numeric-separator-literal", + + # optional features, not supported by us + "caller" ] # ############# Helpers needed for parallel multi-process test execution ############ |