summaryrefslogtreecommitdiff
path: root/tests/auto/webchannel/tst_webchannel.h
Commit message (Collapse)AuthorAgeFilesLines
* Allow deleting a channel during method invocationJüri Valdmann2018-01-081-1/+12
| | | | | | | | | | | | | A real-life use case is the session restore page in KDE Falkon or, more generally, any kind of closeTab() method exposed to JS in a QWebEnginePage. The approach taken in this patch will only work if the transport can also deal with deletion during a messageReceived signal emission. Alternatively, method invocation could be delayed via the event loop, but this would come with an obvious performance penalty. Change-Id: I2940f61e07c77365f6e3e7cd29463d4cb5b525a6 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Do not crash on non-QVariant return typesMilian Wolff2017-08-081-7/+8
| | | | | | | | | | | | | Patch e354bdc5 introduced a regression that triggers a crash in Qt 5.9 when returning a type that is not implicitly convertible to QVariant, such as a QJsonValue, from an invoked method/slot. This patch fixes this situation and adds proper unit test coverage. Change-Id: Ib8cb0c96e7496bc8dc9a628245d7a44e4234aff0 Task-number: QTBUG-62045 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> Reviewed-by: Kai Dohmen <psykai1993@googlemail.com>
* Gracefully handle early deregistration of objectsMilian Wolff2017-05-151-0/+1
| | | | | | | | | | | When an object is deregistered before the signal handler got initializated, we asserted. Now, we check for this case and skip the signal handler removal when it wasn't set up yet. Change-Id: I7abad204cbab72be7729d42f58ce63babd2310d8 Task-number: QTBUG-60250 Reviewed-by: Kai Dohmen <psykai1993@googlemail.com> Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-10-011-0/+13
|\ | | | | | | Change-Id: Ib8b5300d27583018bc7582be41140dfda0ab5309
| * Fix asynchronous signals from QObjects in different threadsDave Andrews2016-09-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switches the signal listener in QWebChannel from using Qt::DirectConnection to Qt::AutoConnection to relay signals from QObjects in different affinities than the QWebChannel. Also adds a unit test in testAsyncObject() to verify that QWebChannel no longer crashes when receiving such a signal, and that such objects can be added and removed dynamically. Task-number: QTBUG-51366 Change-Id: I51a4886286fec9257a21ea95360c1ea8889a584a Reviewed-by: Dave Andrews <jetdog330@hotmail.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
| * Fix asynchronous method calls on QObjects in different threadsDave Andrews2016-09-291-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use QMetaMethod::invoke without a return for void method calls, which allows making asynchronous method calls onto QObjects in different affinities than the QWebChannel that's emitting them. Also adds a unit test called testAsyncObject that intentionally places a QObject in a different affinity and then tests calls into it from the QWebChannel's synchronous publisher. Task-number: QTBUG-47678 Change-Id: I6c35ee54f764c0fc1b0431fb0774aa7e75039abf Reviewed-by: Dave Andrews <jetdog330@hotmail.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-011-0/+2
|\ \ | |/ | | | | Change-Id: If2a4f50d03fccc2654b8336d9e40daea85d6adca
| * Remove deleted transport objectsKai Dohmen2016-07-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added a QMultiHash which maps transport objects to wrapped object ids. transportRemoved iterates over all matching wrapped objects and removes the passed transport object from their transports-vector. If the transports-vector is empty after removing the passed transport object the objectDestroyed will be called on the wrapped object. transportRemoved will be called either on the transports destoryed signal or on disconnecting the webchannel from it. Without this changes the QMetaObjectPublisher::wrappedObjects and ::registeredObjectIds would only be cleaned up if the website calls deleteLater on QObjects but not on website reloads. Task-number: QTBUG-50074 Change-Id: If294564fee2406edd7fb578852aeb269cac23a92 Reviewed-by: Milian Wolff <milian.wolff@kdab.com> (cherry picked from commit fa2374d7c4dedea907e2df26fdad28bdee73b122) Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Edward Welbourne2016-07-151-0/+51
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | Alleged Conflicts: examples/webchannel/chatclient-html/doc/src/chatclient-html.qdoc examples/webchannel/chatclient-qml/doc/src/chatclient-qml.qdoc examples/webchannel/chatserver-cpp/doc/src/chatserver-cpp.qdoc In each case, the two sides agreed byte-for-byte. Not quite sure what git thought the conflict was ! Change-Id: I5da9695b667f4112848c520b630ab1304d61cea3
| * Add test to verify that bools get properly converted.Milian Wolff2016-07-131-0/+5
| | | | | | | | | | | | | | | | | | This test passes and seems to indicate that the signal-delivery has an issue, or that the issue lies on the JavaScript side. Change-Id: Ic2436147b3af49d35dc556da57aed3e54408f1f9 Task-number: QTBUG-54074 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
| * Make passing objects from website to server possibleKai Dohmen2016-06-211-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | If you get an object from the server and want to pass it back to the server via a function the id of the object is passed instead of the whole json object. On the server side QMetaObjectPublisher::invokeMethod now looks up the object in QMetaObjectPublisher::wrappedObjects by the passed object-id. Task-number: QTBUG-50075 Change-Id: Id0df2dfaa79bcba12ca48391ae7537ac1a086898 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
| * Fix setting properties of QJson{Value,Array,Object} type.Milian Wolff2016-05-261-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to the previous issue, where these types were not properly converted to QVariant when invoking a method, we manually do the conversion now to get the desired behavior. The culprit is again that QJsonValue::toVariant converts an object e.g. to a QVariantMap, and not to a QVariant containing a QJsonObject. [ChangeLog] QObject properties of type QJsonValue, QJsonArray or QJsonObject can now be set via the Qt WebChannel. Task-number: QTBUG-48198 Change-Id: I5d574b1a5cffd6d6ad9b555f2a3e872b9c3425a7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Enable calling C++ functions taking QJson arguments via webchannel.Milian Wolff2016-05-251-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We used to convert the QJsonValue arguments to QVariants, which then failed to call a C++ function which expected on of the three QJson data types, i.e. QJsonValue, QJsonObject or QJsonArray. Instead, we now detect these three cases and manually convert the QJsonValue as needed. [ChangeLog] C++ functions taking arguments of type QJsonValue, QJsonArray or QJsonObject can now be called via the Qt WebChannel. Change-Id: I94e0c8937ca35e2ecd3554f7ddf2d4e5a3328570 Task-number: QTBUG-48198 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Updated license headersAntti Kokko2016-01-201-17/+12
|/ | | | | | | | | | | From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) Change-Id: I1c2917ddcb2436477aefde3dc640155d5131a664 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Support subclass property getters and setters.Pierre Rossi2015-07-081-0/+2
| | | | | | | | | | | | | | | QDialog for instance adds a setter for the modal property already exposed by QWidget. Object.defineProperty requires configurable set to true in order to add that setter at a later stage. Adds some reusable autotest logic with a soft dependency on QJSEngine to test some of the C++/JS integration aspects. Task-number: QTBUG-46548 Change-Id: Ibd49274f7d334c068c4006fb09417abf911c24e9 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Fix wrap registered object issueLutz Schönemann2015-05-151-0/+20
| | | | | | | | | | | | | | | | When wrapping a registered object the code generated a new ID for an already known object. That new ID wasn't stored but returned to the client including the objects information. That resulted in a new created object on client side but the remote object (on the server) was not accessible. This patch fixes the issue by just returning the known ID of a known object. Because the client already has a local representation of that object it does not have to unwrap the object description. Change-Id: I31964823c84c84fd7ebce4386865c18fb5518be7 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Update copyright headersv5.5.0-alpha1Antti Kokko2015-02-171-6/+6
| | | | | | | | | 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: Iebed549451f58a9fbdd86adf5d0340412d7766d7 Reviewed-by: Jani Heikkinen <jani.heikkinen@theqtcompany.com>
* Fix crash on signal after deregistrationLutz Schönemann2014-12-031-0/+1
| | | | | | | | | | | | | | | Implemented a remove method in SignalHandler that allows us to remove and disconnect an object from SignalHandler w/o decrementing the connection counter until it hits zero or deleting the object That same functionality was used to remove an object from internal lists when receiving a destroyed signal from an object. In case of deregistering an object we haven't received a destoryed signal but simulated reception of that signal and so that code was not called in that case. Change-Id: Ie20cf628a2de028375f5d29f913682e25ebf8d44 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Update license headers and add new licensesJani Heikkinen2014-08-261-18/+10
| | | | | | | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Furthermore we need to update the sync.profile to not point to the dev branch in order to integrate this patch in the CI. Change-Id: I06b5496b5d865e2da4808532362616429c969658 Reviewed-by: Sergio Ahumada <sahumada@blackberry.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Fix namespace build of testFrederik Gladhorn2014-08-041-0/+4
| | | | | | Change-Id: I66b102f0076d8ab39f871ce2be300a1e33228eac Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Properly disconnect a transport from the QtMetaObjectPublisher.Milian Wolff2014-08-011-0/+6
| | | | | | | | | | | | | | This fixes a bug, where messages from the transport would still be send to the QtMetaObjectPublisher even though it was previously disconnected. I'll refactor this code eventually to get rid of QtMetaObjectPublisher alltogether and merge its code into QWebChannelPrivate where appropriate. Change-Id: Ie0c35bd81a5e633bdcb6be55b64f947d4a545a59 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com> Reviewed-by: Lutz Schönemann <lutz.schoenemann@basyskom.com>
* Refactor and streamline API and IPC protocol.Milian Wolff2014-07-291-1/+1
| | | | | | | | | | | | | | | This patch removes the obsolete API support to send raw messages using a QWebChannel. Instead, it is encouraged to directly use WebSockets or navigator.qt. By doing so, we can cleanup the code considerably. While at it, the transport API is adapted to work on QJsonObject messages, instead of QStrings. This will allow us to use more efficient formats in e.g. QtWebKit or QtWebEngine. One could also implement a JSONRPC interface using a custom transport then. Change-Id: Ia8c125a5558507b3cbecf128a46b19fdb013f47b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
* Refactor code to use QWebChannelAbstractTransport and QtWebSockets.Milian Wolff2014-07-041-11/+8
| | | | | | | | | | | | | | | | | | | | | | This is a quite big changeset, but necessary to get the roadmap implemented that was discussed at QtCS. With this patchset landed, the QWebChannel does not depend on QtWebKit anymore, not even for the tests. Rather, we will introduce the dependency in the other way (i.e. QtWebKit will optionally use QtWebChannel if available). For the pure Qt/C++ use-case, we ship a utility implementation of a QWebChannelAbstractTransport that uses a QWebSocket for the server-client communication. This way, we can get rid of the custom WebSocket implementation. The tests are refactored to run the qwebchannel.js code directly inside QML. Integration tests for QtWebKit/QtWebEngine as well as examples will be added to these repositories. Change-Id: Icc1c1c5918ec46e31d5070937c14c4ca25a3e2d6 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* Add cmake test, adapt test directory layout and point to dev branches.Milian Wolff2014-07-031-0/+237
The auto tests are now located in tests/auto instead of directly in tests/. This is required to ensure the cmake test is found. Furthermore, the sync.profile is updated to point to refs/heads/dev, as we target Qt 5.4 with this new module. Change-Id: I1e6e99968b7081b5774eaf30319cac1fbaed35c2 Reviewed-by: Sergio Ahumada <sahumada@blackberry.com>