Timing bug calling navigator.javaEnabled() after calling navigator.plugins.refresh()

RESOLVED WONTFIX

Status

()

Core
Plug-ins
RESOLVED WONTFIX
10 years ago
a year ago

People

(Reporter: Ben D, Unassigned)

Tracking

({regression})

Trunk
regression
Points:
---
Bug Flags:
wanted1.9.1 ?

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

10 years ago
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9) Gecko/2008061004 Firefox/3.0
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9) Gecko/2008061004 Firefox/3.0

In Firefox 3, there appears to be a timing bug related to calling navigator.javaEnabled() immediately after calling navigator.plugins.refresh().  This happens on both Windows and Mac OS X platforms.  

I have Java installed and enabled, and an independent calling of navigator.javaEnabled() returns true.  However, if I call navigator.javaEnabled() immediately after calling navigator.plugins.refresh(false), about 15% of the time javaEnabled() returns false.  When this happens, the global "java" object is also undefined.

We never saw this behavior with Firefox 2, and I searched around, to no avail, for documentation on any changes in Firefox 3 related to this, thinking refresh() may have become asynchronous or something similar.

I also tried waiting until after the window load event, and the onDomContentLoaded event, but that didn't make any difference either.  It also doesn't matter if you run this script in the HEAD or in the BODY.

Reproducible: Sometimes

Steps to Reproduce:
1. Make sure Java is installed and enabled
2. Call navigator.plugins.refresh(false)
3. Immediately afterwards, alert navigator.javaEnabled() and check the global "java" object. 

<script type="text/javascript">
navigator.plugins.refresh(false);
var j = navigator.javaEnabled();
		
alert("Java Enabled: " + j);
</script>
Actual Results:  
Roughly 15% of the time "false" is the return value and "java" is undefined.  The rest of the time "true" is returned and "java" is defined.

Expected Results:  
I would have expected "true" to be returned all of the time and the global java object to be defined.

To workaround this bug we stopped using javaEnabled() and iterated through the navigator.plugins array manually looking for the Java plugin (since the entry remains in there even during the times this bug is manifested).
Status: UNCONFIRMED → NEW
Component: General → Plug-ins
Ever confirmed: true
Keywords: regression
Product: Firefox → Core
QA Contact: general → plugins
Version: unspecified → 1.9.0 Branch
Flags: wanted1.9.1?
Flags: wanted1.9.0.x?
Doesn't really meet the "wanted" criteria (security, stability, regression from maintenance release) for 1.9.0.x. However, we'll look at a reviewed and baked patch.

We need an owner here though.
Flags: wanted1.9.0.x?
Version: 1.9.0 Branch → Trunk

Comment 2

10 years ago
Ben, would you mind to post your workaround here please.

For me I have a similar problem in FF3: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.2) Gecko/2008092318 Fedora/3.0.2-1.fc9 Firefox/3.0.2

"javaEnabled" succeeds until an applet is started and fails afterward all the time. This is probable an other issue. I will look if I can get deeper into it, to see if it is related to the java version or kind of plugin.
(Reporter)

Comment 3

10 years ago
Thomas, here's a function you can use to iterate through the plugins list looking for the Java plugin.

function hasJavaPlugin()
{
	for (var i=0, nplen = navigator.plugins.length; i < nplen; i++)
	{
	    var plugin = navigator.plugins[i];
	    if (!plugin || plugin.name.toLowerCase().indexOf('java') == -1)
	    {
	        continue;
	    }
	    for (var j=0, pl = plugin.length; j < pl; j++)
	    {
	        var mimetype = plugin[j];
	        if (!mimetype)
	        {
	            continue;
	        }
	        if (mimetype.type && mimetype.type.toLowerCase().indexOf('java-applet') != -1)
	        {
	            return true;
	        }
	    }
	}

	// we have no reason to believe that Java is available
	return false;
}
I'm marking this bug as WONTFIX per bug #1269807.

For more information see - https://blog.mozilla.org/futurereleases/2015/10/08/npapi-plugins-in-firefox/
Status: NEW → RESOLVED
Last Resolved: a year ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.