Bug 747883 - Make Native Fennec's onLocationChanged handler behave correctly for wyciwyg-prefixed URIs. r=mfinkle,kats

This commit is contained in:
Ali Juma 2012-05-29 09:37:47 -04:00
parent 1015fbffe9
commit 5aefe4f637

View File

@ -43,6 +43,9 @@ XPCOMUtils.defineLazyServiceGetter(this, "Haptic",
XPCOMUtils.defineLazyServiceGetter(this, "DOMUtils", XPCOMUtils.defineLazyServiceGetter(this, "DOMUtils",
"@mozilla.org/inspector/dom-utils;1", "inIDOMUtils"); "@mozilla.org/inspector/dom-utils;1", "inIDOMUtils");
XPCOMUtils.defineLazyServiceGetter(window, "URIFixup",
"@mozilla.org/docshell/urifixup;1", "nsIURIFixup");
const kStateActive = 0x00000001; // :active pseudoclass for elements const kStateActive = 0x00000001; // :active pseudoclass for elements
const kXLinkNamespace = "http://www.w3.org/1999/xlink"; const kXLinkNamespace = "http://www.w3.org/1999/xlink";
@ -2214,10 +2217,19 @@ Tab.prototype = {
this._hostChanged = true; this._hostChanged = true;
let uri = aLocationURI.spec; let fixedURI = aLocationURI;
try {
fixedURI = URIFixup.createExposableURI(aLocationURI);
} catch (ex) { }
let documentURI = contentWin.document.documentURIObject.spec; let documentURI = contentWin.document.documentURIObject.spec;
let contentType = contentWin.document.contentType; let contentType = contentWin.document.contentType;
let sameDocument = (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT) != 0;
// XXX If fixedURI matches browser.lastURI, we assume this isn't a real location
// change but rather a spurious addition like a wyciwyg URI prefix. See Bug 747883.
let sameDocument = (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT) != 0 ||
((this.browser.lastURI != null) && fixedURI.equals(this.browser.lastURI));
this.browser.lastURI = fixedURI;
// Reset state of click-to-play plugin notifications. // Reset state of click-to-play plugin notifications.
clearTimeout(this.pluginDoorhangerTimeout); clearTimeout(this.pluginDoorhangerTimeout);
@ -2229,7 +2241,7 @@ Tab.prototype = {
gecko: { gecko: {
type: "Content:LocationChange", type: "Content:LocationChange",
tabID: this.id, tabID: this.id,
uri: uri, uri: fixedURI.spec,
documentURI: documentURI, documentURI: documentURI,
contentType: contentType, contentType: contentType,
sameDocument: sameDocument sameDocument: sameDocument