diff --git a/tests/plugins/uploadwidget/manual/_helpers/xhrerror.js b/tests/plugins/uploadwidget/manual/_helpers/xhrerror.js index 5433c161779..2f4fadeb552 100644 --- a/tests/plugins/uploadwidget/manual/_helpers/xhrerror.js +++ b/tests/plugins/uploadwidget/manual/_helpers/xhrerror.js @@ -7,14 +7,31 @@ // Mock the real XMLHttpRequest so the upload test may show the effect of an error during upload. +window.FormData = function() { + var total, filename; + return { + append: function( name, file, filename ) { + total = file.size; + filename = filename; + }, + getTotal: function() { + return total; + }, + getFileName: function() { + return filename; + } + }; +}; + window.XMLHttpRequest = function() { return { open: function() {}, - send: function() { + send: function( formData ) { // Total file size. - var loaded = 0, - step = 10, + var total = formData.getTotal(), + loaded = 0, + step = Math.round( total / 10 ), onprogress = this.onprogress, onerror = this.onerror, interval; diff --git a/tests/plugins/uploadwidget/manual/error.md b/tests/plugins/uploadwidget/manual/error.md index 06756ffe422..60b1e87b4a8 100644 --- a/tests/plugins/uploadwidget/manual/error.md +++ b/tests/plugins/uploadwidget/manual/error.md @@ -7,5 +7,5 @@ This test emulates an error during upload. When upload hits 50% an error occurs. * Drop an image. * Check if `upload widget` is displayed. - * Check if image is removed after it reaches 50% of progress and no artifacts left. + * Check if image is removed when it reaches 50% of progress and no artifacts left. * Check if you see a message about the error. \ No newline at end of file