Sun played no, or no authoritative, role in developing javascript. I don't know how they got the trademark except perhaps no one owning it thought they could monetize the trademark.
They bought Java (not javascript) a long time ago. With, as far as I can tell, the sole intent of monetization through legal action.
From the article, https://javascript.tm/ is a petition you can sign for Oracle to drop the trade mark claim
Has to be done via github though
you think Oracle cares about petitions?
It's not about caring, it's about the lawyers making the argument javascript's genericness easier