dart-lang/spark — pull request #501 by dinhviethoa (2013-12-18 06:51:24+00:00)
Title: Workaround to get chrome.restoreEntry() to work

Fixed #382.

- Applied a patch to change the behavior of the code generated by Dart2JS.
- It will fix the issue with chrome.restoreEntry().

Here why the bug happened:
1/ chrome.restoreEntry will return an object FileEntry/DirectoryEntry
2/ dart2js runtime will create a dart proxy on top of it. The dart proxy is stored into a field of the FileEntry/DirectoryEntry.
3/ When relaunching, a new dart2js runtime will be created.
4/ chrome.restoreEntry will return the same instance and will try to reuse the same dart proxy based on the previous runtime (because it's cached in a field).
At this point, the code will start behaving un-properly.

The workaround:
When we create a proxy and store it into a field, we'll add a reference to P.Object as an additional field '_$Object'.
When Spark will be relaunched, before reusing the same dart proxy, we'll check that P.Object correspond to what is stored in the field '_$Object'. If it doesn't match, we invalidate this cache.

@devoncarew @justinfagnani