It’s been quite some time since I’ve had to deal with cross-browser compatibility problems of the scale of Internet Explorer 6 and 7, and it lulled me into a false sense of security that we were past this kind of shenanigans. But I have a lovely client who has difficulty keeping her Apple laptop and mobile devices up to date, resulting in some fun compatibility issues with older versions of Safari. Particularly when using certain CSS3 features like flexbox (I admit, there were a couple problems with Explorer 11 on Enterprise Windows, but that’s Explorer for you).
In the process of trying to determine how to reproduce these problems on Safari 9, I was frustrated to find that there isn’t an easy way to emulate older versions of Safari, even on OSX. At least, nothing short of paying a premium subscription to browser testing services. User-agent switching won’t cut it, and so it came down to the tried and true VM route.
Unlike Explorer, which has the excellent resource of xdissent/ievms for VirtualBox, Safari has no such counterpart. But if you can get hold of VirtualBox image for OSX which comes with the version Safari you need to test, you can pretty much do the same thing.
For my purposes, vanilla El Capitan comes with Safari 9, so I picked up the VM from this tutorial on Techsviewer and followed the steps provided there. They’re using Windows, but the steps are essentially the same for OSX.
Step 1: Create a New Virtual Machine
Use the create new virtual machine wizard in VirtualBox to create a new VM using the image you have just downloaded.
You will need to configure the VM with at least the following specs:
- 2048MB RAM
- 2 CPUs
- PIIX3 Chipset
The rest of the options can stay at their defaults.
Step 2: Run the VM
If you’re lucky, that’s it. Run through the OSX new install setup wizard and you’re ready to go.
If the VM doesn’t run, or just gets stuck at a grey screen without loading the wizard, try shutting down the VM and increasing the RAM.
While the VM spun up okay for me at 2048MB RAM, I would have about a minute before the screen blacked and it would force me to log in again. I’d need to log in an average of 3 times before it would actually let me back in.
I treat my machines pretty terribly and I’m pretty much always nearly capped with my memory usage. I’m not sure if this is the actual issue, but if your usage is high, it’s entirely possible the VM will become buggy. Kill off your high usage apps and restart the VM.
If the VM still runs oddly, shut it down and try executing the following in Terminal to update the EFI and SMC settings of the VM:
VBoxManage modifyvm "VM Name" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff VBoxManage setextradata "VM Name" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3" VBoxManage setextradata "VM Name" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0" VBoxManage setextradata "VM Name" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple" VBoxManage setextradata "VM Name" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" VBoxManage setextradata "VM Name" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
VM Name is what you used in the Create a new VM wizard in VirtualBox.
I don’t know how many of these are necessary, you can always just try them one at a time until it starts working, or just put them all in at once.