/hg/icedtea6: 2 new changesets
dbhole at icedtea.classpath.org
dbhole at icedtea.classpath.org
Tue Feb 2 13:21:33 PST 2010
changeset a2659c8bb3c4 in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=a2659c8bb3c4
author: Deepak Bhole <dbhole at redhat.com>
date: Tue Feb 02 16:16:48 2010 -0500
- Re-designed frame embedding code so that the applet is dynamically
packed into given handle. This increases stability and breaks
reliance on the assumption that the browser will always provide a
handle in a certain sequence.
changeset f8d8f6b0a1fd in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=f8d8f6b0a1fd
author: Deepak Bhole <dbhole at redhat.com>
date: Tue Feb 02 16:21:26 2010 -0500
Added tests for JSObject.eval()
diffstat:
6 files changed, 1263 insertions(+), 1138 deletions(-)
ChangeLog | 14
plugin/icedteanp/java/sun/applet/PluginAppletViewer.java | 2314 +++++++-------
plugin/tests/LiveConnect/PluginTest.java | 11
plugin/tests/LiveConnect/common.js | 3
plugin/tests/LiveConnect/index.html | 2
plugin/tests/LiveConnect/jjs_eval_test.js | 57
diffs (truncated from 2841 to 500 lines):
diff -r cc7232b07731 -r f8d8f6b0a1fd ChangeLog
--- a/ChangeLog Tue Feb 02 14:50:43 2010 +0100
+++ b/ChangeLog Tue Feb 02 16:21:26 2010 -0500
@@ -1,3 +1,17 @@ 2010-02-02 Pavel Tisnovsky <ptisnovs at red
+2010-02-02 Deepak Bhole <dbhole at redhat.com>
+
+ * plugin/tests/LiveConnect/PluginTest.java
+ (jjsEvalTest): New function. Calls JSObject.eval() with given string.
+ * plugin/tests/LiveConnect/common.js: Added eval test suite as one of the
+ run options.
+ * plugin/tests/LiveConnect/index.html: Same.
+ * plugin/tests/LiveConnect/jjs_eval_test.js: Eval tests.
+
+2010-02-02 Deepak Bhole <dbhole at redhat.com>
+
+ * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java: Re-designed frame
+ embedding code so that the applet is dynamically packed into given handle.
+
2010-02-02 Pavel Tisnovsky <ptisnovs at redhat.com>
* Makefile.am: Add new patches.
diff -r cc7232b07731 -r f8d8f6b0a1fd plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Tue Feb 02 14:50:43 2010 +0100
+++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Tue Feb 02 16:21:26 2010 -0500
@@ -91,6 +91,7 @@ import java.net.URI;
import java.net.URI;
import java.net.URL;
import java.security.AccessController;
+import java.security.AllPermission;
import java.security.PrivilegedAction;
import java.util.Enumeration;
import java.util.HashMap;
@@ -114,598 +115,170 @@ import com.sun.jndi.toolkit.url.UrlUtil;
* Lets us construct one using unix-style one shot behaviors
*/
- class PluginAppletViewerFactory
+ class PluginAppletPanelFactory
{
- public PluginAppletViewer createAppletViewer(int identifier,
- long handle, int x, int y,
- URL doc, Hashtable atts) {
- PluginAppletViewer pluginappletviewer = new PluginAppletViewer(identifier, handle, x, y, doc, atts, System.out, this);
- return pluginappletviewer;
+
+ public AppletPanel createPanel(PluginStreamHandler streamhandler,
+ int identifier,
+ long handle, int x, int y,
+ final URL doc, final Hashtable atts) {
+
+ AppletViewerPanel panel = (AppletViewerPanel) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ try {
+ AppletPanel panel = new NetxPanel(doc, atts, false);
+ AppletViewerPanel.debug("Using NetX panel");
+ PluginDebug.debug(atts.toString());
+ return panel;
+ } catch (Exception ex) {
+ AppletViewerPanel.debug("Unable to start NetX applet - defaulting to Sun applet", ex);
+ return new AppletViewerPanel(doc, atts);
+ }
+ }
+ });
+
+ double heightFactor = 1.0;
+ double widthFactor = 1.0;
+
+ if (atts.get("heightPercentage") != null) {
+ heightFactor = (Integer) atts.get("heightPercentage")/100.0;
+ }
+
+ if (atts.get("widthPercentage") != null) {
+ widthFactor = (Integer) atts.get("widthPercentage")/100.0;
+ }
+
+
+ // put inside initial 0 handle frame
+ PluginAppletViewer.reFrame(null, identifier, System.out,
+ heightFactor, widthFactor, 0, panel);
+
+ panel.init();
+
+ // Start the applet
+ initEventQueue(panel);
+
+ // Applet initialized. Find out it's classloader and add it to the list
+ String portComponent = doc.getPort() != -1 ? ":" + doc.getPort() : "";
+ String codeBase = doc.getProtocol() + "://" + doc.getHost() + portComponent;
+
+ if (atts.get("codebase") != null) {
+ try {
+ URL appletSrcURL = new URL(codeBase + (String) atts.get("codebase"));
+ codeBase = appletSrcURL.getProtocol() + "://" + appletSrcURL.getHost();
+ } catch (MalformedURLException mfue) {
+ // do nothing
+ }
+ }
+
+
+ // Wait for the panel to initialize
+ // (happens in a separate thread)
+ Applet a;
+
+ // Wait for panel to come alive
+ int maxWait = 5000; // wait 5 seconds max for panel to come alive
+ int wait = 0;
+ while ((panel == null) || (!((NetxPanel) panel).isAlive() && wait < maxWait)) {
+ try {
+ Thread.sleep(50);
+ wait += 50;
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // Wait for the panel to initialize
+ // (happens in a separate thread)
+ while (panel.getApplet() == null &&
+ ((NetxPanel) panel).isAlive()) {
+ try {
+ Thread.sleep(50);
+ PluginDebug.debug("Waiting for applet to initialize...");
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ a = panel.getApplet();
+
+ // Still null?
+ if (panel.getApplet() == null) {
+ streamhandler.write("instance " + identifier + " reference " + -1 + " fatalError " + "Initialization failed");
+ return null;
+ }
+
+ PluginDebug.debug("Applet " + a.getClass() + " initialized");
+ streamhandler.write("instance " + identifier + " initialized");
+
+ AppletSecurityContextManager.getSecurityContext(0).associateSrc(((NetxPanel) panel).getAppletClassLoader(), doc);
+ AppletSecurityContextManager.getSecurityContext(0).associateInstance(identifier, ((NetxPanel) panel).getAppletClassLoader());
+
+ return panel;
}
public boolean isStandalone()
{
return false;
}
- }
-
- class PluginParseRequest
- {
- long handle;
- String tag;
- String documentbase;
- }
-
- /*
- */
- // FIXME: declare JSProxy implementation
- public class PluginAppletViewer extends XEmbeddedFrame
- implements AppletContext, Printable {
- /**
- * Some constants...
- */
- private static String defaultSaveFile = "Applet.ser";
-
- private static enum PAV_INIT_STATUS {PRE_INIT, ACTIVE, INACTIVE};
-
- /**
- * The panel in which the applet is being displayed.
- */
- AppletViewerPanel panel;
-
- /**
- * The status line.
- */
- Label label;
-
- /**
- * output status messages to this stream
- */
-
- PrintStream statusMsgStream;
-
- /**
- * For cloning
- */
- PluginAppletViewerFactory factory;
-
- int identifier;
-
- private static HashMap<Integer, PluginParseRequest> requests =
- new HashMap();
-
- // Instance identifier -> PluginAppletViewer object.
- private static HashMap<Integer, PluginAppletViewer> applets =
- new HashMap();
-
- private static PluginStreamHandler streamhandler;
-
- private static PluginCallRequestFactory requestFactory;
-
- private static HashMap<Integer, PAV_INIT_STATUS> status =
- new HashMap<Integer,PAV_INIT_STATUS>();
-
- private double proposedHeightFactor;
- private double proposedWidthFactor;
-
- /**
- * Null constructor to allow instantiation via newInstance()
- */
- public PluginAppletViewer() {
- }
-
- /**
- * Create the applet viewer
- */
- public PluginAppletViewer(final int identifier, long handle, int x, int y, final URL doc,
- final Hashtable atts, PrintStream statusMsgStream,
- PluginAppletViewerFactory factory) {
- super(handle, true);
- this.factory = factory;
- this.statusMsgStream = statusMsgStream;
- this.identifier = identifier;
- // FIXME: when/where do we remove this?
- PluginDebug.debug ("PARSING: PUTTING " + identifier + " " + this);
- applets.put(identifier, this);
-
-
- // we intercept height and width specifications here because
- proposedHeightFactor = 1.0;
- proposedWidthFactor = 1.0;
-
- if (atts.get("heightPercentage") != null) {
- proposedHeightFactor = (Integer) atts.get("heightPercentage")/100.0;
- }
-
- if (atts.get("widthPercentage") != null) {
- proposedWidthFactor = (Integer) atts.get("widthPercentage")/100.0;
- }
-
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- try {
- panel = new NetxPanel(doc, atts, false);
- AppletViewerPanel.debug("Using NetX panel");
- PluginDebug.debug(atts.toString());
- } catch (Exception ex) {
- AppletViewerPanel.debug("Unable to start NetX applet - defaulting to Sun applet", ex);
- panel = new AppletViewerPanel(doc, atts);
- }
- return null;
- }
- });
-
- add("Center", panel);
- panel.init();
- appletPanels.addElement(panel);
-
- pack();
-
- // 0 handle implies 0x0 plugin, don't show it else it creates an entry in the window list
- if (handle != 0)
- setVisible(true);
-
- WindowListener windowEventListener = new WindowAdapter() {
-
- public void windowClosing(WindowEvent evt) {
- appletClose();
- }
-
- public void windowIconified(WindowEvent evt) {
- appletStop();
- }
-
- public void windowDeiconified(WindowEvent evt) {
- appletStart();
- }
- };
-
- class AppletEventListener implements AppletListener
- {
- final Frame frame;
-
- public AppletEventListener(Frame frame)
- {
- this.frame = frame;
- }
-
- public void appletStateChanged(AppletEvent evt)
- {
- AppletPanel src = (AppletPanel)evt.getSource();
-
- switch (evt.getID()) {
- case AppletPanel.APPLET_RESIZE: {
- if(src != null) {
- resize(preferredSize());
- validate();
- }
- break;
- }
- case AppletPanel.APPLET_LOADING_COMPLETED: {
- Applet a = src.getApplet(); // sun.applet.AppletPanel
-
- // Fixed #4754451: Applet can have methods running on main
- // thread event queue.
- //
- // The cause of this bug is that the frame of the applet
- // is created in main thread group. Thus, when certain
- // AWT/Swing events are generated, the events will be
- // dispatched through the wrong event dispatch thread.
- //
- // To fix this, we rearrange the AppContext with the frame,
- // so the proper event queue will be looked up.
- //
- // Swing also maintains a Frame list for the AppContext,
- // so we will have to rearrange it as well.
- //
- if (a != null)
- AppletPanel.changeFrameAppContext(frame, SunToolkit.targetToAppContext(a));
- else
- AppletPanel.changeFrameAppContext(frame, AppContext.getAppContext());
-
- break;
- }
- }
- }
- };
-
- addWindowListener(windowEventListener);
- panel.addAppletListener(new AppletEventListener(this));
-
- // Start the applet
- showStatus(amh.getMessage("status.start"));
- initEventQueue();
-
- // Wait for the panel to initialize
- // (happens in a separate thread)
- Applet a;
-
- // Wait for panel to come alive
- int maxWait = 5000; // wait 5 seconds max for panel to come alive
- int wait = 0;
- while ((panel == null) || (!((NetxPanel) panel).isAlive() && wait < maxWait)) {
- try {
- Thread.sleep(50);
- wait += 50;
- } catch (InterruptedException ie) {
- ie.printStackTrace();
- }
- }
-
- // Wait for the panel to initialize
- // (happens in a separate thread)
- while (panel.getApplet() == null &&
- ((NetxPanel) panel).isAlive()) {
- try {
- Thread.sleep(50);
- PluginDebug.debug("Waiting for applet to initialize...");
- } catch (InterruptedException ie) {
- ie.printStackTrace();
- }
- }
-
- a = panel.getApplet();
-
- // Still null?
- if (panel.getApplet() == null) {
- this.streamhandler.write("instance " + identifier + " reference " + -1 + " fatalError " + "Initialization failed");
- return;
- }
-
- PluginDebug.debug("Applet " + a.getClass() + " initialized");
-
- // Applet initialized. Find out it's classloader and add it to the list
- String portComponent = doc.getPort() != -1 ? ":" + doc.getPort() : "";
- String codeBase = doc.getProtocol() + "://" + doc.getHost() + portComponent;
-
- if (atts.get("codebase") != null) {
- try {
- URL appletSrcURL = new URL(codeBase + (String) atts.get("codebase"));
- codeBase = appletSrcURL.getProtocol() + "://" + appletSrcURL.getHost();
- } catch (MalformedURLException mfue) {
- // do nothing
- }
- }
-
- AppletSecurityContextManager.getSecurityContext(0).associateSrc(((NetxPanel) panel).getAppletClassLoader(), doc);
- AppletSecurityContextManager.getSecurityContext(0).associateInstance(identifier, ((NetxPanel) panel).getAppletClassLoader());
-
- try {
- write("initialized");
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
-
- }
-
- public static void setStreamhandler(PluginStreamHandler sh) {
- streamhandler = sh;
- }
-
- public static void setPluginCallRequestFactory(PluginCallRequestFactory rf) {
- requestFactory = rf;
- }
-
- /**
- * Handle an incoming message from the plugin.
- */
- public static void handleMessage(int identifier, int reference, String message)
- {
-
- PluginDebug.debug("PAV handling: " + message);
-
- try {
- if (message.startsWith("tag")) {
-
- // tag and handle must both be set before parsing, so we need
- // synchronization here, as the setting of these variables
- // may happen in independent threads
-
- synchronized(requests) {
-
- // Check if we should proceed with init
- // (=> no if destroy was called after tag, but before
- // handle)
- if (status.containsKey(identifier) &&
- status.get(identifier).equals(PAV_INIT_STATUS.INACTIVE)) {
-
- PluginDebug.debug("Inactive flag set. Refusing to initialize instance " + identifier);
- requests.remove(identifier);
- return;
-
- }
-
- status.put(identifier, PAV_INIT_STATUS.PRE_INIT);
-
- PluginParseRequest request = requests.get(identifier);
- if (request == null) {
- request = new PluginParseRequest();
- requests.put(identifier, request);
- }
- int index = message.indexOf(' ', "tag".length() + 1);
- request.documentbase =
- UrlUtil.decode(message.substring("tag".length() + 1, index));
- request.tag = message.substring(index + 1);
- PluginDebug.debug ("REQUEST TAG: " + request.tag + " " +
- Thread.currentThread());
-
- if (request.handle != 0) {
- PluginDebug.debug ("REQUEST TAG, PARSING " +
- Thread.currentThread());
- PluginAppletViewer.parse
- (identifier, request.handle,
- new StringReader(request.tag),
- new URL(request.documentbase));
- requests.remove(identifier);
-
- // Panel initialization cannot be aborted mid-way.
- // Once it is initialized, double check to see if this
- // panel needs to stay around..
- if (status.get(identifier).equals(PAV_INIT_STATUS.INACTIVE)) {
- PluginDebug.debug("Inactive flag set. Destroying applet instance " + identifier);
- applets.get(identifier).handleMessage(-1, "destroy");
- } else {
- status.put(identifier, PAV_INIT_STATUS.ACTIVE);
- }
-
- } else {
- PluginDebug.debug ("REQUEST HANDLE NOT SET: " + request.handle + ". BYPASSING");
- }
- }
-
- } else if (message.startsWith("handle")) {
- synchronized(requests) {
-
- // Check if we should proceed with init
- // (=> no if destroy was called after handle, but before
- // tag)
- if (status.containsKey(identifier) &&
- status.get(identifier).equals(PAV_INIT_STATUS.INACTIVE)) {
-
- PluginDebug.debug("Inactive flag set. Refusing to initialize instance " + identifier);
- requests.remove(identifier);
- return;
-
- }
-
- status.put(identifier, PAV_INIT_STATUS.PRE_INIT);
-
- PluginParseRequest request = requests.get(identifier);
- if (request == null) {
- request = new PluginParseRequest();
- requests.put(identifier, request);
- }
- request.handle = Long.parseLong
- (message.substring("handle".length() + 1));
- PluginDebug.debug ("REQUEST HANDLE: " + request.handle);
- if (request.tag != null) {
More information about the distro-pkg-dev
mailing list