color-supported-p is a built-in function in `C source code'.

(color-supported-p COLOR &optional FRAME BACKGROUND-P)

Return non-nil if COLOR can be displayed on FRAME.
BACKGROUND-P non-nil means COLOR is used as a background.
Otherwise, this function tells whether it can be used as a foreground.
If FRAME is nil or omitted, use the selected frame.
COLOR must be a valid color name.