Incorrect keystroke character insertion into Safari (after keystroke tab) via AppleScript

Originator:mmoore
Number:rdar://32574148 Date Originated:June 5 2017
Status:Open Resolved:
Product:Safari Product Version:Version 10.1.1 (12603.2.4)
Classification:Other Bug Reproducible:Always
 
Summary:
Using an AppleScript to insert keystrokes into Safari after a tab keystroke causes the characters following it to insert in the incorrect order.

Steps to Reproduce:
Run this AppleScript

tell application "Safari"
	make new document
	set URL of front document to "https://appleid.apple.com/#!&page=signin"
	set the_state to missing value
	repeat until the_state is "complete"
		set the_state to (do JavaScript "document.readyState;" in front document)
		delay 0.2
	end repeat
	activate
	delay 2.0
	tell application "System Events"
		keystroke tab
		delay 0.2
		keystroke tab using {shift down}
		keystroke "1234567890"
	end tell
end tell

The script will bring up the Apple ID Login page, tab to the password field then shift + tab back to the apple id field, then enter `3456789012` (or another combination of the incorrect order).  The same thing will occur if you just tab into the password field, but it's more visible in the apple id field which is why I chose to shift + tab back in this example.

Expected Results:
keystroke enters the characters in the correct order

Observed Results:
keystroke doesn't enter the characters in the correct order

Notes:
Adding a slight delay (0.2s) after the tab seems to allow the characters to enter in the correct order.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!