Replace getUserData()/setUserData() with CustomEvents

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=824601 .