Use the internal document reference instead of the global one in DomHelper.prototype.whenBodyExists.