Implement document.lastModified (fixes #2972, #3127).