Bug 1125713 - Browser API: Add event for page download progress, r=fabrice

This commit is contained in:
Andrea Marchesini 2015-02-15 21:06:14 +01:00
parent 4da70f1fe2
commit f2202e383e
3 changed files with 19 additions and 3 deletions

View File

@ -113,7 +113,8 @@ BrowserElementChild.prototype = {
.addProgressListener(this._progressListener,
Ci.nsIWebProgress.NOTIFY_LOCATION |
Ci.nsIWebProgress.NOTIFY_SECURITY |
Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
Ci.nsIWebProgress.NOTIFY_STATE_WINDOW |
Ci.nsIWebProgress.NOTIFY_PROGRESS);
docShell.QueryInterface(Ci.nsIWebNavigation)
.sessionHistory = Cc["@mozilla.org/browser/shistory;1"]
@ -1371,8 +1372,12 @@ BrowserElementChild.prototype = {
},
onStatusChange: function(webProgress, request, status, message) {},
onProgressChange: function(webProgress, request, curSelfProgress,
maxSelfProgress, curTotalProgress, maxTotalProgress) {},
maxSelfProgress, curTotalProgress, maxTotalProgress) {
sendAsyncMsg('loadprogresschanged', { curTotalProgress: curTotalProgress,
maxTotalProgress: maxTotalProgress });
},
},
// Expose the message manager for WebApps and others.

View File

@ -181,6 +181,7 @@ BrowserElementParent.prototype = {
"hello": this._recvHello,
"loadstart": this._fireProfiledEventFromMsg,
"loadend": this._fireProfiledEventFromMsg,
"loadprogresschanged": this._fireEventFromMsg,
"close": this._fireEventFromMsg,
"error": this._fireEventFromMsg,
"firstpaint": this._fireProfiledEventFromMsg,

View File

@ -13,7 +13,8 @@ function runTest() {
// Load emptypage1 into the iframe, wait for that to finish loading, then
// call runTest2.
//
// This should trigger loadstart, locationchange, and loadend events.
// This should trigger loadstart, locationchange, loadprogresschanged and
// loadend events.
var seenLoadEnd = false;
var seenLoadStart = false;
@ -74,6 +75,7 @@ function runTest2() {
var seenLoadStart = false;
var seenLoadEnd = false;
var seenLocationChange = false;
var seenLoadProgressChanged = false;
// Add this event listener to the document; the events should bubble.
document.addEventListener('mozbrowserloadstart', function(e) {
@ -103,6 +105,14 @@ function runTest2() {
is(e.detail.backgroundColor, 'transparent', 'Expected background color reported')
});
iframe.addEventListener('mozbrowserloadprogresschanged', function(e) {
ok(e.isTrusted, 'Event should be trusted.');
seenLoadProgressChanged = true;
ok(seenLoadStart, 'Load end after load start.');
ok(seenLocationChange, 'Load end after location change.');
ok(!seenLoadEnd, 'Load end after load progress.');
});
iframe.src = browserElementTestHelpers.emptyPage2;
function waitForAllCallbacks() {