Sunday, November 11, 2007

Apple Safari LiveConnect Woes

Testing LiveConnect support in Safari, I figured that you can relatively simply crash the browser completely. Actually all you need to do is the following:
An applet that has a simple routine:
package net.coalevo.auth;

import java.applet.Applet;

public class Test
extends Applet {

public String test(String t) {
return t;
}//test

}//Test


Next you need a simple HTML Document to load the applet and call our test method using JavaScript:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Safari Crash Test</title>
</head>
<body>
<applet name="Test" archive="coalevo-test.jar" code="net.coalevo.auth.Test" width="100" height="100" style="border: 1px dashed #000;">
Your browser does not support Java, so nothing is displayed.
</applet>

<input type="button" value="DO TEST" style="width:150px" onclick="console.log(document.Test.test('blubb!'));"><br />
</body>
</html>


That's pretty much all that is needed to send Safari into Digital Nirvana.

My System Info:
OS X 10.4.10;
Java VM: Java HotSpot(TM) Client VM (1.5.0_07-87 mixed mode)

But feel free to vist this example live. But, don't press the button if you have anything important open in your Safari Browser.

My conclusion, Java support on the Mac is starting to suck.

1 comments:

Dieter said...

Same crash on my new system:
OS X 10.5.1
Java VM: Java HotSpot(TM) Client VM (build 1.5.0_13-119, mixed mode, sharing)

However, there is a way to prevent the crashing, using Java 1.4.2:
Go to Utilities, use the Java Preferences Application and change to 1.4.2 in the Java Applet Runtime Settings.


It also works properly on XP SP2, tested in latest Firefox, IE and Safari.