Novak Djokovic and Roger Federer face tough tests next after reaching the Shanghai Masters quarter-finals.