Multi-Safari

An interesting news has appeared this morning in my RSS news reader. Mac OS X’s Web Kit source code is now open to all. On the new public CVS repository can be found a small script that inspired me to do something I wanted for some time now: run two different versions of Safari simultaneously on the same computer. This has now been achieved, and this is how you can do the same.

WebKitTools/Scripts/run-safari

This script sets up the DYLD_FRAMEWORK_PATH environment variable, which will cause the system loader to use the frameworks you built from your Xcode build products directory instead of the ones installed in /System/Library/Frameworks, so it will start the version of Safari from the Applications directory with the WebKit frameworks you just built.

I rewrote the script in a different way which has allowed me to make a self-contained application of Safari 1.2.3 using Web Kit 125.9 from Mac OS X 10.3.8. And it runs perfectly on Mac OS X 10.3.9 alongside Safari 1.3 which I have on my iBook.

To make this work, you will need a computer with the version of Safari you wish to duplicate. Here are the steps to perform:

  1. Make a copy of the older Safari application. This is the application we will modify.

  2. Open your new copy of Safari to see the package content using the contextual menu in the Finder. Then, in the “Content” folder, create a “Frameworks” folder.

  3. On the startup disk with the older version of Mac OS X, copy the WebKit framework from “/System/Library/Frameworks” to your new “Frameworks” folder in the Safari application bundle.

  4. Inside the “WebKit.framework” folder you have just copied there is another “Frameworks” folder containing two other frameworks: “JavaScriptCore” and “WebCore”. Move them to the “Frameworks” folder you just created alongside “WebKit”.

  5. Now that frameworks are in place, we need to make sure the binary program uses them. Inside the Safari application bundle, rename the “Safari” binary found inside “Contents/MacOS” to “TrueSafari”. Then we will put a shell script called “Safari” in it’s place. The shell script will launch the “TrueSafari” binary after having set the DYLD_FRAMEWORK_PATH environement variable so that it prefer frameworks from it’s own bundle.

    Download the shell script here: Safari

  6. There is no sixth step, but you should rename this new Safari to something like “Safari 1.2.3” so that it’s clear what it is.

You can now double-click on your new old Safari. Anyone else has it working?

Update: I now have Safari version 1.0, 1.2, 1.2.3, and 1.3 running simultaneously on my computer. I would like to share the files, but I cannot because of the file sizes and the bandwidth it would take if it becomes somewhat popular.


Comments

Dan Schwartz

I would love to give this a try. I’ve been searching all over the place to get two versions of Safari running for browser testing purposes.

However, I don’t feel comfortable/able to perform what you’ve laid out. Have you thought of posting your complete packages at http://browsers.evolt.org/ to avoid personal bandwidth limitations? Or you can always just email me a package of Safari 1.0 ;-)

Thanks for your work! -Dan

Alex Rosenberg

I asked the Safari team for just such compatibility testing releases of prior builds at WWDC.

It was pointed out to me that some features are implemented in other frameworks (e.g. cookies are in FoundationKit). While basic rendering/CSS will be more like the original release on the original OS it ran on, the browser’s behavior will not be 100% as the original.

musti

You are a genius. Happy St.John Babtiste!

Dexter

Can I run safari 1.x.x on mac os tiger?

Michel Fortin

Alex: WebCore handles HTML and CSS rendering, while JavaScriptCore handles JavaScript. Since they are bundled in the application, page rendering should be exactly as it was.

FoundationKit handles HTTP requests and cookies. Since I do not copy it into the application bundle, Safari will use the one in from the current system. I somewhat doubt using an old FoundationKit on a newer Mac OS will work, but feel free to try by yourself by copying the framework next to the others in the application bundle.

Michel Fortin

Dexter: Above commenter Dan Schwartz reported to me that it works on Tiger with one cravat: you must open a local HTML file to have a browser window. Then you can navigate wherever you want. (I do not have Tiger so I can’t test myself.)

Art Duszynski

Thanks, Michel. It worked like a charm! For the rest of you, the newly packaged Safari 1.03 is available here.