• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: 'do JavaScript' still broken in Safari 3 beta
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'do JavaScript' still broken in Safari 3 beta


  • Subject: Re: 'do JavaScript' still broken in Safari 3 beta
  • From: has <email@hidden>
  • Date: Thu, 21 Jun 2007 14:44:30 +0100

jj wrote:

> tell application "Safari"
>      do JavaScript "document.title = 'hello'; return 1" in tab 1 of
> window 1
> end tell
>
> Window title changes as expected; still no return value though, so
> 'do JavaScript' is definitely broken. Feel free to file your own bug
> report on it; this is something that should've been caught by basic
> unit testing well before public beta.

I think this use of "return" is "invalid". "return" must be used inside a
function (?)

You may be on to something. I tried running:

tell application "Safari"
	do JavaScript "42" in document 1
end tell
--> 42

As you can see, it gives a result. Looks like something in the JavaScript interpreter has changed from previous versions, as "return 1" works fine in the version of JS used by Safari 2. Unfortunately, I'm not a JS expert (as you can tell) so I've no idea if this is by design or accident - anyone know?


Seems that 3b now coerces results (if possible).

I don't know about coercing results, but it does seem to have improved the mapping between JS and AS types, e.g. JS numbers now return as AS numbers instead of strings.


Anyway, after all that there is absolutely definitely a bug in 'do JavaScript', although it's not the one I initially thought. The bug is that 'do JavaScript' should always return a result, even if that result is only 'missing value', but sometimes fails to do so. It's not the first application to do this, e.g. older versions of Address Book were notorious for this, and I suspect it's really something that should be addressed at the Cocoa Scripting framework level when mapping Cocoa objects to their AEDesc equivalents.


It shouldn't, I think. And
if it does, it should also throw AS-errors when the do JavaScript call does
so... (for example, appart from the DOM and appart from lots of missing
functions in Safari and, more generally, in most of browsers).

I've never understood JS's approach to exceptions and exception handling, so ain't going there myself. :p


Anyways, many thanks for helping to get to the bottom of the problem, and I'll be sure to pass the info on.

Cheers,

has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
http://appscript.sourceforge.net/objc-appscript.html

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: 'do JavaScript' still broken in Safari 3 beta
      • From: "Mark J. Reed" <email@hidden>
  • Prev by Date: Re: Speaking of Safari's do Javascript....
  • Next by Date: Re: 'do JavaScript' still broken in Safari 3 beta
  • Previous by thread: Meta: any hobbyists out there interested in a 'code-free' semi-social spinoff list?
  • Next by thread: Re: 'do JavaScript' still broken in Safari 3 beta
  • Index(es):
    • Date
    • Thread