Just as a matter of interest, we recently made an architectural decision to wrap all “static” JavaScript libraries (third party and internal) in Script Extensions.
The primary motivator behind this was json2.js throwing uncatchable exceptions for invalid JSON documents, the reason they are uncatchable being that Script Unit level exceptions can only be caught in the Script Unit in which it is thrown. In external Script Units, any exceptions thrown by a function within a JavaScript object cannot be caught (which is what is happening in json2.js).
To avoid this, we wrap the JavaScript library in a Script Extension which provides Property and Function accessors which wrap the calls to the JavaScript library functions in try/catch blocks. This has the following benefits:
1. Exceptions can be either handled or rethrown to be caught by other Script Units
2. Can control access to functions in the JavaScript libraries (not all functions are useful, usable or desirable within the Test Complete runtime to be made public)
3. Makes the functions available in the Test Complete code editors intellisense.
To minimise the workload around this, I have created some scripts that process a csv file which contain all the information required to create the wrapped property and function wrappers as well as the Description.xml file.
Regards,
Phil Baird