On 15 and 16 December 2011, Sun-grazing comet C/2011 W3 (Lovejoy) passed deep within the solar corona, effectively probing a region that has never been visited by spacecraft. Imaged from multiple perspectives, extreme ultraviolet observations of Lovejoy's tail showed substantial changes in direction, intensity, magnitude, and persistence. To understand this unique signature, we combined a state-of-the-art magnetohydrodynamic model of the solar corona and a model for the motion of emitting cometary tail ions in an embedded plasma. The observed tail motions reveal the inhomogeneous magnetic field of the solar corona. We show how these motions constrain field and plasma properties along the trajectory, and how they can be used to meaningfully distinguish between two classes of magnetic field models.