 Passage of the measure, which has been the subject of a dogged advocacy campaign by parents who say their children lost their lives because of something they found or saw on social media, marked a rare bipartisan achievement at a time of deep polarization in Congress.