Sahih al-Bukhari Book 68, Hadith 83
A woman was bereaved of her husband and her relatives worried about
her eyes (which were diseased). They came to Allah's Messenger (ﷺ), and
asked him to allow them to treat her eyes with kohl, but he said, "She
should not apply kohl to her eyes. (In the Pre-Islamic period of
Ignorance) a widowed woman among you would stay in the worst of her
clothes (or the worst part of her house) and when a year had elapsed,
if a dog passed by her, she would throw a globe of dung, Nay, (she
cannot use kohl) till four months and ten days have elapsed."
I (Humaid) said to Zainab, "What does 'throwing a globe of dung when one year had elapsed' mean?" Zainab said, "When a lady was bereaved of her husband, she would live in a wretched small room and put on the worst clothes she had and would not touch any scent till one year had elapsed. Then she would bring an animal, e.g. a donkey, a sheep or a bird and rub her body against it. The animal against which she would rub her body would scarcely survive. Only then she would come out of her room, whereupon she would be given a globe of dung which she would throw away and then she would use the scent she liked or the like."
The Prophet (ﷺ) said, "It is not lawful for a Muslim woman who believes in Allah and the Last Day to mourn for more than three days, except for her husband, for whom she should mourn for four months and ten days."