zotero/zotero — pull request #202 by aurimasv (2012-11-25 11:27:34+00:00)
Title: Fix some issues with wrapping DOM object for cross-domain translation

There were two issues with the current setup:

1) Since the empty object `{}` was being stored in `DOMWrapper.overrides` it was causing certain properties to look like they were being overridden (e.g. toString), since `'toString' in {}` is true. This would return the actual `toString` function as the property descriptor. Long story short, `document.location.toString()` (used in a couple places) on a wrapped document was throwing exceptions.

2) SOP for wrapping objects in `processDocuments` was being checked against the location that the translator was initialized with. So in the following scenario
```
Translator1(Domain1) -> load page at Domain2 -> Call Translator2 with document from Domain2 -> load another page at Domain2
```
was failing to wrap the document returned for the second `processDocuments` call.

It would be great if @simonster or @dstillman could check whether `_originalLocation` needs to be set in some other places. Particularly, I'm not sure under what conditions is the protocol and host being determined from the `_sandboxLocation`. I'm guessing it will have something to do with import and search translators. But I'm not sure if SOP would apply to these translators if they are called from Zotero code rather than a web translator (if that makes sense).

The varDump code got tacked on during my debugging.

You can test this using the Google Scholar translator (modified to forward to Google Patents) from https://github.com/aurimasv/translators/tree/GS-recursive and a page like http://scholar.google.com/scholar?q=Liquid+jet+recording+device&btnG=&hl=en&as_sdt=0%2C14 (first item should be sufficient. One of those items for me is not a patent, so beware)

Maybe we can marge this in 3.0 instead of master?