Safari crash - simple create new document script step -


(cobbap) #1

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:

(Ed Stockly) #2

This works for me

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

(Jean Christophe Helary) #3

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

(Ed Stockly) #4

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"
   set myWindow to make new document at beginning
end tell

–The application “” 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’ } }

(Mark Alldritt) #5

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.

(Phil Stokes) #6

Just encountered this in SD 6.0.6.

Will this bug be addressed in the future?

(Mark Alldritt) #7

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

(Phil Stokes) #8

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.

(Mark Alldritt) #9

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

(Phil Stokes) #10

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).

(Ed Stockly) #11

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

(Christopher Stone) #12

Hey Ed,

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

Where are you seeing this?