chrome.storage.sync not syncing between browsers - javascript

I am writing a chrome extension in which I would like some data to be synced across multiple computers. I was under the impression that if I was 'signed in' using the same gmail account to two separate chrome browsers (one in a virtual machine running on the same computer) that I should be able to use the chrome.storage.sync.set on one browser, and then retrieve that same data from the other using chrome.storage.sync.get?
I can retrieve the data using the get method from that same browser I ran the set method with (even from a separate incognito window), but the same get command on the other virtual machine returns an empty object.
Both browsers have the 'sync everything' option set in 'advanced sync settings'.
Both browsers have the same chrome version: 33.0.1750.117 m.
Here is my code for setting and getting:
chrome.storage.sync.set({'foo': 'bar'}, function() {});
chrome.storage.sync.get('foo', function(items) {
console.dir(items);
});

As #abraham and #sowbug both alluded to, the problem was that when loading unpacked extensions they get assigned different extension ids.
I found the solution here: https://developer.chrome.com/extensions/packaging#upload
It involves packing the extension from the extensions page in chrome, and then loading the resulting .crx file. Every time this .crx file is loaded it will have the same extension id.

Related

Caching with service workers - Chrome & Android Webview

I work on an old application that used ApplicationCache to work offline. Because of its deprecation, we would like to move to Service Workers to achieve the same goal.
Firefox 67 works very well with my current service worker implementation: when I first access to the application, every file listed as 'to-be-cached' is effectively downloaded and cached. The app can then be accessed offline.
Nevertheless, Chrome 74 and Android WebView (which looks like to be based on Chrome 73 - inside a Cordova app) have a slightly different comportment. When I first access to the application, a request per 'to-be-cached' file is put inside the cache. Navigating through the app works great when I'm online. But then I switch offline and only pages I have already accessed to are now accessible.
Is this a bug or a feature? Whatever it is, is there any workaround?
Finally, here is what I have understood: Firefox compares cached resources on their URLs (string). Thus, giving a list of URLs (string) is sufficient for Firefox to cache them and retrieve them later with a Request object (sent when browsing the web application).
Chrome apparently compares cached resources on another value (I haven't managed to find which one). Then, giving a list of URLs (string) wasn't sufficient for Chrome. Request objects and URLs (string) were not recognized as the same.
Based on W3C's specification cache.addAll method, Chrome behaviour should be the right one. But Firefox behaviour is simplier.

net::ERR_SPDY_PROTOCOL_ERROR in chrome

I'm using JS-autocomplete which is working fine in the local environment, but in Live environment, initially autocomplete works properly, but after 3-4 attempts I'm getting net::ERR_SPDY_PROTOCOL_ERROR in the console (only in one page).
This is not the case for all pages, other pages have the same autocomplete which is working properly, I have tried in incognito mode and some other browsers, but getting the same error
I have tried following methods
Cleared temp files, cookies, and caches Flushing SPDY Sockets using chrome://net-internals/#sockets
Updated browser Flushing DNS and Renewing IP
but these attempts did not solve my problem
Note: I have not installed any Antivirus
Snapshot of Network panel
Try following two things :-
Use http2 protocol for loading your resources as well and for the auto-complete API.
Use unique identifier for your auto-complete API(like &t=(new Date()).getTime())

Understanding chrome.storage.sync's behaviour when not signed in to the Chrome browser

I've been playing around with the chrome.storage.sync API as part of a Google Chrome extension that I'm building.
The API makes it clear that if you sign in to the Chrome browser with your Google account and use chrome.storage.sync.set then all the data that is set will be accessible next time you sign in to a Chrome browser with the same Google account and use chrome.storage.sync.get.
What the API doesn't make particularly clear is how chrome.storage.sync behaves when not signed in to the Chrome browser.
From my experiments it appears that, when not signed in to the Chrome browser, chrome.storage.sync.set and chrome.storage.local.set save to different places.
It says in the API:
When Chrome is offline, Chrome stores the data locally. The next time
the browser is online, Chrome syncs the data. Even if a user disables
syncing, storage.sync will still work. In this case, it will behave
identically to storage.local.
It appears that the place where
Chrome stores the [synced] data locally
is different to where chrome.storage.local.set stores it. Can anyone confirm if this is true?
When Chrome.storage.sync is unable to connect to the internet, it stores data in a new, temporary place locally. It does not store it in Chrome.storage.local and is still accessed through Chrome.storage.sync.
The confusion seems to be in the language. Chrome.storage.local is a separate location, and Chrome.storage.sync will behave LIKE Chrome.storage.local. It does not use the same storage location
Actually chrome description has clearly stated on https://developer.chrome.com/extensions/storage
When Chrome is offline, Chrome stores the data locally. The next time
the browser is online, Chrome syncs the data. Even if a user disables
syncing, storage.sync will still work. In this case, it will behave
identically to storage.local.

Chrome Tab Sync javascript API

Is there a javascript API for Chrome Tab Sync for web sites? I'm not asking about Chrome Extensions, just web sites.
For example, I'd like to store some text (a string) when you open a web site on the desktop then when you open that same page in the chrome mobile browser I'd like to display that stored text.
Is this possible? I know with Chrome Extensions there is chrome.storage, but I don't believe that is available for websites.
You should store that information:
on your server,
in the URL of the page (?mystring=...),
or on your server with a lookup key for the specific info in the URL.
Any one of these is an ordinary thing to do and will work for all browsers and all ways to get a page from one device to another, without relying on any features specific to Chrome.

Safari 5.0 Extension Scripts Won't Run on Local Files

I wrote a very simple extension for Safari 5 that only outputs a single log message from a start script. This is the start script:
console.log('start script running');
If I go to any internet page (eg. http://www.yahoo.com) the log message appears in the error console. But if I open any local html page no log message appears. By local I mean on my local machine. It's like my start script never gets run for local pages (eg. C:/blank.html).
Is there a permission setting I'm overlooking or is this a feature of Safari 5?
Brent
Caveat: I only have a passing familiarity with the Safari extension system. I work on Google Chrome which is based on Webkit. Safari is also based on webkit.
In a Google Chrome extension, you can inject a script into a local page using the file:// permission. But I’m pretty sure there’s no analogue for Safari extensions.
The Safari page on script injection also seems to say you can’t interact with local files:
“You cannot access resources on the user’s hard drive outside of the extensions folder.”
There is no way to inject scripts on local files.
If you feel like it, you may complain at bugreport.apple.com.

Categories