Magnetic optical rotation in H2 and D2