Bug 948287 - [Download API] Accessing startTime attribute at download start fires NS_ERROR_UNEXPECTED in emulator. r=fabrice

This commit is contained in:
Ghislain Lacroix 2013-12-13 11:46:22 -05:00
parent f81682cfee
commit 75c36c29d1

View File

@ -198,6 +198,7 @@ function createDOMDownloadObject(aWindow, aDownload) {
function DOMDownloadImpl() { function DOMDownloadImpl() {
debug("DOMDownloadImpl constructor "); debug("DOMDownloadImpl constructor ");
this.wrappedJSObject = this; this.wrappedJSObject = this;
this.totalBytes = 0; this.totalBytes = 0;
this.currentBytes = 0; this.currentBytes = 0;
@ -205,9 +206,11 @@ function DOMDownloadImpl() {
this.path = null; this.path = null;
this.state = "stopped"; this.state = "stopped";
this.contentType = null; this.contentType = null;
this.startTime = Date.now();
this.error = null; this.error = null;
/* fields that require getters/setters */
this._startTime = new Date();
/* private fields */ /* private fields */
this.id = null; this.id = null;
} }
@ -244,6 +247,19 @@ DOMDownloadImpl.prototype = {
return this.__DOM_IMPL__.getEventHandler("onstatechange"); return this.__DOM_IMPL__.getEventHandler("onstatechange");
}, },
get startTime() {
return this._startTime;
},
set startTime(aStartTime) {
if (aStartTime instanceof Date) {
this._startTime = aStartTime;
}
else {
this._startTime = new Date(aStartTime);
}
},
_init: function(aWindow, aDownload) { _init: function(aWindow, aDownload) {
this._window = aWindow; this._window = aWindow;
this.id = aDownload.id; this.id = aDownload.id;