Coming on the heels of a spate of mass shootings, the vote gave Democrats another opportunity to draw a sharp distinction with Republicans before the midterm elections.