WIP: add support for Java applets

400 views
Skip to first unread message

Stephen Bannasch

unread,
Mar 4, 2012, 1:46:50 PM3/4/12
to phan...@googlegroups.com
WIP: Enable Java Applets: --enable-java=[yes|no]

see: https://github.com/stepheneb/phantomjs/commit/d42711cfc9d2f9

I'd like to be able to use ShadowJS to support testing JavaScript <=> Java Applet communication.

It seems QtWebKit might support Java Applets

This bug is marked as: RESOLVED FIXED
Bug 33044 - Add Java Applet support to WebKit's Qt port
https://bugs.webkit.org/show_bug.cgi?id=33044

This page reports:
http://dot.kde.org/2011/07/26/release-47-new-features-improved-stability-and-performance
"... java applet support has been working since QtWebKit 2.1"

However a comment in qwebsettings.cpp indicates that currently Java applets are not supported.

./src/qt/src/3rdparty/webkit/Source/WebKit/qt/Api/qwebsettings.cpp

\value JavaEnabled Enables or disables Java applets.
Currently Java applets are not supported.

I ran the Jasmine tests on master and on the java-enabled branch and both had the same single failure:

#66 WebPage object: should handle file uploads
FAIL

I did not see a current test pattern for testing an argument like --load-plugins.

Using shadowjs with the --enable-java argument appears to operate without error, but rendering the page does not show the
rendered Java applet.

I'm running a copy of this Sandpile NetLogo applet locally:

desc: http://ccl.northwestern.edu/netlogo/models/Sandpile
applet: http://ccl.northwestern.edu/netlogo/models/run.cgi?Sandpile.996.476

And trying to access from shadowjs like this:

// phantomjs netlogo.js
var page = new WebPage();
page.viewportSize = { width: 1100, height: 600 };
page.open("http://localhost:8000/netlogo.html", function(status) {
var title = page.evaluate(function () {
return document.title;
});
console.log('Page title is "' + title + '"');
window.setTimeout(function () {
page.render("netlogo.png");
phantom.exit();
}, 10000);
});

Here's what my local html page looks like:

<html>
<head>
<title>NetLogo Applet</title>
<style type="text/css">
body { font: 16px sans-serif;
margin: 1.0em 2.0em;
background-color: white;}
applet { border: 1px solid gray;
padding: 10px;
background-color: #F0F0F0; }
</style>
</head>
<body>
<p>NetLogo Applet</p>
<p>
<applet code="org.nlogo.lite.Applet" archive="NetLogoLite.jar" width="996" height="455">
<param name="DefaultModel" value="Sandpile.nlogo">
</applet>
</p>
</body>
</html>

Here's the invocation:

$ ~/dev/javascript/testing/phantomjs-git/bin/phantomjs --enable-java=yes netlogo.js; open netlogo.png

I get this displayed in the console:

Page title is "NetLogo Applet"

Stephen Bannasch

unread,
Mar 4, 2012, 3:40:39 PM3/4/12
to phan...@googlegroups.com
Last comment on this bug report:

Java applets do not work in Qt's QWebView widget
https://bugreports.qt-project.org/browse/QTBUG-19720

Just tried this on Windows 7 with Qt 4.8 Beta - turn on
plugins and Java applets in the settings and it works flawlessly.
Appears fixed, so the documentation should be updated...

I tried adding: --load-plugins=yes and got the same result -- the rendering shows no evidence of an applet -- or even an applet
element.

$ phantomjs --enable-java=yes --load-plugins=yes netlogo.js; open netlogo.png

The applet element is styled with a border -- but that isn't visible either.

Ariya Hidayat

unread,
Mar 5, 2012, 12:22:06 AM3/5/12
to phan...@googlegroups.com
> see: https://github.com/stepheneb/phantomjs/commit/d42711cfc9d2f9
>
> I'd like to be able to use ShadowJS to support testing JavaScript <=> Java
> Applet communication.

ShadowJS? Do you really mean PhantomJS or some other related application?

--
Ariya Hidayat, http://ariya.ofilabs.com

Stephen Bannasch

unread,
Mar 5, 2012, 8:18:17 AM3/5/12
to phan...@googlegroups.com
At 9:22 PM -0800 3/4/12, Ariya Hidayat wrote:
> > see: https://github.com/stepheneb/phantomjs/commit/d42711cfc9d2f9
>>
>> I'd like to be able to use ShadowJS to support testing JavaScript <=> Java
>> Applet communication.
>
>ShadowJS? Do you really mean PhantomJS or some other related application?

I mean PhantonJS ;-) Somehow "Shadow" and "Phantom" are crossed up in my head.

But the code here is based on PhantomJS:

https://github.com/stepheneb/phantomjs/commit/d42711cfc9d2f9

Reply all
Reply to author
Forward
0 new messages