Creating an instance of a FireBreath plugin using ActiveXObject - firebreath

I am using FireBreath to create a cross browser plugin. In the HTML test page i am using the following function to detect whether the plugin is installed and to initiate a download of the MSI installer if the plugin is not detected.
function checkPlugin(){
var pluginInstalled = false;
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
// For IE
var pluginObject = null;
try {
pluginObject = new ActiveXObject('Test.TestPlugin');
if(pluginObject){
pluginInstalled = true;
//pluginObject.Dispose();
}
} catch (e) {
// Cannot load the plugin. Most probably it's not installed
console.log(e.message);
}
}else{
// For other browsers
pluginInstalled = (navigator.mimeTypes && navigator.mimeTypes["application/x-test"] && navigator.plugins["TestPlugin"]);
}
return pluginInstalled;
}
Above function works fine on all other browsers except for IE. It causes both IE 9 and 10 to crash when it attempts to create an instance of the plugin using ActiveXObject. I have noted that support for this functionality was added from FireBreath 1.4 onwards but I believe i am using the latest version of FireBreath which is 1.7. Any assistance in solving this issue is greatly appreciated :)

That looks like the method used in the FireBreath javascript detection example, and that's what I'm using in my plugins. You weren't entirely clear on what version you're using; are you on 1.7? It works for me on 1.6 and 1.7 for sure.
If you could be a little more specific about where it crashes that might be easier to make some speculations; try attaching a debugger. For information on how to force IE to be single process to make attaching a debugger see the "Debugging Plugins" page on firebreath.org.

Related

welcome page loads when Allow in incognito is checked/unchecked in Chrome

I am new to chrome extensions.I used chrome.runtime.onInstalled to load a html page whenever the extension is installed or updated.But when i am testing it in chrome, whenever i check/uncheck Allow in incognito the same html page loads each time.How to avoid this behaviour? I used "incognito":"split" in manifest.
I wish you'd posted the code so I could try to replicate the problem and give a specific solution but the easy solution is to use chrome storage API to save the extension's version when welcome.html is opened and compare it to the current version next time onInstalled is fired.
If the stored version is the same don't open it. If it's undefined or older, open it.
Get your extension's version by extracting it from chrome.extension.getURL("manifest.json")
Edit:
After a bit of googling it seems you can access the manifest more directly. Get the version number using the code below.
var version = chrome.runtime.getManifest().version;
Edit:
It seems the previous version is supplied in the callback when you update so you don't need to store anything. The object provided can be compared to the current version using chrome.runtime.getManifest().version
Something like this:
chrome.runtime.onInstalled.addListener(function (details) {
if(details.reason === "install"){
chrome.tabs.create({url: "welcome.html"});
}
else if(details.reason === "update"){
var currentVersion = chrome.runtime.getManifest().version;
var previousVersion = details.previousVersion;
if(previousVersion !== currentVersion){
chrome.tabs.create({url: "welcome.html"});
}
}
});
I don't think you can. I assume that when you uncheck "Allow in incognito", Chrome nukes the local state of the (split) incognito instance.

Libgdx AndroidApplication native(?) crash

I have a strange problem. I use a nightly from last week. If I recall correctly it's from 23/3.
What happens is that I run a Libgdx Activity and it runs fine. Than I finish the app. I start the libgdx activity again and it crashes... This happens a lot but not all the time.
In debug mode it doesn't happen at all. Any ideas? It doesn't print any crash log but I think it has something to do with this log: http://pastebin.com/3BFrjbES
My code doesn't do any thing special right now. It's just printing the FPS in a stage....
I think there is an error in the log that may be connected: EGL error: EGL_BAD_CONTEXT.
This is printed just before the previous log.
Thanks.
What does "finish the app" mean? A pause (pressing home) or a destroy?
I wonder if it is any way related to LibGDX attempting to preserve the EGL Context. The default for Android is to not preserve it but LibGDX attempts to enable it if you are on SDK >= 11. You could try to disable preservation in your AndroidApplication subclass by doing something like:
View view = ((AndroidGraphics)Gdx.graphics).getView();
try {
Method method = null;
for (Method m : view.getClass().getMethods()) {
if (m.getName().equals("setPreserveEGLContextOnPause")) {
method = m;
break;
}
}
if (method != null) {
method.invoke((GLSurfaceView20)view, false);
}
} catch (Exception e) {
}
I found out the problem. The problem disappeared after I removed hardwareAccelaration="true" from my application tag in the manifest. I don't know why it matters as my device is 4.0.4 which means that it's enabled by default.

chrome.app.getDetails() returns null

