Answer
By examining the absorption spectrum of its light.
Work Step by Step
Analyze the spectrum of light coming from the sun by using a diffraction grating (or prism).
If there is oxygen near the surface, you will see dark (absorption) lines at the wavelengths that correspond to electron transitions in oxygen atoms.