Last active
January 6, 2016 23:17
-
-
Save ybootin/fe380cd7265a90fa9e35 to your computer and use it in GitHub Desktop.
A simple polyfill of DOM ProgressEvent, work in PhantomJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(window) { | |
// http://engineering.shapesecurity.com/2015/01/detecting-phantomjs-based-visitors.html | |
if (/PhantomJS/.test(window.navigator.userAgent)) { | |
var ProgressEvent = function(type, eventInit) { | |
this.type = type | |
this.lengthComputable = eventInit.lengthComputable | |
this.loaded = eventInit.loaded | |
this.total = eventInit.total | |
} | |
ProgressEvent.prototype = Object.create(Event.prototype) | |
ProgressEvent.prototype.constructor = ProgressEvent | |
window.ProgressEvent = ProgressEvent | |
} | |
})(window) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(window) { | |
// http://engineering.shapesecurity.com/2015/01/detecting-phantomjs-based-visitors.html | |
if (/PhantomJS/.test(window.navigator.userAgent)) { | |
interface IProgressEventInit { | |
lengthComputable: boolean | |
loaded: number | |
total: number | |
} | |
var ProgressEvent = function(type: string, eventInit:IProgressEventInit): void { | |
this.type = type | |
this.lengthComputable = eventInit.lengthComputable | |
this.loaded = eventInit.loaded | |
this.total = eventInit.total | |
} | |
ProgressEvent.prototype = Object.create(Event.prototype) | |
ProgressEvent.prototype.constructor = ProgressEvent | |
window.ProgressEvent = ProgressEvent | |
} | |
})(window) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment