An in-depth explanation of promises in JavaScript, while fixing a WebKit bug