Comment 8 for bug 278405

Revision history for this message
In , Sylvain Pasche (sylvain-pasche) wrote :

I can reproduce on trunk. What happens is that when escape is pressed, the textValue property of the binding in urlbarBindings.xml is set with the value currently in the urlbar. The setter there tries to parse the URI using nsIOService::newURI. If it succeeds, the nsIURI.spec attribute is used to fill the urlbar. The cause of the issue is that this process can add trailing slashes:

for each (let u in ["foo", "ftp", "ftp:", "ftp://",
                    "http", "http:", "http:/", "http://", "http://foo",
                    "http://foo/", "http://foo/bar"]) {
    let spec = "<none>";
    try {
        spec = Cc["@mozilla.org/network/io-service;1"]
                 .getService(Ci.nsIIOService)
                 .newURI(u, null, null).spec;
    } catch(e) {}
    dump("Url: " + u + " -> " + spec + "\n");
}

Url: foo -> <none>
Url: ftp -> <none>
Url: ftp: -> ftp:///
Url: ftp:// -> ftp:///
Url: http -> <none>
Url: http: -> http:///
Url: http:/ -> http:///
Url: http:// -> http:///
Url: http://foo -> http://foo/
Url: http://foo/ -> http://foo/
Url: http://foo/bar -> http://foo/bar