The justices explored whether the so-called dormant commerce clause is violated by California’s law, which is based on morality and an interest in health and safety.