The European Union's highest court has sided with a Syrian refugee in a landmark case against Frontex, the EU border agency.