In https://drafts.csswg.org/css-pseudo-4/#selectordef-selection the spec says:
The ::selection and ::inactive-selection pseudo-elements represent the portion of a document that has been highlighted by the user.
However, it is possible that web apps can create selections with DOM Ranges and Selection APIs. And ::selection applies to those programatically created selections. Perhaps spec should take such non-user initiated selection into account?