JavaScript Notes and Extension APIs
Note: Squish assumes that all test.js
files use the UTF-8 encoding. If you expect to edit such files outside of the squishide
, make sure that the editor loads and saves the files using UTF-8.
Squish JavaScript API Classes and Objects
Squish has added the below types/classes/objects to the JavaScript interpreter.
Provides file handling operations. | |
Container for handling data from forms. | |
Provides operations for interaction with the Operating System. | |
API for accessing SQL databases. | |
TCP Client Socket. | |
Blocking API for text communication via WebSocket protocol. | |
Provides a parse method which returns an XMLNode. | |
HTTP client API. | |
Provides an assert method. |
JavaScript Language Documentation
In theory, any JavaScript book or online resource is suitable for learning about the language or for looking up functions. Unfortunately most authors don't make a clear distinction between features that are part of the JavaScript language itself and browser-specific extensions. When reading such texts beware of any example code that makes use of the window
or document
objects since these are provided by browsers and are not part of the language.
By keeping in mind the distinction between the pure language (which is what Squish supports) and browser-specific extensions, you'll be able to find the information you need from a variety of books and online resources while avoiding confusion. Here are some useful online JavaScript language resources:
- Mozilla's Core JavaScript Reference
- Microsoft's JScript Language Reference at msdn.microsoft.com
- DevGuru JavaScript Quick Reference at www.devguru.com
If you prefer books, a good JavaScript book is JavaScript: The Definitive Guide by David Flanagan.
Language Core
The JavaScript engine shipped with Squish is based on the ECMAScript language specification (ECMA 262 Edition 3, plus parts of later editions). The language core that is defined in this standard encompasses operators, control structures, objects, and other features commonly found in a scripting language. The subset of supported built-in classes and members can be found in Squish ECMAScript Support.
The pure JavaScript (i.e., ECMAScript) language has no built-in support for file handling or networking, unlike other scripting languages such as Python and Tcl. This is because JavaScript has been designed to be a small language that can be safely embedded into applications. However, JavaScript is also designed to be extened by custom APIs specific to the embedding application. In the case of web browsers there are hundreds of functions and properties that allow for the manipulation of HTML documents via the DOM API, for example. In the case of Squish we have added numerous functions specific to testing. And we have also added some general purposes classes described below. And if the features we have added are not sufficient for your needs contact support and request an enhancement.
Note: Some JavaScript functions take a path parameter. This can be a directory or a filename (and can include the full path), such as C:\My Documents\test-plan.odt
or /home/user/test-plan.odt
. In most scripting languages, including JavaScript, the backslash character (\
) is used to start an escape sequence inside strings and so cannot be written by itself. For this reason, when writing Windows paths in JavaScript strings we must escape the backslash—for example, "C:\\My Documents\\test-plan.odt"
.
Squish ECMAScript Support
This section is about the ECMAScript API subset that is supported in Squish. Squish also adds non-standard objects like File, XML and SQL, and a testing-specific API which are listed in Squish JavaScript API Classes and Objects.
Keywords
as
, break
, case
, catch
, const
, continue
, default
, delete
, do
, else
, export
, extends
, false
, finally
, for
, from
, function
, if
, in
, instanceof
, import
, let
, new
, null
, of
, return
, static
, super
, switch
, this
, throw
, true
, try
, typeof
, var
, void
, while
, with
Punctuators
{}, \c {}
, (
, )
, [
, ]
, .
, ,
, ;
<
, >
, <=
, >=
, ==
, !=
, ===
, !==
, +
, -
, *
, /
, %
,**
, ++
, --
, <<
, >>
, >>>
, &
, |
, ^
, !
, ~
, &&
, ||
, ??
, ...
?
, :
, =
, +=
, -=
, *=
, /=
, %=
, **=
, <<=
, >>=
,>>>=
, &=
, |=
,^=
, &&=
, ||=
, ??=
and =>
.
Here is a list of ECMASCRIPT-supported types available from Squish test cases.
ECMAScript Array type. | |
ECMAScript Boolean type. | |
ECMAScript Date type. | |
ECMAScript Error type. | |
ECMAScript Function type. | |
ECMAScript globals. | |
ECMAScript JSON object. | |
ECMAScript Map type. | |
ECMAScript Math object. | |
ECMAScript Number type | |
ECMAScript Object type | |
ECMAScript RegExp type. | |
ECMAScript Set type. | |
ECMAScript String type. |
© 2024 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners.