Wednesday, October 15, 2008

Firefox 3.1 beta 1 - an overview of features for web developers

Firefox 3.1 Beta 1 is out and with it comes a huge pile of new features for developers. While those of you who follow Mozilla’s web-tech blog might know about some of them we thought that with the release of the first beta of 3.1 that it would be good to try to summarize just some of the bigger features for web developers that are part of this beta.

Note: the Firefox 3.1 for Developers page in the wiki is the canonical source for new features in Firefox 3.1.

Geolocation

Mozilla has implemented the draft spec for Geolocation. Geolocation is a JavaScript API that lets a web page query the browser’s location via JavaScript. It can be used to plot maps, give directions, attach location information to pictures, give a location for a weblog post and a pile of other things.

Geolocation Screenshot

The Geolocation API in Firefox 3.1 exposes a single API to web developers, but can potentially be backed by a number of different location sources. Examples include the Skyhook service, which guesses your location based on nearby access points, a GPS device in your mobile computer or hand-setting a fixed location where your desktop lives. Developers who want to write a location provider for Firefox need to implement the nsIGeolocationProvider as part of a component and include it as an extension.

People who want to try out Geolocation in Beta 1 can install Doug Turner’s Geolocation add-on which adds a fixed Geolocation provider. Once you’ve installed it you can visit http://whatismygeolocation.com/ to get your location and update the preference in Tools -> Add-ons -> Geolocation with your latitude and longitude. There are a number of examples of the API you can try on the Geode Labs Welcome page.

Mozilla Labs recently announced Geode, which is an extension that adds Geolocation support to Firefox 3. Geode added one type of Geolocation support to Firefox 3, based on Skyhook, and was built only as an example. Aza Raskin recently did a post on the differences. Geode and the Geolocation support in Firefox 3.1 should be API compatible and the end-user experience should be the same.

Geolocation is pretty hot right now and it will be great to see what people do once this is added directly to the browser.

@font-face

One of our most widely-request features is to add support for the CSS @font-face property. This property allows you to specify a true type font file that includes a specific font you want to use to render a web page. This is important not only for designers to get more consistent formatting and layout, but is also important to web developers for non-english websites who often have users that may or may not have access to high-quality fonts. Beta 1 includes support for @font-face.

Right now the fonts must be located at the same origin as the page that includes it.

@font-face support is implemented for Windows and Mac, but not for Linux. Linux support is underway and will be done by Firefox 3.1 final.

Video and Audio

This is the first beta from Mozilla to include support for the and elements. This beta includes support for the OGG Theora and OGG Vorbis formats on all platforms. There are quite a few free tools for encoding to OGG Theora and OGG Vorbis. We are also working on backend support for GStreamer for Linux, QuickTime for Mac and Windows Media for Windows. However it’s not clear if those backends will land before 3.1 final is ready.

Our goal with adding support for audio and video has been to make it as easy to post a video as it is to post an image. Along with that ease of use being able to mix audio and video elements with other rich media elements such as , SVG and super-fast JavaScript means that we’re able to get video out of the plugin prison and let it interact with the rest of the content on pages. This is a huge step forward for the web.

This beta has quite a few unimplemented features, as noted in the developer pages for audio and video, but fixes for many of those missing features will land before 3.1 final.

Chris Double has created a site with a bunch of sample videos up on it.

XHR Progress Notification

We’ve added a better way to get progress notifications for XML HTTP Requests. We’ve implemented the W3C Draft Spec on progress events. In Firefox 3 the events available on the XHR object were progress, uploadprogress, load, abort and error. For 3.1 we now support the loadstart, progress, load, abort and error events. (uploadprogress is also supported, but is deprecated.)

There’s a great example of the new progress events by Olli Pettay. It’s very simple and does everything in a single script.

XHR Cross-site Access Control

We’ve implemented the draft specification for access-control for cross-site requests. Web developers have long wanted to be able to get data from one site on another but same-origin restrictions on many types of requests prevent many developers from mashing up content. This new access control mechanism offers the ability for servers, content and web clients to cooperate to make a lot of new things possible on an opt-in basis. The spec is complex, and support is new, so if you’re interested reading the spec is probably the best thing to do. It contains examples and uses cases.

TraceMonkey

Beta 1 does include TraceMonkey, our super-fast JavaScript engine, but it’s not turned on by default. If you do want to turn it on, go to about:config, set javascript.options.jit.content to True, restart your browser and try it out.

This is an early beta, of course, so there will be issues. Please file bugs if you find sites that don’t work or cause crashes or hangs. The more testing we get, the better it will be when we turn it on.

And more…

There are several other features that are scheduled for Firefox 3.1 Beta 2 and are partially implemented in this beta that we’ll talk about more once Beta 2 is available. Some of the things you can expect are Worker Threads for JavaScript, new graphics, SVG and CSS capabilities and probably other things as well. The Firefox 3.1 for Developers page is the full source for new stuff that’s coming for 3.1 and it’s size tells the full tale of everything that’s new.

So stay tuned - we’ve got lots of new stuff coming up for Firefox 3.1!

Resource - mozilla

No comments: