The angels were created before the earth. When God is speaking to Job we see that he refers to the angels or sons of God celebrating over the creation of the earth. Job 38:1-7:
Then Jehovah answered Job out of the windstorm:
2 “Who is this who is obscuring my counsel
And speaking without knowledge?
3 Brace yourself, please, like a man;
I will question you, and you inform me.
4 Where were you when I founded the earth?
Tell me, if you think you understand.
5 Who set its measurements, in case you know,
Or who stretched a measuring line across it?
6 Into what were its pedestals sunk,
Or who laid its cornerstone,
7 When the morning stars joyfully cried out together,
And all the sons of God began shouting in applause?
Satan was present with the other angels during the creation of the earth. It wasn't until God created man that Satan began to rebel against God. Genesis 3:3-5
But God has said about the fruit of the tree that is in the middle of the garden: ‘You must not eat from it, no, you must not touch it; otherwise you will die.’” 4 At this the serpent said to the woman: “You certainly will not die. 5 For God knows that in the very day you eat from it, your eyes will be opened and you will be like God, knowing good and bad.”
Satan was then calling God a liar and inferred that God was keeping good things from man.
You said in your heart, ‘I will ascend to the heavens.
Above the stars of God I will lift up my throne,
And I will sit down on the mountain of meeting,
In the remotest parts of the north.
14 I will go up above the tops of the clouds;
I will make myself resemble the Most High.
Satan wanted the glory of God's position. He also wanted humans to worship him as God.
At the time Revelation was written Satan had not yet been thrown down to earth. That was prophecy that would occur at a later date. Acts 2:32-35
God resurrected this Jesus, and of this we are all witnesses. Therefore, because he was exalted to the right hand of God and received the promised holy spirit from the Father, he has poured out what you see and hear. For David did not ascend to the heavens, but he himself says, ‘Jehovah said to my Lord: “Sit at my right hand until I place your enemies as a stool for your feet.”’
Satan and his angels would have been thrown down from heaven when Jesus became the ruler of the kingdom. We don't know what time that happened or will happen, although different denominations will have different answers for this.
We know that Satan had not yet been thrown out of heaven because he was able to talk to God in the book of Job. Job 1:6-7
Now the day came when the sons of the true God entered to take their station before Jehovah, and Satan also entered among them.
7 Then Jehovah said to Satan: “Where have you come from?” Satan answered Jehovah: “From roving about on the earth and from walking about in it.
We see that Satan did enter heaven to take his station before God. We know that can't have been on earth because Satan had just come from the earth. Satan cannot have been thrown out of heaven before this account then.
A plausible time-frame for that happening would have been some time after Jesus's resurrection.