Lawmakers in New York have passed legislation that would ban the sale of toys containing hazardous chemicals.