Bug 9761

Summary: LiveConnect string conversion fails for java.lang.Object
Product: WebKit Reporter: Marc Epard <marc>
Component: JavaAssignee: Alexey Proskuryakov <ap>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, bugzilla, ddkilzer, hendry, mrowe
Priority: P2    
Version: 412   
Hardware: Mac   
OS: OS X 10.4   
URL: javascript:alert(window.java)
Attachments:
Description Flags
xcode project for applet and web page that illustrate the problem
none
LiveConnect enabled check
none
proposed fix mjs: review+

Description Marc Epard 2006-07-06 12:44:18 PDT
The LiveConnect JavaScript-to-Java type conversion rules for JavaScript strings are at <http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:LiveConnect_Overview:Data_Type_Conversions:JavaScript_to_Java_Conversions#String_Values>

They specifically that JavaScript strings are converted to java.lang.String for arguments of both java.lang.String and java.lang.Object types.  On Mac OS X 10.4.7, though, only arguments of type java.lang.String work.  java.lang.Object arguments become null.

I'll send along an attachment with an example.
Comment 1 Marc Epard 2006-07-06 12:48:16 PDT
Created attachment 9236 [details]
xcode project for applet and web page that illustrate the problem
Comment 2 Mark Rowe (bdash) 2006-07-06 15:25:52 PDT
Based on my reading of the LiveConnect documentation and a test of the provided applet, I can reproduce this issue with WebKit 418.8 and WebKit r15138.
Comment 3 Kai Hendry 2007-08-29 02:28:51 PDT
Created attachment 16150 [details]
LiveConnect enabled check

I can't get LiveConnect working on any Safari version on my new MBP 10.4.10 system.

Perhaps I am missing a plugin?

QuickTime Plug-In 7.2
iPhotoPhotocast
Quartz Composer Plug-In
Verified Download Plugin
Java Plug-in for Cocoa
Shockwave Flash
QuickTime Plug-in 7.2
Google Update One-Click Installer Plugin
Comment 4 David Kilzer (:ddkilzer) 2007-08-29 06:57:53 PDT
(In reply to comment #3)
> Created an attachment (id=16150) [edit]
> LiveConnect enabled check
> 
> I can't get LiveConnect working on any Safari version on my new MBP 10.4.10
> system.

Is Safari set to run under Rosetta?  Do a "Get Info" on the Safari application in the /Applications folder, and make sure the "Open using Rosetta" checkbox is unchecked.

http://docs.info.apple.com/article.html?artnum=303120

Comment 5 Kai Hendry 2007-08-29 07:10:28 PDT
Found Rosetta unchecked.

Does the "LiveConnect enabled check" test work for you?
Comment 6 David Kilzer (:ddkilzer) 2007-08-29 07:18:54 PDT
(In reply to comment #5)
> Found Rosetta unchecked.
> 
> Does the "LiveConnect enabled check" test work for you?

No, it does not.  Works on Firefox 2.0.0.6.  Does not work on Safari 2.0.4 (419.3) with original WebKit on Mac OS X 10.4.10 (8R218).  I am using a PowerPC-based PowerBook G4.

Comment 7 David Kilzer (:ddkilzer) 2007-08-29 07:23:16 PDT
Opening javascript:alert(window.java) in Firefox 2.0.0.6 returns:

[JavaPackage java]

This is undefined in ToT WebKit, so it would appear that the window.java object is not available.

Opera 9.22 does nothing with the alert, but the test works properly (undetectable support?).

Comment 8 David Kilzer (:ddkilzer) 2007-08-29 07:35:45 PDT
(In reply to comment #5)
> Does the "LiveConnect enabled check" test work for you?

Kai, I believe your test demonstrates a different bug (no window.java object available in the DOM).  Would you please open a new bug for this issue?  Thanks!

Comment 9 David Kilzer (:ddkilzer) 2007-08-29 07:37:02 PDT
BTW, the original bug is still an issue.  Here's  how to compile the Java source file without Xcode:

$ javac LiveConnectBug.java
$ jar cf LiveConnectBug.jar LiveConnectBug.class

After doing that, opening example1.html from the LiveConnectBug/ directory will demonstrate the original bug.

Comment 10 David Kilzer (:ddkilzer) 2007-08-29 14:58:54 PDT
(In reply to comment #8)
> (In reply to comment #5)
> > Does the "LiveConnect enabled check" test work for you?
> 
> Kai, I believe your test demonstrates a different bug (no window.java object
> available in the DOM).  Would you please open a new bug for this issue? 

Bug 15109

Comment 11 Alexey Proskuryakov 2010-02-19 23:17:38 PST
Created attachment 49119 [details]
proposed fix
Comment 12 Maciej Stachowiak 2010-02-19 23:25:07 PST
Comment on attachment 49119 [details]
proposed fix

r=me
Comment 13 Alexey Proskuryakov 2010-02-20 00:25:27 PST
Committed <http://trac.webkit.org/changeset/55044>.