Pending scripts can cause disposed documents to leak.

The script runner of a document may still be holding pending scripts
when the document is disposed (e.g. due to navigation). The script
runner, and thus the pending scripts, is cleared in the destructor of
the document. However, the pending scripts keep a reference to the
script element they belong to. The script element in turn, keeps a
guard ref to the document, so the document will never be deleted.
Clearing the script runner in dispose clears the pending scripts and
breaks the reference cycle so that document can be deleted.

BUG=534844
R=sigbjornf@opera.com

Review URL: https://codereview.chromium.org/1368623003

Cr-Commit-Position: refs/heads/master@{#350664}
3 files changed