Add toString to core.Document.prototype, fixes #935