Safari crash - simple create new document script step -

I’m not sure if this is related is Safari 10.1 update or something else, but I’m getting a Safari crash from SD with this simple script :slight_smile:

tell application “Safari” to make new document

running same script from Script Editor runs okay.

From SD, I get the following:

This works for me

tell application "Safari" to set myWindow to make new document at beginning

I confirm @cobbap’s issue here. And the same happens in Safari Technology Preview.

Crashes SD but not SE on this system too:

–>Script Debugger 6.0.5 (6A202) on Mac OS 10.11.6 (15G1421)

tell application "Safari"
   activate
   set myWindow to make new document at beginning
end tell

–The application “Safari.app” appears to have crashed, responding to the following Apple Event:

–AppleScript: get source of document “Favorites”

–AEPrint: ‘core’‘getd’{ ‘----’:'obj '{ ‘want’:‘prop’, ‘from’:'obj '{ ‘form’:‘name’, ‘want’:‘docu’, ‘seld’:‘utxt’(“Favorites”), ‘from’:null() }, ‘form’:‘prop’, ‘seld’:‘conT’ } }

Turns out the crash is caused by Script Debugger’s Result explorer asking Safari for the source property of the newly created document. Switching the Result view from Best to Source avoids the crash.

Just encountered this in SD 6.0.6.

Will this bug be addressed in the future?

I don’t think this is Script Debugger’s bug to fix. I would suggest filing a bug with Apple for this one.

It seems to me that the crash is caused by SD asking for the source before the page has loaded. With ‘Best’ view selected, this works fine:

tell application "Safari"
	make new document
end tell
delay 3
tell application "Safari"
	get front document's source
end tell

But if I take the delay out Safari will crash. Given that, it’s not clear to me how I can implicate Safari to file a bug against it.

Running this code in the Script Editor causes Safari to crash. This excludes Script Debugger from the test case:

tell application "Safari"
	make new document
end tell
--delay 3
tell application "Safari"
	get front document's source
end tell
2 Likes

It looks like this bug is already resolved on High Sierra. Source just returns “” if the page hasn’ loaded in time and doesn’t crash (in either SD or SE).

1 Like

What’s happening is that SD automatically gets the document’s source as part of the result. Safari only return a reference to the open window, not the properties, etc.

This causes safari to crash the same way:

tell application "Safari"
	set myResult to source of (make new document)
end tell

Hey Ed,

On my MacOS 10.12.6 system Safari 11.1 (12605.1.33.1.4) does NOT crash with that code.

Where are you seeing this?

-Chris