WebPagetest Forums
Why not use window->eval() instead of window->execScript in ScriptEngine.cpp - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: WebPagetest (/forumdisplay.php?fid=7)
+--- Forum: General Discussion (/forumdisplay.php?fid=25)
+--- Thread: Why not use window->eval() instead of window->execScript in ScriptEngine.cpp (/showthread.php?tid=13339)



Why not use window->eval() instead of window->execScript in ScriptEngine.cpp - leon_temp@163.com - 10-31-2014 05:37 PM

Cause some script is not work in Firefox and Chrome, but only can execute in IE10.


RE: Why not use window->eval() instead of window->execScript in ScriptEngine.cpp - pmeenan - 11-04-2014 02:04 AM

I don't think you're looking at the correct code. There is custom code for each browser for running script and you are likely running into Chrome/Firefox sandbox issues. That said, Chrome should be using the same interface that the dev console uses so if you can run a script there it should work.

Here is the code in the Chrome agent that executes script: https://github.com/WPO-Foundation/webpagetest/blob/master/agent/browser/chrome/extension/wpt/chromeDebugger.js#L89

Here is the IE code: https://github.com/WPO-Foundation/webpagetest/blob/master/agent/browser/ie/wptbho/wpt.cc#L557

Here is the Firefox code: https://github.com/WPO-Foundation/webpagetest/blob/master/agent/browser/firefox/extension/chrome/content/mozutil.js#L123

Firefox has a pretty restrictive sandbox that I haven't found a way out of from an extension yet but Chrome and IE should both have good page access.