concord-consortium/shutterbug — pull request #13 by pjanik (2014-02-12 14:26:58+00:00)
Title: Nested iframes support

This pull requests adds support of nested iframes. Another improvement is that when there is only one iframe, Shutterbug no longer requires that this iframe will be specified as an *src* argument (e.g. now the iframe can be a child of a DIV specified as *src* argument). Example (it is a new demo page, available as part of this pull request):
![nested1](https://f.cloud.github.com/assets/767857/2148979/e121116c-93ed-11e3-8bb7-f2f61b02d0ab.png)
Upper part presents real HTML elements, lower part presents snapshot. Missing borders issue is also present in current master, it's not related to this work.

Situations when one of the iframes doesn't support Shutterbug are also handled. Request will timeout and Shutterbug will try to render as much as it can. Example:
![nested2](https://f.cloud.github.com/assets/767857/2148981/e49ba884-93ed-11e3-94d1-cd417f936f16.png)

Changes are only on the client-side (shutterbug.js), server code isn't changed. Nested iframes are included into final document using *src="data:"* attribute.

**Backward compatibility**
Obviously the new client code can work with an old server. However all pages and iframes should use new shutterbug.js script, as format of messages is changed a bit - there are two new properties: *iframeReqTimeout* and *iframeReqId*.
Perhaps I could provide workaround to make sure that new shutterbug.js supports responses from iframes using old shutterbug.js. However I'm not sure if it's worth the effort (especially testing can be annoying). If so, please let me know.

Other small, "breaking" change is that now iframes element are rendered on the snapshot. Previously when *src* argument was equal to iframe, it was silently replaced by iframe content. So in other words, iframe element was somehow lost during taking a snapshot.
Please compare old snapshot:
![iframeold](https://f.cloud.github.com/assets/767857/2149131/5c05a526-93f0-11e3-8803-79ba6940e685.png)
with new snapshot:
![iframenew](https://f.cloud.github.com/assets/767857/2149132/62ad7624-93f0-11e3-94f2-b7141990e800.png)
I think old behavior wasn't fully correct and current one is rather necessary to support reasonably nested iframes.