RESOLVED WONTFIX 61295
Web Inspector: Applescript "do JavaScript" fails to return same results as javascript console
https://bugs.webkit.org/show_bug.cgi?id=61295
Summary Web Inspector: Applescript "do JavaScript" fails to return same results as ja...
eric oberle
Reported 2011-05-23 11:40:08 PDT
I am not sure I am filing this under the right component category, but basically I am hoping that a fix could be made to allow Applescript's "do Javascript" command to obtain all a text/string dump of everything that appears in the debugger's javascript console. For example: If I type in the Javascript console: document.images I receive a list of all image tags in the document But if I issue this Applescript command: tell application "WebKit" set the_tab to current tab of window 1 set x to do JavaScript "document.images" in the_tab log x end tell I receive only: "[object HTMLDivElement]" as a result. Trying to push the array into a Javascript array and converting it to a string inside the Javascript passed to Applescript is equally futile. I understand that no one is going to implement the DOM datatypes for Applescript. But if the console can display the image tags as a block of text, why not let Applescript's "do Javascript" do the same? This would be huge for me trying to automate some webpage testing. Thank you for your consideration. best, Eric Oberle
Attachments
Timothy Hatcher
Comment 1 2011-05-23 11:54:53 PDT
I am not sure how document.images converts to "[object HTMLDivElement]", it should be "[object HTMLCollection]" or similar. Anyway, this is expected behavior and we don't plan to add "pretty printing" of types to the "do JavaScript" command. It isn't as simple as you make it sound — the Web Inspector code to do this is very disconnected from AppleScript. If you want useful results, you need to stick to basic JS types (array, string, etc) which will get converted to AppleScript types. This isn't even a WebKit feature, it is a Safari feature, so this isn't even the right bug database.
Timothy Hatcher
Comment 2 2011-05-23 12:00:15 PDT
Internally we have <rdar://problem/3098893> about exposing the DOM to "do JavaScript". You can file new Safari specific bugs/enhancement requests at http://bugreport.apple.com.
Note You need to log in before you can comment on or make changes to this bug.