Qt for Web Assembly Support in Squish

Qt for Web Assembly Support in Squish

WebAssembly is a new binary executable format. It is mainly used to run web applications within a web browser, but it is also supported by other projects like Node.js or standalone interpreters written in C, Rust, Haskell and even JavaScript. WebAssembly is not tied to a particular programming language and can serve as a target for a wide range of compilers.

Starting with version 5.11, Qt provides an experimental WebAssembly port. While it currently supports only a subset of core Qt modules and places certain restrictions on some of the features, it already allows running usable applications in the context of a web browser. It uses a single <canvas> HTML element to render the GUI using assembly code. This makes it impossible to test such applications using standard edition of Squish for Web. We are currently working on a prototype Squish implementation that supports the Qt for WebAssembly port. While some of its restrictions may be lifted eventually, many of them stem from the policies and limitations placed on the execution environment by the web browser.

Currently, Qt for WebAssembly supports static linking only. Just as on any other platform supported by Squish for automated GUI testing, this requires the application to include the Squish Built-in Hook in order to become testable. Loadable modules and dynamic linking were, however, recently introduced to WebAssembly. Given the size of Qt binaries, it seems reasonable to use that feature to allow caching and sharing of the library code between applications. When the standardized ABI is introduced to the platform, it should also become possible to share the same Qt binaries between applications from different vendors by using common CDN servers. If the Qt library adopts that paradigm, it should be possible to integrate Squish with the WebAssembly AUT without any changes to the application source code.

Squish GUI Tester uses a TCP/IP connection to the AUT in order to record and execute tests. However, web browsers do not support arbitrary-protocol network connections and apply rigorous restrictions on connectable addresses. In order to connect the AUT to the squishserver, we use a binary WebSocket client instead. We have extended the launcher used to start and communicate to the web browser by Squish for Web, and allowed it to tunnel the Squish IPC protocol through a WebSocket connection. This allows WebAssembly AUTs hooked by Squish to work alongside regular Web context, behaving as a separate application. Further development may allow seamless integration of such content and remove the need for juggling the application contexts.

                                       Two separate contexts for a WebAssembly application.

Web browsers do not support custom event loops and always execute code in a non-blocking, event driven manner. Some of the Squish core IPC components had to be refactored to avoid blocking the event loop. Consequences of running Squish communication in parallel to regular AUT event processing are still under investigation.

The WebAssembly platform and the corresponding Qt port are still under active development. We will continue to work toward releasing Squish support for it as the technology matures. If you are interested in using Squish with Qt for WebAssembly applications, please contact us at squish@froglogic.com.


Leave a reply

电子邮件地址不会被公开。 必填项已用*标注