Measurement of ultrashort optical pulses by third-harmonic generation