There is an assumption that the Javascript engine embedded in the EA is in line with the ES5 (ES6?) standard supported by the Mozilla Spidermonkey v60. This is the pre-requisite to allow me to use open/off the shelf Javascript to supplement my EA automation.
I have yet to find any technical documentation, except an assertion that it is based on the gecko v60 JS runtime (standalone available here
windows/
linux),
I have recently started testing this assumption, or rather exploring the abilities of the JS engine from the inside. My approach so far is reminiscent of how you got things working in the browser wars, where you try and get an idea about the properties from inside and outside of the Javascript engine context. You do this by using JS reflection techniques to dump the properties from global scope in the running context, and a debugger on the running context.
Before i go to far and re-invent the wheel though, is there documentation on the JS engine implementation?
More specifically:
- what is the object that defines the global scope. there is no globalThis defined, but the root 'this' (see script below) is not behaving as a typical global scope object would.
- how do i tell i am in a Javascript and not JScript context?
- how do i tell which of the pre-defined contexts the script is running in?
- where is the 'var <blah> as' operator documented.
Investigation using the script debugger on the script below, shows that these 'as' objects are already available to the script execution context.
function getGlobal2() {
return (function(global) {
return global;
})(new Function('return this;')());
}
var temp=getGlobal2();
Session.Output("----- globaldump");
// rightclick to insert debugger breakpoint on line below
Session.Output(Object.getOwnPropertyNames(temp));
The implication being that there can only be one instance of a given 'as' defined object - meaning it is always a global object?. Does it only work in var statements? Can i scope these with let?
- So does it matter which execution context a script it is running in?
Pointers and experiences also appreciated.