Bug 917515 - Check for null before checking the document. r=ehsan