There's a separate ambient light sensor. On some models you can make out the three separate holes above the monitor, one for the webcam, one for the led, and one for the light sensor.
I can't for the life of me see it with more recent models, but if block the camera it's clearly still there since it can respond to light changes, but if you block enough of the area around the camera, it'll default to assuming you're in darkness.