Web platform technologies in Safari 6.1 and 7

Warning This article was written over six months ago, and may contain outdated information.

At the recent unveiling of OSX Mavericks Apple also announced Safari 7, with greatly improved web standards support. It was left a little unclear as to which versions of OSX it would run on, but browsing through their developer area this week I found a downloadable pre‐release of Safari 6.1, which I think clears that up: it seems Safari 7 will be exclusive to Mavericks, while 6.1 will run on Lion and Mountain Lion, with all of the web standards support of Safari 7, but only a limited set of new features.

As both versions are a major update for the browser, bringing almost a year’s worth of WebKit updates, I thought it would be useful to take a look through the new and updated features in each, as well as trying to identify where they differ.

NB: all of my tests for this post have been performed in Safari 6.1 Seed 2 for Mountain Lion, so it’s possible that missing features — or those implemented differently than expected — may be in Safari 7 only, or perhaps not yet enabled by default.

CSS

Starting with the biggest stuff, Regions is a mechanism where you choose content from a source element, then flow that content into another element, or multiple other elements. As this is still considered experimental, all appropriate properties use the -webkit‐ prefix:

The launch and release notes mention a further two big layout features: first is Grid Layout, which I’m very excited about as I first saw a version of it some seven years ago and have been eagerly awaiting it since! Unfortunately it doesn’t seem to work at all in Safari 6.1; the inspector tools suggests the properties in auto‐complete, but then treats them as invalid.

The release notes also mention Exclusions, but it’s actually Shapes that’s implemented — the two used to share a spec, but were recently split out into their own. Shapes works by defining a shape which controls the flow of content around it, either inside or outside:

Still on layout, Safari’s Flexbox support has been updated to use the stable syntax, bringing it on a par with other modern browsers. While these properties are also still prefixed, a number of sets of features are now considered stable and have had their prefixes removed: the transition property, gradient values, and the calc() value function.

Along with as these bigger changes, there are a bunch of smaller new features. The clip‐path property, originally introduced in SVG, acts like clip, but allows more shapes than the basic rectangle; for example, to clip a circle you specify the x and y co‐ordinates of the centre, and a radius:

Also: the word‐wrap property has been renamed overflow‐wrap; and there are a few new value units — ch is equivalent to the 0 character of the currently applied font, and vmax is equivalent to either vh or vw, whichever is greater.

There have been numerous fixes to the properties in the Backgrounds & Borders module, giving it now full implementation except, for some reason, the long‐standing background‐repeat errors. Among the changes, the background‐position property now accepts four values, for finer control over positioning:

A couple of changes I haven’t yet been able to find: the release video touts the image‐set() function value as a new feature, but as far as I can tell it’s identical to the version already implemented in Safari 6; and background‐blend‐mode is said to be implemented, but didn’t work in any of the demos I tried — perhaps this is only in Safari 7?

There are a few new additions to the DOM API for forms. The height and width attributes for an image input type are now available, along with the elements attribute for fieldset, which lists all of the form elements (i.e. not legend or label) contained within.

JavaScript

The two big new JS features in Safari 7 are support for Mutation Observers and Shared Workers. The former provide a new way of detecting changes to the DOM, while the latter extend the Web Workers concept to be available from multiple different scripts.

There are a bunch of new APIs: Page Visibility allows you to detect whether the tab your site is running in is in focus, and perform actions based on that; pause a playing video when the user switches away, for example.

Web Speech was implemented in Chrome recently and is now in Safari too, using Apple’s Siri processing — and it hasn’t even been accepted by the W3C yet. Push Notifications are implemented in a split‐level way; Local Notifications are the standard, and allow you to send notifications via Safari, and OSX Website Push Notifications require that you register your web server with the Apple Push Notifications service, and can create your own app entry in the notifications tray.

OS integration

It’s not clear that Push Notifications — especially the OSX version — will be present in Safari 6.1, and a further two APIs were announced for Safari 7 which are noticeably absent from the release notes for Safari 6.1: AirPlay, to allow streaming media over the AirPlay protocol, and JS Objective C, which will act as a bridge between the two technologies allowing them to work together.

While I can’t say for sure that these won’t be in Safari 6.1, I strongly suspect that they won’t be; and that while the two new versions of Safari will have equivalent levels of web standards support, Safari 7 will be much more tightly integrated to the OS.

With the release of Safari 7, not only 3rd Party cookie is being blocked. Local Storage as well as WebDB, any kind of website data are being blocked. When you go to Safari Preferences (CMD+comma), Under privacy tab, on Safari 7, it now says : “Block cookies *and other website*”, originally was “Block cookies”. That confirms the changes.