[js] Change Deferred#cancel() to silently no-op if the deferred has already been resolved.

Fixes issue 6686