Which of "她睡觉的时候...", "她在睡觉的时候...", "她睡觉时候...", and "她在睡觉时候..." are grammatically correct and do they all have the same meaning? In class, we learned this sentence:


  她睡觉的时候，她的朋友正在上网。
  Tā shuìjiào de shíhòu. Tāde péngyǒu zhèngzài shàngwǎng.


My question is about the following three variants.  For the first, we add in a 在 (zài):


  她在睡觉的时候，她的朋友正在上网。


For the second we omit the 的 (de):


  她睡觉时候，她的朋友正在上网。


And for the third we add in a 在 (zài) and omit the 的 (de):


  她在睡觉时候，她的朋友正在上网。


Question: Which of these are grammatically correct and do they all have the same meaning?

I feel the first variant is correct, YouDao.com gives an example "当她在睡觉的时候笑了..." which seems similar (but the 在 might be part of a different grammar construct here: 在[x]笑了).  The latter two examples might be wrong as most examples I've found include the 的, but I'm not sure, as I found "...但在睡觉时候..." on YouDao.com.
她在睡觉的时候，她的朋友正在上网。
  她睡觉时候，她的朋友正在上网。
  
  
  3.她在睡觉时候，她的朋友正在上网。


The first one is the most natural way to say it, grammatically and formally. 

The second one is ok in colloquial contexts with omitting both 在 and 的. 

The third one is a bit odd because it adds 在, I may expect the interlocutor to say the full version. Otherwise, I expect they say the shorten version like the second one. 

But, in practice, especially when you speak fast, it really doesn't matter. These sentences are all ok, though the first one is preferable. There are no problems for understanding. They all could sound natural if you have a good command of Chinese speaking.