I'm into application cache related work in HTML5. I've added addCacheListeners() in body onload. This works fine with mobile safari and chrome, but NOT with android browser. when it comes to the android browser, error event is fired.
function addCacheListeners(){
var appCache=window.applicationCache;
if(appCache!== 'undefined'){
alert("defined");
appCache.addEventListener('checking', function(e){
}, false);
appCache.addEventListener('progress', function(e){
}, false);
appCache.addEventListener('updateready', function(e) {
alert("update is ready");
if (appCache.status == appCache.UPDATEREADY){
appCache.swapCache();
updateappInfo();
}
}, false);
appCache.addEventListener('noupdate', function(e){
updateappInfo();
}, false);
appCache.addEventListener('error', function(e){
alert("error" + e.message);
}, false);
appCache.addEventListener('cached', function(e){
alert("cached");
updateappInfo();
}, false);
}
if (appCache=== 'undefined'){alert("undefined");}
}
Any idea with regards to this?
Thanks a bunch.
This issue is with only Android browser as it does not support ‘.manifest’ extension without having MIME type configuration in the hosted server.
Therefore, tried out adding ‘.manifest’ as one of the MIME types, but this was failed as it does not support as a MIME type which is already attached with another reference.
Adding ‘.appcache’ or ‘apache’ was made it functional.
<mimeMapfileExtension=".apache"mimeType="text/cache-manifest" />
(source: Load cache manifest file)
Related
Our chrome extension does not work correctly anymore since version 37.0.2062.103 (It used to work correctly on chrome version 36.0.1985.143).
Specifically, the debugger API has stopped working for us when we use the DOMDebugger.
See the attached code: (background.js)
chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab){
if( changeInfo.status == "loading" && tab.active){
var debugId = {tabId:tabId};
chrome.debugger.attach(debugId, '1.0', function() {
chrome.debugger.sendCommand(debugId, 'Debugger.enable', {}, function() {
chrome.debugger.sendCommand(debugId, "DOMDebugger.setEventListenerBreakpoint", {'eventName':'click'},
function(result) {
console.log('registering click');
});
});
});
}
});
chrome.debugger.onEvent.addListener(onEvent);
function onEvent(debuggeeId, method,params) {
if(method=="Debugger.paused"){
console.log('DONE!');
}
};
The extension successfully starts the debugger. we get the yellow debugger ribbon.
We also see the 'registering click' msg in the console. the result argument is an empty object {} (line 8).
However upon clicking on a button that has a click event listener nothing happens.
It used to work without any issues.
It seems like it regressed with https://codereview.chromium.org/305753005. One needs to call "DOM.enable" for it to work now. On the Chrome side, we should implicitly enable DOM domain upon setEventListenerBreakpoint for backwards compatibility. Unfortunately it already squeezed into the stable release.
I've got some js code in a chrome background extension of the following :
function handleCapture(stream) {
console.log('content captured');
console.log("backround.js stream: ", stream);
alert(stream);
// localStream = stream; // used by RTCPeerConnection addStream();
// initialize(); // start signalling and peer connection process
}
function captureCurrentTab() {
console.log('reqeusted current tab');
chrome.tabs.getSelected(null, function(tab) {
console.log('got current tab');
var selectedTabId = tab.id;
chrome.tabCapture.capture({
audio : false,
video : true
}, handleCapture);
});
}
However, when this is ran, the "handleCapture" variable "stream" that is passed in is always undefined? Is this to be expected or is there something that I am missing here?
Also, I've confirmed that my manifest.json contains the capture permission and I am using chrome canary Version 31.0.1607.1 canary Aura.
Thanks,
Mike
I had this same issue when I was trying to drive a tabCapture purely from a background script, I found this on the tabCapture reference page:
Captures the visible area of the currently active tab. This method can only be used on the currently active page after the extension has been invoked, similar to the way that activeTab works. Note that Chrome internal pages cannot be captured.
My understanding is that this means you need to drive it from a browserAction for your extension, like so:
chrome.browserAction.onClicked.addListener(function(request) {
chrome.tabs.getSelected(null, function(tab) {
chrome.tabCapture.capture({audio: true, video: true}, callback);
});
});
That's what worked for me.
You should probably provide some constraints to make it work. See:
http://developer.chrome.com/extensions/tabCapture.html#type-MediaStreamConstraint
The capture param you provided is a MediaTrackConstraint, see:
http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastreamconstraints
that is also a simple JS object, where you should set some mandatory options, see:
http://dev.w3.org/2011/webrtc/editor/getusermedia.html#idl-def-MediaTrackConstraints
So the following should help, if you set all the needed settings in mandatory object:
chrome.tabCapture.capture({
audio : false,
video : true,
videoConstraints: {
mandatory: {
width: { min: 640 },
height: { min: 480 }
}
}
}, handleCapture);
I have created browser extension/add-on for Chrome, Firefox, Safari and IE using Crossrider framework
Now since Crossrider does not provide support for Opera, I have created a native extension for the same.
My problem is how to detect if a user(using Opera), visiting our website, has the extension installed or not ?
Similar Question is answered. Is there any better option?
Or any simple way to check(crossbrowser) if an extension is installed or not so that I don't have to use Crossrider.API?
Or is there anything similar to window.navigator.plugins for extensions?
You can communicate with your page using simple content script for your domain only using window.postMessage function.
Content script code:
window.addEventListener("message", function(event) {
if (event.source !== window) return; // We only accept messages from ourselves
switch (event.data.type) {
case 'get_info': window.postMessage({type: "info", browser: 'opera'}, "*"); break;
}
}, false);
Your page code:
window.addEventListener('load', function () {
window.addEventListener("message", function (event) {
switch (event.data.type) {
case 'info': console.log(`browser is ${event.data.browser}`); break;
}
});
window.postMessage({type: "get_info"}, "*");
});
I am developing a Chrome Extesion for the first time and I am following the only guide that explains something about that: HTML5 ROCKS - FILESYSTEM.
I need to get storage for my extension and I resolved so:
window.webkitStorageInfo.requestQuota(window.PERSISTENT,1024*1024, onInitFs, errorHandler);
Ok, it works.
Now I need to create a xml file into the root, but in "onInitFs" the "fs" var is only a number and "fs.root" can't get it.
function onInitFs(fs){
console.log(fs.root); // -> Undefined
fs.root.getFile('list.xml', {create: true, exclusive: true}, function(fileEntry) {
fileEntry.isFile === true;
fileEntry.name == 'list.xml';
fileEntry.fullPath == '/list.xml';
}, errorHandler);
}
Can anybody explain why it doesn't work and how to resolve this issue?
Using RequestFileSystem within Chrome Extension
In order to use the FileSystem API as a root filesystem for your Chrome extension, you can actually use window.webkitRequestFileSystem instead of requestQuota.
window.webkitRequestFileSystem(window.PERSISTENT, 1024 * 1024, function (filesystem) {
console.log(filesystem);
console.log(filesystem.root);
}, function (e) { console.log("Could not request File System"); });
This does print correctly on Chrome 15,16 and 17 for me:
DOMFileSystem
DirectoryEntry
Using requestQuota for HTML5 apps
Just for reference, this would be the way to actually request the quota (i.e., when not using a Chrome Extension). You have to request the quota (the user sees a little banner at the top of his/her window) first. The RequestFileSystem is called if the user accepts.
window.webkitStorageInfo.requestQuota(PERSISTENT, 1024*1024, function(grantedBytes) {
window.webkitRequestFileSystem(PERSISTENT, grantedBytes, onInitFs, errorHandler);
}, function(e) {
console.log('Error requesting filesystem', e);
});
Eventually it might be necessary to request quota within an extension. Currently this can be circumvented with the unlimitedStorage permission. For the current state of implementation/storage types, see http://code.google.com/chrome/whitepapers/storage.html
Until current stable version 17.x, you cannot use HTML5 FileSystem API in Chrome extension. I have try this, the browser will crash down if I call FileSystem API in background page.
And here is a HTML5 API list what you can use in Chrome extension:
http://code.google.com/chrome/extensions/api_other.html
I am working on a chrome extension for desktop notification.Is there any way by which I can close the desktop notification after a specified time ?
If you have a reference of the notification object, you can use notification.cancel instead:
setTimeout(function() {
notification.cancel();
}, 5000);
References:
Chrome extension development: auto close the notification box
http://dev.chromium.org/developers/design-documents/desktop-notifications/api-specification
You can close it by running window.close() from notification's javascript (assuming your notification is a separated HTML file). So something like this:
setTimeout(function() {
window.close();
}, 5000);
for me this worked
setTimeout(function() {
notification.close();
}, 2000);