Depending on how much JS manipulation you need you have 3 options. The first is to use the inbuilt "Browser" plugin, which has a couple of options for evaluating JS. So in this situation you could use the expression
Browser.ExecJS("window.testMessage") to get the value.
The final option is to write a small plugin using the SDK, this is an advanced use case but might fulfil a few more complex situations that you want. SDK manual