ozone-development/ozp-iwc — pull request #34 by mark-leone (2014-06-11 19:40:23+00:00)
Title: Feature post message

Resolves #10

Detects whether a browser supports structured clones. If so, payloads passed to postMessage are not stringified. If not, payloads are stringified.

The detection works by detecting that the structured clone feature is implemented, and also checking for an anomaly caused by a Firefox bug. The current version of Firefox supports structured clones, but will fail if a File object is passed as the payload of psotMessage. The feature-detect has an added check for this, wherein it tries to send a test Blob via postMessage. This will result in any Firefox version with the bug mentioned above failing the feature-detect for structured clone support. The results of the feature-detect are cached, so the extra postMessage call will only occur once per session.

The commits in this pull request unfortunately include whitespace changes. They can be suppressed in Gitbub with ?w=1 and in the git command line client with -w.

A unit test clientSpec.js was created to verify that the payload is stringified or not in accordance with the detected support for structured clones.