aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Don't check for revisions when assigning to grouped propertiesLars Knoll2016-01-271-0/+9
| | | | | | | | | | This leads to wrong behavior in some cases, where we reject valid revisions, and there is probably no case, where this could lead to a conflict for the user of the API. Change-Id: I1614332cf4c07c6a227551612331dd69b2ae71f3 Task-number: QTBUG-40043 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Provide a threaded TestHTTPServerUlf Hermann2015-10-141-3/+1
| | | | | | | | | This allows us to do blocking operations that interact with the test server in the main thread. The threaded server is used in tests that don't explicitly require asynchronous operation. Change-Id: Ibcb28e79a1114cb9cfb812e86aae0a1af71c569e Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Tests: Fix single-character string literals.Friedemann Kleint2015-10-131-1/+1
| | | | | | | | Use character literals where applicable. Change-Id: Ib0e618752fbc762a73a0a91c43efab61ef2c9687 Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanups to property allocation in the VMEMOLars Knoll2015-09-251-0/+2
| | | | | | | | There's no need for a separate propertiesAllocated bool, we can keep that state in the WeakValue itself. Change-Id: Ife0f517bee9bc5830680eec68983767379a3c2cf Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* V4: Fix SparseArray::deleteNodeRon Hashimoto2015-09-251-0/+11
| | | | | | | | | SparseArray::deleteNode should modify size_left only if the deleted node had a right child Change-Id: I0f3504a5c6568dbd9e392bf83eaf3f9780eb2b84 Task-number: QTBUG-46022 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup qmlcontextwrapper usage in XHRLars Knoll2015-08-201-3/+3
| | | | | | | | | | | | | | | Get rid of the static getContext overload and simplify the signature of the dispatchCallback method in XHR. Get rid of the m_me object, and instead store a pointer to the thisObject and the context data directly. Turn all internal errors into assertions. Change-Id: I5427b2009c64f54b67cce1c130eace47201624bd Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Fix test caseLars Knoll2015-08-181-2/+3
| | | | | | | | After the latest changes to the VMEMO, JS declared properties will not be available after the engine is deleted. Change-Id: Ifc6034bd0dff18d26863ca9bcf7a19e1c7d68ff6 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of special handling of var propertiesLars Knoll2015-08-181-0/+6
| | | | | | | | | | | | These can be handled in a simple way now by using a special propertyType value indicating that we have a var property. Also remove the additional write calls in the different readProperty implementations. If the stored data doesn't match, we can simply return the default value directly. Change-Id: I3823a971df24bd78f0acdc4c0042776277b3c55f Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* tests/qml: Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b).Friedemann Kleint2015-07-291-49/+49
| | | | | | | | | | | | - Replace Q[TRY]_VERIFY(pointer == 0) by Q[TRY]_VERIFY(!pointer). - Replace Q[TRY]_VERIFY(smartPointer == 0) by Q[TRY]_VERIFY(smartPointer.isNull()). - Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b) and add casts where necessary. The values will then be logged should a test fail. Change-Id: I8cc97fd9b48fc789a849e9527c292c4e05accd97 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
* Tests: Replace Q[TRY]_VERIFY(v == true|false) by QVERIFY(v)|QVERIFY(!v).Friedemann Kleint2015-07-271-18/+18
| | | | | | | | Preparing the replacement of Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b) for non-boolean types. Change-Id: I8a4e44a2b4e20a9c8b811799e3932c8ce1a2cbbb Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.4' into 5.5Simon Hausmann2015-04-271-6/+10
|\ | | | | | | | | | | | | | | Conflicts: .qmake.conf tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp Change-Id: I715b8a78b74cbe0dcaf599367fd6e08af4858e11
| * Prospective fix for flakey "network" related QML testsv5.4.2Simon Hausmann2015-04-251-6/+10
| | | | | | | | | | | | | | Replace hard-coded server ports with dynamically allocated ports. Change-Id: Iab8f9a88343a9f2c49af3cd700c954c13c3bf121 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
* | Don't evaluate the expression in switch() multiple timesLars Knoll2015-03-111-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | The old code would evaluate the expression in the switch statement once for every case label. This is not only slower than it should be, but can also lead to unexpected results in case the expression doesn't always evaluate to the same value or has side effects. Task-number: QTBUG-41630 Change-Id: Id93baca7e3aa09ce884967ef6524d4c4f055bcd6 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* | CleanupsLars Knoll2015-01-231-1/+1
| | | | | | | | | | | | | | | | Remove duplicated methods. Remove some mostly unused methods, and simplify some others. Change-Id: I605b249e54417bb32c3dfc8e22f2c8b6b684a1e1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove all remaining usages of ValueRefLars Knoll2015-01-231-4/+4
| | | | | | | | | | Change-Id: Icd76d3d03fac2e57530e55f8ec15b97109dcdcbc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Get rid of most uses of ValueRefLars Knoll2015-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Instead pass a const Value & into the functions With our new inheritance structure, we can get rid of ValueRef and instead simply pass a pointer to a Value again. Pointers to Values are safe to use again now, as they are now guaranteed to be in a place where the GC knows about them. Change-Id: I44c606fde764db3993b8128fd6fb781d3a298e53 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Merge remote-tracking branch 'origin/5.4' into devSimon Hausmann2015-01-161-1/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4debugging.cpp src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4functionobject_p.h src/qml/jsruntime/qv4qobjectwrapper.cpp src/quick/scenegraph/shaders/visualization.frag tests/auto/qml/qjsengine/tst_qjsengine.cpp Change-Id: I492e8546c278f80a300a2129e9a29d861e144a30
| * Parse dates as Qt::RFC2822Date tooAlbert Astals Cid2015-01-081-1/+2
| | | | | | | | | | | | | | | | [ChangeLog][QtQml] Fix JavaScript Date parsing to correctly accept RC2822 dates. Task-number: QTBUG-38011 Change-Id: Ic7d3f5b8c624d6780d4c3595fd2efe22c427ffd3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Make sure we always have an engine when assigning to a PersistentLars Knoll2015-01-131-3/+4
| | | | | | | | | | | | | | This prepares things for a rewrite of the internals of Persistent. Change-Id: Ib93ec5911984d1bfce87ffdc3f86bc75f6ecafe9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Cleanup variant conversion codeLars Knoll2015-01-091-1/+1
| | | | | | | | | | | | | | | | Make public methods proper members of the ExecutionEngine, and move private methods into the .cpp file only. Change-Id: I3ca49e39bb1c4e559a2c63346e6ae6cfa446147d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Move the variant conversion methods from qv8engine to qv4::ExecutionEngineLars Knoll2015-01-091-1/+1
| | | | | | | | | | Change-Id: Ibd529ae5cc3ba06f46152e9daa9119a4e7a2561c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Clean up JS .import/.pragma directive scanningSimon Hausmann2015-01-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | There's a scanner in QQmlJS::Lexer::scanDirectives that can parse those, so let's get rid of extra parser that operates on a string. Instead this way we can do the scanning all in one shot, avoid detaching a copy of the source code string and (most importantly) bring the parser closer to the copy in Qt Creator, which uses the directives approach to extract imports and pragma. Change-Id: Iff6eb8d91a45d8a70f383f953115692be48259de Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
* | Remove qv8engine usage in the contextwrapperLars Knoll2015-01-081-1/+1
| | | | | | | | | | Change-Id: Iaf807add5d971e96cac57e38e13385e901f9c930 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Get rid of QV8Engine::toStringLars Knoll2015-01-081-1/+1
| | | | | | | | | | Change-Id: Ib51fa09ae251c1b7b8878ecdf920016f8fcc0067 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Use QV4::ScopedFunctionObject typedef instead of actual typeOleg Shparber2015-01-021-3/+3
| | | | | | | | | | Change-Id: I6b4effaa5bef992b4ae9402eea7fe655bc7b18f0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove v8engine dependency in toVariant conversionsLars Knoll2015-01-021-1/+1
| | | | | | | | | | Change-Id: I0f2f77c9cc268a0c5ca3ffe0cd66fc98bb1964b3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Return Heap::ExecutionContext for globalContext()Lars Knoll2014-12-191-7/+5
| | | | | | | | | | Change-Id: Ide7c81735be4662ff45bf268cfe750ff1f784453 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Read and write QObject pointer properties in QML without registration.Mitch Curtis2014-12-131-1/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, accessing QObject pointer properties from QML would require these types to be registered with qRegisterMetaType(), but this shouldn't be necessary if we're able to read/write the property, because the moc generates code that calls qRegisterMetaType in the static meta-call implementation. So when resolving a property in the property cache and we can't resolve, fall back to placing the static meta-call to register the type, similar to what QMetaType::userType() does. Change-Id: Ic8b00ed93a1e5e42cf7aaaf1c355e89557485c59 Reviewed-by: Christopher Adams <chris.adams@jollamobile.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* | Revert "Properly handle negative years when printing JS Dates to strings."Ulf Hermann2014-12-121-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f06daaf3d8747c6c0a277bf055c80d8f2e7bcc81. The only things actually specified by the ECMAScript standard on dates are: 1. Reparsing a date output from any of the to*String() functions has to result in the same date representation. 2. The ISO 8601 standard has to be followed for the ISO format. Currently we clearly don't follow rule 1. Date.parse(d.toString()) will not yield the same as d.valueOf() for negative dates. The ISO 8601 standard clearly has a year 0 while common human language has not. All non ISO date representations are considered "implementation-dependent" in the ECMAScript standard. We can thus define the relation between our representations and the ISO standard any way we like. If we try to match up the dates so that the negative years look equal in each representation we cannot properly interact with QDate for dates in the year 0 as that doesn't exist in QDate. We can, however, choose not to make the dates look equal. That means a date with a negative year will be "one off" when represented in ISO 8601. "333 BC" in human language is "-332" in ISO 8601. Our internal representation is aligned to ISO 8601 and the to*String() methods may output something else. That means we can easily set the year in ISO 8601 sense from the Date constructor as well as from setYear() and setFullYear(). This, of course, is somewhat unintuitive and also differs from most other JavaScript implementations (which don't have to interoperate with QDate). However, it is still correct. Change-Id: I5fc26b709a486cb520a075918b184a80bec56c9b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Encapsulate accesses to the root contextLars Knoll2014-12-111-3/+3
| | | | | | | | | | Change-Id: I668cef1363a5c1a5c5b9a7e138f3bd0338712eea Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove the executioncontext in a few more places where it's not neededLars Knoll2014-11-211-7/+4
| | | | | | | | | | Change-Id: I4c92c7bc9d94d8265e306f45d863fdc080a5e2a6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Change test data from 6.7 to 6.5Thiago Macieira2014-11-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 6.5 is an exact binary number (4 + 2 + 0.5), so all conversions to string will result in "6.5", regardless of how many digits of precision are used. This is done in advance of changing QVariant to add more digits of precision, which would cause toString() of 6.7 to result in "6.7000000000000002". Change-Id: I19ea4c5bb02b99f0655c0b9bc9dc09f06ec654e5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Cleanup exception catching codeLars Knoll2014-11-151-6/+6
| | | | | | | | | | Change-Id: I85afd5758f72e19c280dc196601ee145f0c25f01 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Cleanup header file dependenciesLars Knoll2014-11-041-0/+1
|/ | | | | Change-Id: Ibb4658576a98b53de2eac2474ce4d5b9eb83b6ae Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Properly handle negative years when printing JS Dates to strings.Ulf Hermann2014-10-241-0/+17
| | | | | | | | | | JavaScript knows a year 0. That is correctly translated into QDateTime terms when creating a Date object, but it's not correctly translated back when converting the JavaScript date to a string. Task-number: QTBUG-29491 Change-Id: I46b200a144434187656d08e87f422f97523acd0e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix mapping of JS objects/arrays to C++Simon Hausmann2014-09-171-10/+10
| | | | | | | | | | | | | | | [ChangeLog][QtQml][Important Behavior Changes] When a JavaScript object/array is passed to C++ through a QVariant, the engine no longer immediately converts the object recursively into a QVariantMap or QVariantList but instead stores a QJSValue in the QVariant. This prevents a loss of data when the JS object contains non-primitive types such as function objects for example. Code that expects the variant type to be exactly QVariant::Map or QVariant::List may need to be adapted. Registered conversion functions however ensure that code that merely calls toMap() or toList() continues to work. Task-number: QTBUG-40431 Change-Id: I1dbc1d5f8e78ad28bb62db3681b9a0b34557e7f5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix setUTCXxx methods in DateLars Knoll2014-09-111-0/+16
| | | | | | | | | The methods where converting doing a localtime->UTC conversion even though the input was already in UTC. Task-number: QTBUG-38448 Change-Id: I4409275fade0dd2a677af2293edc87445f853879 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix roundtrip conversion between JS var and QVariantLars Knoll2014-09-111-0/+24
| | | | | | | | | | | | | | Always convert null to a QVariant(VoidStar) as documented in QJSValue. Make sure the reverse conversion will lead back to a null JS value. Adjusted two test cases that expected an invalid QVariant when setting the property to null, and added test cases for the correct conversion. Task-number: QTBUG-40880 Change-Id: I6eb01f0067f2c89779c53fd2cd0a1193047ed2cc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Merge remote-tracking branch 'origin/5.3' into 5.4Simon Hausmann2014-09-081-0/+11
|\ | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/qml/jsruntime/qv4arraydata.cpp src/quick/scenegraph/util/qsgatlastexture.cpp Change-Id: Ic4c96066d5c37dcf0d5446baed590ea005d445ce
| * QML: parse .js files as JavaScript, not QML.Erik Verbruggen2014-09-051-0/+11
| | | | | | | | | | | | | | | | | | When importing a JS library into a QML file with the "import" keyword, that JS file was parsed in QML mode, disallowing QML keywords like "as". Task-number: QTBUG-40143 Change-Id: Ie98adceb27544732c2e96657d41170db36bff288 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | | | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* | Merge remote-tracking branch 'origin/5.3' into 5.4Simon Hausmann2014-08-121-0/+17
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4include.cpp src/quick/items/qquickrendercontrol.cpp src/quick/items/qquickrendercontrol_p.h src/quickwidgets/qquickwidget.cpp Change-Id: Ib2dc0051a38cd283a37a7665eb4a76f6f7ec8b15
| * Fix Qt.include with cached compilation units and resourcesSimon Hausmann2014-08-061-0/+17
| | | | | | | | | | | | | | | | | | Similar to the worker scripts we also need to do a lookup for cached scripts here. Added also a test to ensure that Qt.include works correctly from Qt resources. Change-Id: Idb67af3da4b0cc91edbd3d2746d074fd68ed8bf0 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | V4: change string flattening to be iterative and use a worklist.Erik Verbruggen2014-08-081-0/+25
| | | | | | | | | | | | | | | | And not recursive, because that might blow out of stack space. Task-number: QTBUG-39520 Change-Id: Id961d4af03a543d3efa173f976626cf2dae4f483 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Merge remote-tracking branch 'origin/5.3' into devFrederik Gladhorn2014-07-291-0/+28
|\| | | | | | | Change-Id: Id95f7b01de36bccecbb7b73acc041654a1fe2ebe
| * Fix interaction of garbage collector with JS objects during QML type ↵Simon Hausmann2014-07-261-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instantiation It may happen that during the lengthy process of instantiating a tree of objects for QML, the garbage collector runs. For objects created by QML we support different ownership models, for example in QtQuick visual parents keep their visual children alive, despite perhaps a lack of QObject parentship. That ownership becomes active once the QML autoparent function has assigned the correct visual parent, which happens after object instantiation (after QQmlObjectCreator). Similarly when a composite type is created, its QObject parent is only set after all properties have been set. The root QObject is kept alive through a special boolean, but if the sub-objects aren't children yet, their JS wrapper might get deleted. For composite types with var properties, that also means their var properties get deleted, such as the model property of TableView.qml in the bug report. In the future we want to support creating QWidget hierarchies with QML, which also for layouts may rely on a delayed parent assignment for layouts. To accommodate all this, this patch introduces an array on the JS stack that keeps track of all JS wrappers for all QObjects created. This array is alive during object tree creation. Afterwards, the different ownership models take over, for example the auto parent function assigning a visual parent. This patch also fixes an off-by-one in the total object count calculation for composite types, where when instantiating a composite type as a sub-object we counted the sub composite's object count but forgot the object itself. Task-number: QTBUG-38835 Task-number: QTBUG-39966 Change-Id: I6104b2434510642081e0c54793ed296adeca7481 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | qmlRegisterCustomExtendedType, qmlRegisterExtendedUncreatableTypePaul Lemire2014-07-251-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are cases in Qt3D where we'd like to be able to register uncreatable extended types. The main use case is having an abstract class that has an extension class so as to have a clean separation between the C++ and QML API. Implementations of the abstract can then be easily registered to QML and rely on the extension class for QML specific properties. The other feature we'll need in the near future is the ability to create extended QML types that use a custom parser. Two new type registration method were added to qqml.h to fulfill those needs. Unit tests for those are present in qqmlecmascript and qqmllanguage. Change-Id: I15b2cd791ffd36b537305af1873491c079d4094e Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove unused methodLars Knoll2014-07-221-1/+1
| | | | | | | | | | Change-Id: I3830de8c4f01cc7340ab37673024ceea93585a9e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Allow integer values to be assigned QList<qreal> propertiesOleg Shparber2014-06-251-4/+4
| | | | | | | | | | | | | | | | Before this patch it was not possible to assign an integer value to QList<qreal> property, while it worked for non-list properties. Change-Id: Iab00288f7d78f4f76056ab4291700d7f51626de4 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>