Open Bug 707416 Opened 13 years ago Updated 2 years ago

canceling a navigation initiated by the Back or Forward buttons within the TabsProgressListener failes

Categories

(Firefox :: General, defect)

8 Branch
x86
Windows XP
defect

Tracking

()

UNCONFIRMED

People

(Reporter: ronen.zilberman, Unassigned)

Details

I am trying to be able to cancel navigations (document location changes).
I am using a progress listener and call the cancel() method on the Request object passed to the onStateChange() listener function.

This works for clicks on link, however it does not work for the Forward and Back buttons consistently: Mostly, the call is ignored and the location changes, however sometimes it does cancel.

Run the POC code and play with your responses while pressing links, Back and Forward.


-----------------------------------------------------------

var PL = {

onStateChange: function(aBrowser, aWebProgress, aRequest, aFlag, aStatus) {

if(aFlag & Components.interfaces.nsIWebProgressListener.STATE_START) {

var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
var res = promptService.confirm(window, "", "shall I go?");
 if (!res) {
    aRequest.cancel(Components.results.NS_BINDING_ABORTED);
 }
}
}

gBrowser.addTabsProgressListener(PL);
Not sure where this bug belongs, but surely not Location Bar
Component: Location Bar → General
QA Contact: location.bar → general
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.