Gordon stated that he is concerned about singer's apparent "habitual, frequent, and continuous use of controlled substances and alcohol" and he wants to investigate. He has ordered Spears to "undergo testing", which will be conducted randomly twice a week, reports imdb.com.
Custody remains split at 50-50 between Spears and her ex-husband Kevin Federline until test results have been determined. It is not known how long Spears will be tested for.
Meanwhile, Gordon also said: "Each party is restrained from making derogatory remarks about the other party and the other party's family or significant other."
The judge has also insisted that both Federline and Spears meet "a parenting coach for a minimum of eight hours each week", and he also demands, "Neither party shall consume alcohol or other non-prescription controlled substance during or for 12 hours immediately preceding any period such party is responsible for the health and safety of the minor children".
The judge's ruling on Tuesday coincided with what would have previously been a happy time for the former couple - it was three years to the day Spears and Federline staged a wedding ceremony in Studio City, California on Sep 18, 2004.
The pair was officially married a month later.