Bug 61295
| Summary: | Web Inspector: Applescript "do JavaScript" fails to return same results as javascript console | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | eric oberle <bt> |
| Component: | WebCore JavaScript | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED WONTFIX | ||
| Severity: | Normal | CC: | apavlov, bweinstein, joepeck, keishi, loislo, pfeldman, pmuellr, rik, timothy, yurys |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | Mac | ||
| OS: | All | ||
eric oberle
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Timothy Hatcher
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
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.