1

In Firefox 16, java can no longer be accessed using the global instance as per https://bugzilla.mozilla.org/show_bug.cgi?id=748343.

I have built a custom selenium-ide.xpi (http://seleniumhq.org/download/) which loads up java and runs through my custom framework. To access java I added an addJava.js file, which I included in the selenium-ide-common.xul file calling the java using something like what is found at https://developer.mozilla.org/en-US/docs/Java_in_Firefox_Extensions, however this no longer works.

I've tried the following to fix the issue:

Adding the below to the various .xul files, but each time I try the below I get that appletRef is null:

<div name="appletDiv">
    <embed id ="cipherDocsApplet" type="application/x-java-applet;version=1.6" code="java.applet.Applet"  pluginspage="http://java.com/download/"  MAYSCRIPT="true" width="0" height="0" />  
</div>

var appletRef = document.getElementById("cipherDocsApplet");
window.java = appletRef.Packages.java;

The below gives me java_instance.Packages is undefined.

var java_instance = window.document.createElementNS("http://www.w3.org/1999/xhtml","applet");
     java_instance.setAttribute("id", "adsfund_java_instance");
     java_instance.setAttribute("code", "java.applet.Applet");
     java_instance.setAttribute("width", "0");
     java_instance.setAttribute("height", "0");
     java_instance.setAttribute("flex", "1");

var div = window.document.createElementNS("http://www.w3.org/1999/xhtml","div");
var elementToAppendTo = window.document.getElementsByTagName("vbox")[0];
elementToAppendTo.appendChild(div);
div.appendChild(java_instance); 
var date = new java_instance.Packages.java.util.Date();

Finally I tried https://bug748343.bugzilla.mozilla.org/attachment.cgi?id=655062, adding the app element to my main xul file and getting it later, but that also gives me the same error: 'TypetError:app.Packages is undefined.'

Does anyone know how to fix this?

Thanks in advance, James

James
  • 589
  • 1
  • 6
  • 15

1 Answers1

0

You are doing this the hard way IMHO. Using WebDriver (part of Selenium2 framework), you can dynamically load a Java .xpi extension by loading a custom Firefox profile.

For example:

File file = new File("firebug-1.8.1.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1");
WebDriver driver = new FirefoxDriver(firefoxProfile);

What you have come up with is not typical and I doubt many people could answer your question because of that.

Also, if later versions of Firefox have disabled "LiveConnect" capability, then what reason do you have to try to force a unsupported browser to support that feature by javascript injection?

djangofan
  • 28,471
  • 61
  • 196
  • 289