Behat does not play well with confirmation dialogues and in some
situations it does not wait for the page to reload before starting the
next step.
This change adds a pending_js call which is only resolved if the cancel
button was pressed, otherwise it remains in-progress until the page
reloads resetting the entire state of it.