Welcome!

Open Source Authors: Patrick Burke, Jeremy Geelan, Maureen O'Gara, Pat Romanski, Tony Baer

Related Topics: Web 2.0, AJAX & REA

Web 2.0: Article

Making Mashups Safe: Introducing CrossFrame

A safe communication mechanism across documents and across domains

Julien Lecomte, who currently works on Yahoo!'s DHTML Evangelist team, is a member of the distinguished Speaker Faculty at the upcoming AJAXWorld Conference & Expo 2008 East, to be held in New York City (March 18-20, 2008), where his session will be entitled "High Performance AJAX Applications."

According to my Yahoo! co-worker Douglas Crockford, Mashups are the most interesting advancement in software development in decades. They are also unsafe in the current generation of browsers. Lately, Douglas has been spending some time convincing the main browser vendors that mashups need to be made safe, wrote a proposal, and even mentioned Google Gears as a potential solution to the problem.

While fixing the browser is the right thing to do, web developers are confronted with this problem today, and cannot afford to wait 5 years for a definitive solution.

Existing solutions to the mashup problem

One way mashups (or widgets, badges and gadgets, take your pick…) can be made safe is by sandboxing them in an IFrame pointing to another domain (Note: another way would be to run the untrusted code through ADsafe, and provide some safe API to do useful things on the page) The problem is that the Same Origin Policy isolates them so completely that they are then unable to cooperate with the page containing them or with each other. Several hacks have been exploited to achieve reasonably secure client-side cross-domain communication. The most popular ones use the URL fragment identifier or the Flash LocalConnection object.

Why the need for another technique?

CrossFrame is a variant of the URL fragment identifier mechanism. In the original technique, the containing page sets the URL fragment identifier of an embedded IFrame (usually via its src attribute), and the IFrame must poll to detect changes in the value of its location.hash property. This technique can be further built upon to allow for 2-way communications between an IFrame and its containing page, or between two distinct IFrames.

The original URL fragment identifier technique has many limitations, many of which can be worked around except maybe for the following:

  • It unnecessarily consumes CPU cycles by requiring the receiver to poll.
  • It creates “fake” history entries on Safari and Opera.

More Stories By Julien Lecomte

Julien Lecomte currently works on Yahoo!'s DHTML Evangelist team, a group that provides architectural assistance to Yahoo! web developers. He has worked extensively on Yahoo! Mail and Yahoo! Search, and is the author of the YUI Browser History Manager and the YUI Compressor.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.