"I heard Al-Husain bin Ali He said, "By Allah, the tyrants of Bani umayya (la) will gather for killing me and they will be lead by Umr bin Saad (la). And this incident happened in the life of the Prophet (saww).

I (Huzaifa) said to Imam Husain , "Did Prophet (saww) give the news of this to you?". Imam Husain said, 'No'.

I (Huzaifa) then went to the Prophet (saww) and informed Him of what occurred.

Prophet Muhammad (saww) said, "My knowledge is His Knowledge and His knowledge is My Knowledge. And verily, We have the knowledge of things before they occur."

[Source: Dalaail Al-Imamah Pg.183-184]

This incident clearly shows that the Imam's (as) have knowledge bestowed by Allah (swt) from the very beginning and it is not that the Imam's (as) get knowledge only after they get the responsibilities of Imamat.