Showing posts with label firefox. Show all posts
Showing posts with label firefox. Show all posts

Friday, May 16, 2014

ServiceWorker implementation status in Firefox


ServiceWorkers are a new web platform feature that allows sites to use JavaScript to provide a better offline experience, and eventually various other 'background service' capabilities. Jake Archibald has a good article on his blog explaining them further.

I've been working on the Gecko implementation for a while now, helped by several other Mozillians and some of the first patches are now beginning to land on Nightly. Interest in trying out a build has been high within both Mozilla and outside. I've been procrastinating about a detailed hacks article, but I thought I'd at least share the build and what Firefox supports for now and what it doesn't.

  1. Download the build
  2. Run it using a clean profile.
  3. Go to about:config and set "dom.serviceWorkers.enabled" to true.


Supported:
  • Registration, installation, activation, unregistration. Update() is not according to the spec, the scripts themselves are not cached offline, so don't actually try to make offline apps yet.
  • Intercepting navigation and fetch events and replying using a simple SameOriginResponse object.
  • Intercepting Push API events.
Not supported:
  • Cache API
  • fetch() - You'll have to use XHR in the worker.
  • ClientLists and postMessage() to talk to windows
  • Persistence - ServiceWorker registrations are currently not stored across restarts.
  • Anything that throws an error :)
  • No devtools support right now.

SameOriginResponse is a relic of an earlier version of the spec. Similarly the Request object received from the fetch event is not exactly up to speed with the spec.

I have two sample applications on Github to try out the build. Note that ServiceWorkers require HTTPS connections. For development, please create a new boolean preference in about:config - "dom.serviceWorkers.testing.enabled" and set it to true. This will disable the HTTPS requirement.

Push API Test - Remember to run the Firefox build from the command line since this demo prints stuff to the terminal. Click the register button to sign up for Push notifications. To perform the push, copy the unique URL and run


curl -vX PUT 'URL'

The ServiceWorker will be spun up and a 'push' notification delivered.

Simple Network Interception - This example will load an iframe with some content. Refresh the page and the iframe's content should change and the browser should show an alert dialog. These changes are done by the ServiceWorkers (there are 2, one for the current scope and one for the sub/ scope) intercepting the requests for both "fakescript.js" and the iframe and injecting their own responses.

Contributing

We could always use help with the specification, implementation and testing.

The specification is improved by filing issues.

The tracking bug for the Gecko implementation is Bug 903441. There is a mercurial patch queue for patches that have not landed on trunk.

I (nsm) am around on the #content channel in irc.mozilla.org if you have questions.

Monday, January 09, 2012

Toggling Proxy settings quickly with Pentadactyl and Firefox

If you use the excellent Pentadactyl plugin for Firefox to get vim super-powers to the browser, here is a quick and painless way to toggle between a direct connection to the internet or using the default proxy settings. Add this to your ~/.pentadactylrc
command proxy -nargs=1 :set! network.proxy.type=<args>
nmap up :proxy 1<CR>
nmap np :proxy 0<CR>
Now pressing up (Use Proxy) will enable Manual Proxy Settings while pressing np (No Proxy) will use Direct Connection. network.proxy.type can take other values which might be suited to your setup. You can change the key bindings too.

Thursday, April 17, 2008

Firefox feature request

I love to hack URLs to navigate the web, especially for sites with clean urls. What I'd love is if Firefox could hack the address bar text field so that the slash '/' is the default word seperator, instead of the usual space. This way just pressing Shift + Left/Right Arrow would allow power users to quickly select clean url tokens and edit them faster. This could even be improved so that the ampersand '&' is also a tokenizer.

Why haven't I posted this on Mozilla's bug tracker as a feature request, because I don't want to create an account, and I'm hoping that some reader who has one will do it for me :p

Thursday, January 24, 2008

I like that

As found on IIT Bombay's Techfest

On a side note, I SO NEED to be at BarCamp. Too bad I've got exams. Seriously next year I'm going to every damn festival.