I was trying to get the version of my extension at run-time using chrome.app.getDetails().version and noticed that chrome.app.getDetails() returns null. Surprisingly, there is no talk about this in the online community and the function isn't even documented by the Google folks. Is there a permission I am missing? I do have tabs enabled.
Very old... I know
But in case if someone is looking for this, you can have your extension version reading the manifest file with chrome.runtime API and the getManifest Method.
Ex. in your background script:
var manifest = chrome.runtime.getManifest();
var current_version = manifest.version;
console.info('Current Version: ', current_version);
The object returned is a serialization of the full manifest file, so you can get all the info in the manifest file
So.. if you want for example all and only the matches of your content_scripts... for say something...
for(var i in manifest.content_scripts) {
console.log(manifest.content_scripts[i]['matches']));
}
Note: Stable since Chrome 22
It's undocumented because they might be moving getDetails to a different part of the API -- see this bug. It's currently working on my copy of Chrome (beta channel), but I wouldn't be surprised if they've disabled it in a newer release. In the meantime you can just do an AJAX query to get the manifest.json of your extension -- you can get its URI using chrome.extension.getURL("manifest.json").
Here is what I'm using to pull the current version.
var manifest = new XMLHttpRequest();
manifest.open("get", "/manifest.json", true);
manifest.onreadystatechange = function (e) { if (manifest.readyState == 4) {console.log(JSON.parse(manifest.responseText).version)} };
manifest.send({});

NPAPI plugin does not show in about:plugins in google chrome

I have gone through the questions in this forum regarding this issues, but I have not found any query related to the kind of issue that I am facing. I have written a NPAPI plugin which works fine with GtkLauncher (comes with webkit) and firefox, but with google-chrome (18.0.1025.151), the plugin is not even showing up in about:plugins. I am running on Ubuntu 10.10.
When I am loading the plugin in google-chrome, in the browser I am getting failed to load plugin error but nothing is shown on the console. I doubt whether my NP_Initialize function is getting called.
Here is the NP_Initialize code:
-------------------------------
NPError OSCALL
NP_Initialize(NPNetscapeFuncs *npnf
#if !defined(_WINDOWS) && !defined(WEBKIT_DARWIN_SDK)
, NPPluginFuncs *nppfuncs)
#else
)
#endif
{
MEDIA_DEBUG_PRINT("\nwcf Media plugin: NP_Initialize");
if(npnf == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
if(HIBYTE(npnf->version) > NP_VERSION_MAJOR)
return NPERR_INCOMPATIBLE_VERSION_ERROR;
npnfuncs = npnf;
#if !defined(_WINDOWS) && !defined(WEBKIT_DARWIN_SDK)
NP_GetEntryPoints(nppfuncs);
#endif
return NPERR_NO_ERROR;
}
NPError OSCALL
NP_GetEntryPoints(NPPluginFuncs *nppfuncs)
{
MEDIA_DEBUG_PRINT("\nwcf Media plugin: NP_GetEntryPoints");
nppfuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
nppfuncs->newp = nevv;
nppfuncs->destroy = destroy;
nppfuncs->getvalue = getValue;
nppfuncs->event = handleEvent;
nppfuncs->setwindow = setWindow;
return NPERR_NO_ERROR;
}
I know there is a Firebreath framework for cross browser development which I have plan to use but at present I need to get my plugin running on chrome.
Can some one please help me to solve my issue?
Thanks and Regards,
Souvik
Chrome tends to be a bit pickier about how things start up. I don't see anything here that would be likely to cause your issue, but Chrome is notorious for rejecting plugins that don't behave as it expects. Most likely your issue is later on; you say you doubt that your NP_Initialize is getting called, if I were you I'd verify that. Have it write to a file in /tmp/ or something to make sure.
Also you haven't provided any of your other entrypoints such as NP_GetPluginVersion or NP_GetMimeDescription. Those are needed as well for a linux plugin and could very possibly be responsible for an issue like this. For reference, take a look at FireBreath's X11 entrypoint file.
Finally, it's possible that the way you installed the plugin it is found by mozilla and not by chrome; how did you install it?
If your plugin isn't showing in chrome://plugins, then it's failing during the initial plugin scan. Try running with the --debug-plugin-loading flag, which should give you a log statement at the point where registering your plugin is failing.

IndexedDB onversionchange event not fired in Chrome

I'm playing with the IndexedDB API from html5 spec in both Firefox and Chrome.
There something that's not working as expected I and want to share it here because I don't know if it's my fault or a browser bug.
According to the API, there's an event called onversionchange that's fired when you open a connection to a local database and the version number used is greater than the databases one.
My problem is that this event is being fired in Firefox but not in Chrome.
Some sample code trying several modes:
var db;
var DB_VERSION = 5;
var openRequest = indexedDB.open("test_db", DB_VERSION);
openRequest.onsuccess = function(event) {
db = openRequest.result;
};
openRequest.onversionchange = function(event) {
console.log("This is the place where I can change db structure");
};
openRequest.onupgradeneeded = function(event) {
console.log("This is the place where I can change db structure");
};
onversionchage event is not being fired even when I change the version number.
UPDATE
As ebidel has answered, Chrome implementation does not follow the currently specification so, in order to have a cross browser client code, we need to handle two situations: onversionchange event and database.version manual comparison.
Here are a couple on links with code example:
Chromium google group and
HTML5 Rocks!
Chrome's IndexedDB implementation is based off an older version of the spec which uses the older setVersion call rather than onversionchange/onupgradeneeded. Please star this issue: http://crbug.com/108223