Replace str_to_jsval and domstring_to_jsval with a JSValConvertible implementation.