When Does Contrastive Learning Preserve Adversarial Robustness from Pretraining to Finetuning?