JS-based cancel buttons always redirect to the last viewed page. If forms have multiple tabs/views, however, this approach does no longer work. A good example is the "Add Photo" form in the gallery. Click on the "Zip-Archive" button and go back to "Single File". You are no longer able to cancel the form.
I suggest to properly implement cancel buttons by template variables (submitt button or url) guiding to the logical return location and not just the last viewed page. If you think that is more of an RFE I can repost.