Bug 1073462: Send synthetic property with Content:LocationChange message. r=felipe

The browser.isSynthetic property is needed by the zoom code to detect when to
apply the correct zoom level. In e10s it is currently only set when a new
document is created which means we don't set it right for history navigation.
This sends it with the Content:LocationChange message which is where it is
needed by the zoom code anyway.
This commit is contained in:
Dave Townsend 2015-03-03 16:58:53 -08:00
parent 87451d9d5b
commit 6775df8e21
6 changed files with 65 additions and 20 deletions

View File

@ -140,6 +140,7 @@ let WebProgressListener = {
json.charset = content.document.characterSet;
json.mayEnableCharacterEncodingMenu = docShell.mayEnableCharacterEncodingMenu;
json.principal = content.document.nodePrincipal;
json.synthetic = content.document.mozSyntheticDocument;
}
sendAsyncMessage("Content:LocationChange", json, objects);
@ -326,22 +327,6 @@ addEventListener("ImageContentLoaded", function (aEvent) {
}
}, false);
let DocumentObserver = {
init: function() {
Services.obs.addObserver(this, "document-element-inserted", false);
addEventListener("unload", () => {
Services.obs.removeObserver(this, "document-element-inserted");
});
},
observe: function(aSubject, aTopic, aData) {
if (aSubject == content.document) {
sendAsyncMessage("DocumentInserted", {synthetic: aSubject.mozSyntheticDocument});
}
},
};
DocumentObserver.init();
const ZoomManager = {
get fullZoom() {
return this._cache.fullZoom;

View File

@ -18,6 +18,9 @@ skip-if = e10s
skip-if = e10s # Disabled for e10s: Bug ?????? - seems to be a timing issue with RemoteFinder.jsm messages coming later than the tests expect.
[browser_input_file_tooltips.js]
skip-if = e10s # Bug ?????? - test directly manipulates content (TypeError: doc.createElement is not a function)
[browser_isSynthetic.js]
support-files =
empty.png
[browser_keyevents_during_autoscrolling.js]
skip-if = e10s # Bug 921935 - focusmanager issues with e10s
[browser_save_resend_postdata.js]

View File

@ -0,0 +1,60 @@
function waitForLoad(browser) {
return new Promise(resolve => {
let wasSynthetic = browser.isSyntheticDocument;
browser.addProgressListener({
onLocationChange: function(webProgress, request, location, flags) {
wasSynthetic = browser.isSyntheticDocument;
},
onStateChange: function(webProgress, request, flags, status) {
let docStop = Ci.nsIWebProgressListener.STATE_IS_NETWORK |
Ci.nsIWebProgressListener.STATE_STOP;
if ((flags & docStop) == docStop) {
browser.removeProgressListener(this);
resolve(wasSynthetic);
}
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference])
});
});
}
const FILES = gTestPath.replace("browser_isSynthetic.js", "")
.replace("chrome://mochitests/content/", "http://example.com/");
add_task(function*() {
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
yield waitForLoad(browser);
is(browser.isSyntheticDocument, false, "Should not be synthetic");
let loadPromise = waitForLoad(browser);
browser.loadURI("data:text/html;charset=utf-8,<html/>");
let wasSynthetic = yield loadPromise;
is(wasSynthetic, false, "Should not be synthetic");
is(browser.isSyntheticDocument, false, "Should not be synthetic");
loadPromise = waitForLoad(browser);
browser.loadURI(FILES + "empty.png");
wasSynthetic = yield loadPromise;
is(wasSynthetic, true, "Should be synthetic");
is(browser.isSyntheticDocument, true, "Should be synthetic");
loadPromise = waitForLoad(browser);
browser.goBack();
wasSynthetic = yield loadPromise;
is(wasSynthetic, false, "Should not be synthetic");
is(browser.isSyntheticDocument, false, "Should not be synthetic");
loadPromise = waitForLoad(browser);
browser.goForward();
wasSynthetic = yield loadPromise;
is(wasSynthetic, true, "Should be synthetic");
is(browser.isSyntheticDocument, true, "Should be synthetic");
gBrowser.removeTab(tab);
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -322,10 +322,6 @@
break;
}
case "DocumentInserted":
this._isSyntheticDocument = data.synthetic;
break;
case "FullZoomChange": {
this._fullZoom = data.value;
let event = document.createEvent("Events");

View File

@ -198,6 +198,7 @@ RemoteWebProgressManager.prototype = {
this._browser._imageDocument = null;
this._browser._mayEnableCharacterEncodingMenu = json.mayEnableCharacterEncodingMenu;
this._browser._contentPrincipal = json.principal;
this._browser._isSyntheticDocument = json.synthetic;
}
this._callProgressListeners("onLocationChange", webProgress, request, location, flags);