Mac:AppleScript
This page needs to be updated!
For the latest on AppleScript support in Firefox, please see:
Below:
- Please update the overall status
- check whether each bug below has been fixed or not and update accordingly
Below information is old since 2010:
Right now Gecko is only able to respond to the relevant parts of the standard AppleScript dictionary. We'd like to expand support to allow for more complex interactions. In particular, we want to resolve the following bugs in Firefox:
- 369901, 491005, 516502, get URLs and titles for tabs
- 490830, get contents of selection
- 395712 (Camino), make a new browser window
- 395711 (Camino), make a new tab
Similar bugs in other Gecko applications include:
- 46407 (SeaMonkey), get URLs and titles for tabs
Other requests include:
- 156013 (SeaMonkey), get current profile
- 520515 (Camino), rearrange tabs
- 557057 (Camino), refresh tabs
- 178917 (Camino), do javascript
- 453202 (Camino), get bookmarks
- 605068 (Camino), add and remove bookmarks
Current Plan
The bug for improved AppleScript support in Gecko is bug 61356.
The bug for improved AppleScript support in Firefox is bug 608049.
Other bugs for AppleScript in include: 125419, 156078 (Camino), 237733.
The ideal solution is to allow Gecko applications to dynamically register for AppleScript commands which are then forwarded to them, without the caller needing to write their own Objective-C.
e.g. if Firefox Sync would like to have an AppleScript command "tell application "Firefox" to sync", it could register with the AppleScript service to forward all "sync" AppleScript requests to their Javascript code.
The current plan is to create a solution tailored for Firefox, which could be replaced by a more generic solution (once one is found).
Generic Solution Proposals
- Proxy objects: similar to Tom Dyas' work in bug 516502, have an application create their own set of proxy Obj-C classes to respond to AppleScript.
- Pros: native Obj-C solution, less chance of problems interacting with Apple's code
- Cons: must regularly update proxy objects, may not represent actual state of application. Also, much be maintained on a per-application basis (not within Gecko)
- Catching requests: override KVC and preformSelector on NSApplication subclass to catch requests from AppleScript and forward requests to other classes that register with an AppleScript service
- Pros: can be maintained at the Gecko-level, allows developers with no knowledge of Obj-C to provide functionality to AppleScript
- Cons: could have performance implications (given changes to NSApplication), greater chance of problems interacting with Apple's code
- Override [NSScriptCommand executeCommand] and do our own parsing and handling of AppleScript commands.
- Provide a basic level of commands at the Gecko level which return results based on Javascript queries (e.g. a request for application->window->tabs would use Objective-C objects for application, windows and then use Javascript to find the current tabs and fabricate Objective-C objects that reflect their current state.)
Scripting Hierarchy
Firefox
- application
- windows
- tabs
- index
- name
- URL
- source
- doJavascript?
- tabs
- windows