Debug on open location handler?

Besides an on run handler, my script has an on open location handler. Is it possible to run the latter via the debugger in Script Debugger?

My source is in .applescript format, but I also tried saving it as an .app (both Apple as Enhanced).

I would expect some option in the run-button-dropdown, but nothing is enabled there. I’ve also tried drag/dropping a .webloc file (with my own private scheme) on the editor window, but the “Invoke Open Handler” is disabled.

What am I missing here?

We don’t offer the ability to debug on open location handlers at present. You can simulate this on AppleScript:

-- Get the URL of the current Safari web page...
tell application "Safari"
	set theURL to URL of current tab of the first window
end tell

open location theURL

on open location theURL
	log theURL
end open location

I’ve added a feature request for this at our end. No promises for Script Debugger 8.0, but we’ll look into it.

Ah, it’s not implemented yet. Good to know.

I indeed “faked” a call to on open by adding a line in the on run handler. The downside to this, I must comment out this code before committing changes.

Hmm, maybe better just handle this situation via a user default. If a value exists in a user default, just let it be handled by the on open handler.

I’m not sure if this will help, but you can use code like this to detect when your script is running within Script Debugger:

if id of current application begins with "com.latenightsw.ScriptDebugger" then
	display alert "You are running in Script Debugger"
else
	display alert "You are not running in Script Debugger"
end if
2 Likes