This is part an AppleScript question and part an SD issue.
Where did the tabs element go?
According to the Safari dictionary tabs are an element of windows. Therefore running the following script displays a list of tabs in the results inspector (or an error — see below).
tell application "Safari"
the tabs of window 1
end tell
However, after executing the following the results inspector doesn’t include the tabs element that Safari’s AppleScript dictionary says windows have. Why?
tell application "Safari"
window 1
end tell
Windows without Tabs
Not all windows have tabs. When the designated window has no tabs an error occurs rather than the expression returning an empty list.
Windows with no tabs? Many applications have a few windows hanging around with no document, tabs, or whatever that document’s windows typically hold. These are palettes, dialog boxes, etc. (Someone else could contribute by characterizing these oddball windows more accurately and generally.) But in general they return empty strings or lists when queried.
However in the case of Safari’s windows we must write
tell application "Safari"
try
the tabs of window 1
on error
{}
end try
end tell
How many tabless windows hang around in Safari? Well, at the moment I have 40 windows on Safari’s Windows menu . (I am grateful for relatively recent improvements in Safari that allow this many windows to be open, with quite a few tabs in some of them.) However there are 97 total windows! What are those other windows?
One has the name “Passwords”, another the name “Thanks!” The rest have no names.
Another weirdness is that if you select one of these in the results inspector and disclose its contents, in contrast to “regular” windows, all you see is class
and properties
. Opening properties
shows the properties you would see in a “regular” window’s display in the results inspector.
Other than the question of what all those nameless windows are (a question I would love an answer to), how much of this is AppleScript weirdness, how much is SD’s unavoidable behavior, and how much is an SD bug?