jenkins-bot has submitted this change and it was merged.
Change subject: Remove old code for old browsers
......................................................................
Remove old code for old browsers
Everything related to submitting forms through the iframe transport
is now gone.
Bug: T131248
Change-Id: Ia38b5c36c20c86c6493d7bc3db4738fdbb0cf20c
---
M UploadWizard.php
M UploadWizardHooks.php
D resources/handlers/mw.ApiUploadHandler.js
M resources/handlers/mw.FirefoggHandler.js
M resources/mw.UploadWizard.js
M resources/mw.UploadWizardPage.js
M resources/mw.UploadWizardUpload.js
M resources/mw.UploadWizardUploadInterface.js
M resources/mw.fileApi.js
D resources/transports/mw.IframeTransport.js
M tests/qunit/mw.fileApi.test.js
D tests/qunit/transports/mw.IframeTransport.test.js
12 files changed, 69 insertions(+), 482 deletions(-)
Approvals:
MarkTraceur: Looks good to me, approved
Jforrester: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/UploadWizard.php b/UploadWizard.php
index 94614aa..fdff930 100644
--- a/UploadWizard.php
+++ b/UploadWizard.php
@@ -104,19 +104,6 @@
),
) + $uploadWizardModuleInfo;
-$wgResourceModules['ext.uploadWizard.iFrameTransport'] = array(
- 'scripts' => 'transports/mw.IframeTransport.js',
- 'dependencies' => array(
- 'oojs',
- ),
-) + $uploadWizardModuleInfo;
-
-$wgResourceModules['ext.uploadWizard.apiUploadHandler'] = array(
- 'scripts' => 'handlers/mw.ApiUploadHandler.js',
- 'dependencies' => 'ext.uploadWizard.iFrameTransport',
- 'messages' => 'mwe-upwiz-transport-started',
-) + $uploadWizardModuleInfo;
-
$wgResourceModules['ext.uploadWizard.apiUploadPostHandler'] = array(
'scripts' => 'handlers/mw.ApiUploadPostHandler.js',
'messages' => 'mwe-upwiz-transport-started',
diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php
index 33a9e4d..36bff93 100644
--- a/UploadWizardHooks.php
+++ b/UploadWizardHooks.php
@@ -35,7 +35,6 @@
'mediawiki.feedback',
'moment',
'uw.base',
- 'ext.uploadWizard.apiUploadHandler',
'ext.uploadWizard.apiUploadPostHandler',
'ext.uploadWizard.apiUploadFormDataHandler',
'ext.uploadWizard.events',
@@ -909,7 +908,6 @@
'tests/qunit/controller/uw.controller.Tutorial.test.js',
'tests/qunit/controller/uw.controller.Upload.test.js',
'tests/qunit/transports/mw.FormDataTransport.test.js',
-
'tests/qunit/transports/mw.IframeTransport.test.js',
'tests/qunit/uw.EventFlowLogger.test.js',
'tests/qunit/uw.ConcurrentQueue.test.js',
'tests/qunit/mw.UploadWizard.test.js',
diff --git a/resources/handlers/mw.ApiUploadHandler.js
b/resources/handlers/mw.ApiUploadHandler.js
deleted file mode 100644
index 5fb50c2..0000000
--- a/resources/handlers/mw.ApiUploadHandler.js
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * An attempt to refactor out the stuff that does API-via-iframe transport
- * In the hopes that this will eventually work for AddMediaWizard too
- */
-
-// n.b. if there are message strings, or any assumption about HTML structure
of the form.
-// then we probably did it wrong
-
-( function ( mw, $ ) {
-
- /**
- * Represents an object which configures a form to upload its files via
an iframe talking to the MediaWiki API.
- *
- * @param {mw.UploadWizardUpload} upload current upload
- * @param {mw.Api} api
- */
- mw.ApiUploadHandler = function ( upload, api ) {
- // the Iframe transport is hardcoded for now because it works
everywhere
- // can also use Xhr Binary depending on browser
- this.upload = upload;
- this.api = api;
- this.$form = $( this.upload.ui.form );
- this.configureForm();
-
- this.transport = new mw.IframeTransport( this.$form );
- };
-
- mw.ApiUploadHandler.prototype = {
- /**
- * Configure an HTML form so that it will submit its files to
our transport (an iframe)
- * with proper params for the API
- */
- configureForm: function () {
- this.addFormInputIfMissing( 'action', 'upload' );
-
- // force stash
- this.addFormInputIfMissing( 'stash', 1 );
-
- // ignore warnings (see mw.FormDataTransport for more)
- this.addFormInputIfMissing( 'ignorewarnings', 1 );
-
- // XXX TODO - remove; if we are uploading to stash
only, a comment should not be required - yet.
- this.addFormInputIfMissing( 'comment', 'DUMMY TEXT' );
-
- // we use JSON in HTML because according to mdale, some
browsers cannot handle just JSON
- this.addFormInputIfMissing( 'format', 'jsonfm' );
-
- if ( this.upload.fromURL ) {
- this.removeFormInputIfPresent( 'file' );
- this.addFormInputIfMissing( 'url',
this.upload.providedFile.url );
- }
- },
-
- /**
- * Modify our form to have a fresh edit token.
- *
- * @return {jQuery.Promise}
- */
- configureEditToken: function () {
- var handler = this;
-
- return this.api.getEditToken()
- .then( function ( token ) {
- handler.removeFormInputIfPresent(
'token' );
- handler.addFormInputIfMissing( 'token',
token );
- } );
- },
-
- /**
- * Remove a file input if it's there.
- *
- * @param {string} name
- */
- removeFormInputIfPresent: function ( name ) {
- var $input = this.$form.find( '[name="' + name + '"]' );
-
- if ( $input.length > 0 ) {
- $input.remove();
- }
- },
-
- /**
- * Add a hidden input to a form if it was not already there.
- *
- * @param {string} name the name of the input
- * @param {string} value the value of the input
- */
- addFormInputIfMissing: function ( name, value ) {
- if ( this.$form.find( '[name="' + name + '"]' ).length
=== 0 ) {
- this.$form.append( $( '<input>' ) .attr( {
type: 'hidden', name: name, value: value } ) );
- }
- },
-
- /**
- * Kick off the upload!
- *
- * @return {jQuery.Promise}
- */
- start: function () {
- var handler = this;
-
- return this.configureEditToken()
- .then( function () {
- handler.beginTime = ( new Date()
).getTime();
- handler.upload.ui.setStatus(
'mwe-upwiz-transport-started' );
-
handler.upload.ui.showTransportProgress();
-
- return handler.transport.upload()
- .progress( function ( fraction
) {
-
handler.upload.setTransportProgress( fraction );
- } )
- .then( function ( result ) {
-
handler.upload.setTransported( result );
- } );
- }, function ( code, info ) {
- handler.upload.setError( code, info );
- } );
- }
- };
-}( mediaWiki, jQuery ) );
diff --git a/resources/handlers/mw.FirefoggHandler.js
b/resources/handlers/mw.FirefoggHandler.js
index 022c17c..59ca3cf 100644
--- a/resources/handlers/mw.FirefoggHandler.js
+++ b/resources/handlers/mw.FirefoggHandler.js
@@ -24,12 +24,9 @@
getTransport: function () {
var file, transport,
- upload = this.upload,
- $fileInput = upload.ui.$fileInputCtrl[ 0 ];
+ upload = this.upload;
- if ( $fileInput.files && $fileInput.files.length ) {
- file = $fileInput.files[ 0 ];
- } else if ( upload.file ) {
+ if ( upload.file ) {
file = upload.file;
} else if ( upload.providedFile ) {
file = upload.providedFile;
diff --git a/resources/mw.UploadWizard.js b/resources/mw.UploadWizard.js
index 246a9fd..0ada62e 100644
--- a/resources/mw.UploadWizard.js
+++ b/resources/mw.UploadWizard.js
@@ -89,11 +89,7 @@
$fileInputCtrl,
wizard = this;
- $fileInputCtrl = $( '<input type="file" name="file"
class="mwe-upwiz-file-input" />' );
- if ( mw.fileApi.isFormDataAvailable() ) {
- // Multiple uploads requires the FormData
transport
- $fileInputCtrl.attr( 'multiple', '1' );
- }
+ $fileInputCtrl = $( '<input type="file" multiple
name="file" class="mwe-upwiz-file-input" />' );
// #mwe-upwiz-add-file is a ButtonWidget constructed
somewhere else, so this is hacky.
// But it's less bad than how this was done before.
@@ -104,7 +100,7 @@
totalSize, uploadObj, thumbPromise,
uploadObjs = [],
uploadInterfaceDivs = [],
- files = mw.fileApi.isAvailable() &&
$fileInputCtrl[ 0 ].files,
+ files = $fileInputCtrl[ 0 ].files,
totalFiles = ( files ? files.length : 1
) + wizard.uploads.length,
tooManyFiles = totalFiles >
wizard.config.maxUploads;
@@ -113,24 +109,18 @@
return;
}
- if ( mw.fileApi.isAvailable() ) {
- totalSize = 0;
- $.each( files, function ( i, file ) {
- totalSize += file.size;
- } );
+ totalSize = 0;
+ $.each( files, function ( i, file ) {
+ totalSize += file.size;
+ } );
- $.each( files, function ( i, file ) {
- uploadObj = wizard.addUpload(
file, totalSize > 10000000 );
- uploadObjs.push( uploadObj );
- // We'll attach all interfaces
to the DOM at once rather than one-by-one, for better
- // performance
- uploadInterfaceDivs.push(
uploadObj.ui.div );
- } );
- } else {
- uploadObj = wizard.addUpload(
$fileInputCtrl.off( 'change' ).detach(), false );
+ $.each( files, function ( i, file ) {
+ uploadObj = wizard.addUpload( file,
totalSize > 10000000 );
uploadObjs.push( uploadObj );
+ // We'll attach all interfaces to the
DOM at once rather than one-by-one, for better
+ // performance
uploadInterfaceDivs.push(
uploadObj.ui.div );
- }
+ } );
// Attach all interfaces to the DOM
$( '#mwe-upwiz-filelist' ).append( $(
uploadInterfaceDivs ) );
@@ -344,9 +334,10 @@
* Create the upload interface, a handler to transport it to
the server, and UI for the upload
* itself; and immediately fill it with a file and add it to
the list of uploads.
*
+ * @param {File} file
* @return {UploadWizardUpload|false} The new upload, or false
if it can't be added
*/
- addUpload: function ( fileLike ) {
+ addUpload: function ( file ) {
var upload,
wizard = this;
@@ -371,12 +362,8 @@
'remove-upload': [ 'removeUpload', upload ]
} );
- upload.fill( fileLike );
-
- upload.checkFile(
- upload.ui.getFilename(),
- mw.fileApi.isAvailable() ? fileLike : null
- );
+ upload.fill( file );
+ upload.checkFile( upload.ui.getFilename(), file );
return upload;
},
diff --git a/resources/mw.UploadWizardPage.js b/resources/mw.UploadWizardPage.js
index 141a126..5ee1e85 100644
--- a/resources/mw.UploadWizardPage.js
+++ b/resources/mw.UploadWizardPage.js
@@ -9,6 +9,15 @@
// Create UploadWizard
( function ( mw, $ ) {
+ function isCompatible() {
+ return !!(
+ window.FileReader &&
+ window.FormData &&
+ window.File &&
+ window.File.prototype.slice
+ );
+ }
+
mw.UploadWizardPage = function () {
var uploadWizard,
@@ -25,7 +34,7 @@
return;
}
- if ( !mw.fileApi.isAvailable() ||
!mw.fileApi.isFormDataAvailable() ) {
+ if ( !isCompatible() ) {
// Display the same error message as for grade-C
browsers
$( '.mwe-upwiz-unavailable' ).show();
return;
diff --git a/resources/mw.UploadWizardUpload.js
b/resources/mw.UploadWizardUpload.js
index 4f24c01..52e86b3 100644
--- a/resources/mw.UploadWizardUpload.js
+++ b/resources/mw.UploadWizardUpload.js
@@ -78,13 +78,11 @@
* @param {File} providedFile
*/
mw.UploadWizardUpload.prototype.fill = function ( providedFile ) {
- if ( providedFile && !( providedFile instanceof jQuery ) ) {
- this.providedFile = providedFile;
+ this.providedFile = providedFile;
- // check to see if the File is being uploaded from a
3rd party URL.
- if ( providedFile.fromURL ) {
- this.fromURL = true;
- }
+ // check to see if the File is being uploaded from a 3rd party
URL.
+ if ( providedFile.fromURL ) {
+ this.fromURL = true;
}
this.ui.fill( providedFile );
@@ -102,7 +100,7 @@
mw.UploadWizardUpload.prototype.start = function () {
this.setTransportProgress( 0.0 );
- // handler -- usually ApiUploadHandler
+ // handler -- usually ApiUploadFormDataHandler
this.handler = this.getUploadHandler();
return this.handler.start();
};
@@ -433,45 +431,36 @@
} else {
// Split this into a separate case, if the
error above got ignored,
// we want to still trudge forward.
- // if the JavaScript FileReader is available,
extract more info via fileAPI
- if ( mw.fileApi.isAvailable() ) {
- this.file = file;
- // If chunked uploading is enabled, we
can transfer any file that MediaWiki
- // will accept. Otherwise we're bound
by PHP's limits.
- // NOTE: Because we don't know until
runtime if the browser supports chunked
- // uploading, we can't determine this
server-side.
- if (
mw.UploadWizard.config.enableChunked && mw.fileApi.isFormDataAvailable() ) {
- actualMaxSize =
mw.UploadWizard.config.maxMwUploadSize;
- } else {
- actualMaxSize = Math.min(
-
mw.UploadWizard.config.maxMwUploadSize,
-
mw.UploadWizard.config.maxPhpUploadSize
- );
- }
+ // Extract more info via File API
+ this.file = file;
- // make sure the file isn't too large
- // XXX need a way to find the size of
the Flickr image
- if ( !this.fromURL ) {
- this.transportWeight =
this.file.size;
- if ( this.transportWeight >
actualMaxSize ) {
-
this.showMaxSizeWarning( this.transportWeight, actualMaxSize );
- return;
- }
- }
- if ( this.imageinfo === undefined ) {
- this.imageinfo = {};
- }
- this.filename = filename;
- if ( this.hasError === false ) {
- finishCallback();
- }
-
+ // If chunked uploading is enabled, we can
transfer any file that MediaWiki
+ // will accept. Otherwise we're bound by PHP's
limits.
+ if ( mw.UploadWizard.config.enableChunked ) {
+ actualMaxSize =
mw.UploadWizard.config.maxMwUploadSize;
} else {
- this.filename = filename;
- if ( this.hasError === false ) {
- finishCallback();
+ actualMaxSize = Math.min(
+
mw.UploadWizard.config.maxMwUploadSize,
+
mw.UploadWizard.config.maxPhpUploadSize
+ );
+ }
+
+ // make sure the file isn't too large
+ // XXX need a way to find the size of the
Flickr image
+ if ( !this.fromURL ) {
+ this.transportWeight = this.file.size;
+ if ( this.transportWeight >
actualMaxSize ) {
+ this.showMaxSizeWarning(
this.transportWeight, actualMaxSize );
+ return;
}
+ }
+ if ( this.imageinfo === undefined ) {
+ this.imageinfo = {};
+ }
+ this.filename = filename;
+ if ( this.hasError === false ) {
+ finishCallback();
}
}
}
@@ -761,7 +750,7 @@
/**
* Get the upload handler per browser capabilities
*
- * @return {ApiUploadHandler} upload handler object
+ * @return
{FirefoggHandler|ApiUploadFormDataHandler|ApiUploadPostHandler} upload handler
object
*/
mw.UploadWizardUpload.prototype.getUploadHandler = function () {
var constructor; // must be the name of a function in 'mw'
namespace
@@ -769,10 +758,8 @@
if ( !this.uploadHandler ) {
if ( mw.UploadWizard.config.enableFirefogg &&
mw.Firefogg.isInstalled() ) {
constructor = 'FirefoggHandler';
- } else if ( mw.fileApi.isAvailable() &&
mw.fileApi.isFormDataAvailable() ) {
- constructor = 'ApiUploadFormDataHandler';
} else {
- constructor = 'ApiUploadHandler';
+ constructor = 'ApiUploadFormDataHandler';
}
if ( mw.UploadWizard.config.debug ) {
mw.log( 'mw.UploadWizard::getUploadHandler> ' +
constructor );
@@ -1184,7 +1171,7 @@
* Check if the file is previewable.
*/
mw.UploadWizardUpload.prototype.isPreviewable = function () {
- return mw.fileApi.isAvailable() && this.file &&
mw.fileApi.isPreviewableFile( this.file );
+ return this.file && mw.fileApi.isPreviewableFile( this.file );
};
/**
@@ -1198,7 +1185,7 @@
* Checks if this upload is a video.
*/
mw.UploadWizardUpload.prototype.isVideo = function () {
- return mw.fileApi.isAvailable() &&
mw.fileApi.isPreviewableVideo( this.file );
+ return mw.fileApi.isPreviewableVideo( this.file );
};
} )( mediaWiki, jQuery, OO );
diff --git a/resources/mw.UploadWizardUploadInterface.js
b/resources/mw.UploadWizardUploadInterface.js
index 256cae3..cb74716 100644
--- a/resources/mw.UploadWizardUploadInterface.js
+++ b/resources/mw.UploadWizardUploadInterface.js
@@ -83,12 +83,7 @@
* @param {File} providedFile
*/
mw.UploadWizardUploadInterface.prototype.fill = function ( providedFile
) {
- if ( providedFile instanceof jQuery ) {
- this.$fileInputCtrl = providedFile;
- this.form.append( this.$fileInputCtrl );
- } else if ( providedFile ) {
- this.providedFile = providedFile;
- }
+ this.providedFile = providedFile;
this.clearErrors();
};
@@ -221,22 +216,11 @@
* @return {string}
*/
mw.UploadWizardUploadInterface.prototype.getFilename = function () {
- var input;
- if ( this.providedFile ) {
- if ( this.providedFile.fileName ) {
- return this.providedFile.fileName;
- } else {
- // this property has a different name in FF vs
Chrome.
- return this.providedFile.name;
- }
+ if ( this.providedFile.fileName ) {
+ return this.providedFile.fileName;
} else {
- input = this.$fileInputCtrl.get( 0 );
- // On IE 11, input.value is incorrect for <input
type=file multiple>, like we're using here;
- // the input.files interface is reliable.
(T88223#1595320)
- if ( input.files && input.files[ 0 ] && input.files[ 0
].name ) {
- return input.files[ 0 ].name;
- }
- return input.value;
+ // this property has a different name in FF vs Chrome.
+ return this.providedFile.name;
}
};
@@ -290,13 +274,7 @@
mw.UploadWizardUploadInterface.prototype.fileChangedError = function (
code, info ) {
var filename = this.getFilename();
- if ( this.$fileInputCtrl ) {
- this.$fileInputCtrl.remove();
- delete this.$fileInputCtrl;
- }
- if ( this.providedFile ) {
- this.providedFile = null;
- }
+ this.providedFile = null;
if ( code === 'ext' ) {
this.showBadExtensionError( filename, info );
diff --git a/resources/mw.fileApi.js b/resources/mw.fileApi.js
index 910bd15..86e1af0 100644
--- a/resources/mw.fileApi.js
+++ b/resources/mw.fileApi.js
@@ -5,13 +5,6 @@
mw.fileApi = {
/**
- * Is the FileAPI available with sufficient functionality?
- */
- isAvailable: function () {
- return typeof window.FileReader !== 'undefined';
- },
-
- /**
* Check if this is a recognizable image type...
* Also excludes files over 10M to avoid going insane on memory
usage.
*
@@ -36,10 +29,7 @@
isPreviewableVideo: function ( file ) {
var video = document.createElement( 'video' );
return video.canPlayType && video.canPlayType(
file.type ).replace( 'no', '' ) !== '';
- },
-
- isFormDataAvailable: function () {
- return window.FormData !== undefined && window.File !==
undefined && window.File.prototype.slice !== undefined;
}
+
};
}( mediaWiki, jQuery ) );
diff --git a/resources/transports/mw.IframeTransport.js
b/resources/transports/mw.IframeTransport.js
deleted file mode 100644
index 9f34c55..0000000
--- a/resources/transports/mw.IframeTransport.js
+++ /dev/null
@@ -1,140 +0,0 @@
-( function ( mw, $ ) {
- /**
- * @class mw.IframeTransport
- * Represents a "transport" for files to upload; in this case an iframe.
- * XXX dubious whether this is really separated from
"ApiUploadHandler", which does a lot of form config.
- * The iframe is made to be the target of a form so that the existing
page does not reload, even though it's a POST.
- * @constructor
- * @param {jQuery} $form HTML form with the upload data.
- */
- mw.IframeTransport = function ( $form ) {
- var iframe,
- transport = this;
-
- function setupFormCallback() {
- transport.$iframe.off( 'load', setupFormCallback );
- transport.setUpStatus.resolve();
- }
- function iframeError() {
- transport.setUpStatus.reject();
- }
-
- this.$form = $form;
- this.setUpStatus = $.Deferred();
-
- this.iframeId = 'f_' + ( $( 'iframe' ).length + 1 );
-
- // IE only works if you "create element with the name" ( not
jquery style )
- try {
- iframe = document.createElement( '<iframe name="' +
this.iframeId + '">' );
- } catch ( ex ) {
- iframe = document.createElement( 'iframe' );
- }
-
- this.$iframe = $( iframe );
-
- // we configure form on load, because the first time it loads,
it's blank
- // then we configure it to deal with an API submission
- // Using javascript:false because it works in IE6; otherwise
about:blank would
- // be a viable option; see If04206fa993129
-
- /* jshint scripturl: true */
- this.$iframe
- .load( setupFormCallback )
- .error( iframeError )
- .prop( 'id', this.iframeId )
- .prop( 'name', this.iframeId )
- .prop( 'src', 'javascript:false;' )
- .addClass( 'hidden' )
- .hide();
- /* jshint scripturl: false */
-
- $( 'body' ).append( this.$iframe );
- };
-
- /**
- * Accessor function
- *
- * @return {jQuery.Promise}
- */
- mw.IframeTransport.prototype.getSetUpStatus = function () {
- return this.setUpStatus.promise();
- };
-
- /**
- * Process the result of the form submission, returned to an iframe.
- * This is the iframe's onload event.
- *
- * @param {Element} iframe iframe to extract result from
- */
- mw.IframeTransport.prototype.processIframeResult = function ( iframe ) {
- var response, json,
- doc = iframe.contentDocument || frames[ iframe.id
].document;
-
- // Fix for Opera 9.26
- if ( doc.readyState && doc.readyState !== 'complete' ) {
- return;
- }
-
- // Fix for Opera 9.64
- if ( doc.body && doc.body.innerHTML === 'false' ) {
- return;
- }
-
- if ( doc.XMLDocument ) {
- // The response is a document property in IE
- response = doc.XMLDocument;
- } else if ( doc.body ) {
- // Get the json string
- // We're actually searching through an HTML doc here --
- // according to mdale we need to do this
- // because IE does not load JSON properly in an iframe
- json = $( doc.body ).find( 'pre' ).text();
-
- // check that the JSON is not an XML error message
- // (this happens when user aborts upload, we get the
API docs in XML wrapped in HTML)
- if ( json && json.substring( 0, 5 ) !== '<?xml' ) {
- response = $.parseJSON( json );
- } else {
- response = {};
- }
- } else {
- // Response is a xml document
- response = doc;
- }
-
- // Process the API result
- return response;
- };
-
- /**
- * Start the upload.
- *
- * @return {jQuery.Promise}
- */
- mw.IframeTransport.prototype.upload = function () {
- var transport = this;
-
- return this.getSetUpStatus().then( function () {
- var deferred = $.Deferred();
-
- // Set the form target to the iframe
- transport.$form.prop( 'target', transport.iframeId );
-
- // attach an additional handler to the form, so, when
submitted, it starts showing the progress
- // XXX this is lame .. there should be a generic way to
indicate busy status...
- transport.$form.submit( function () {
- return true;
- } );
-
- transport.$iframe.on( 'load', function () {
- deferred.notify( 1.0 );
- deferred.resolve(
transport.processIframeResult( this ) );
- } );
-
- transport.$form.submit();
-
- return deferred.promise();
- } );
- };
-}( mediaWiki, jQuery ) );
diff --git a/tests/qunit/mw.fileApi.test.js b/tests/qunit/mw.fileApi.test.js
index 7383fba..d2effac 100644
--- a/tests/qunit/mw.fileApi.test.js
+++ b/tests/qunit/mw.fileApi.test.js
@@ -18,18 +18,6 @@
( function ( mw ) {
QUnit.module( 'mw.fileApi', QUnit.newMwEnvironment() );
- QUnit.test( 'isAvailable', 2, function ( assert ) {
- var oldFileReader = window.FileReader;
-
- window.FileReader = undefined;
- assert.strictEqual( mw.fileApi.isAvailable(), false );
-
- window.FileReader = {};
- assert.strictEqual( mw.fileApi.isAvailable(), true );
-
- window.FileReader = oldFileReader;
- } );
-
QUnit.test( 'isPreviewableFile', 6, function ( assert ) {
var testFile = {};
@@ -76,40 +64,4 @@
assert.strictEqual( fakeVideo.canPlayType.callCount, 1 );
} );
- QUnit.test( 'isFormDataAvailable', 6, function ( assert ) {
- var oldfd = window.FormData,
- oldf = window.File;
-
- window.FormData = undefined;
- window.File = undefined;
-
- assert.strictEqual( mw.fileApi.isFormDataAvailable(), false );
-
- window.File = { prototype: {} };
- assert.strictEqual( mw.fileApi.isFormDataAvailable(), false );
-
- window.FormData = {};
- assert.strictEqual( mw.fileApi.isFormDataAvailable(), false );
-
- window.File = {
- prototype: {
- slice: function () {}
- }
- };
- assert.strictEqual( mw.fileApi.isFormDataAvailable(), true );
-
- window.File = undefined;
- assert.strictEqual( mw.fileApi.isFormDataAvailable(), false );
-
- window.FormData = undefined;
- window.File = {
- prototype: {
- slice: function () {}
- }
- };
- assert.strictEqual( mw.fileApi.isFormDataAvailable(), false );
-
- window.FormData = oldfd;
- window.File = oldf;
- } );
}( mediaWiki ) );
diff --git a/tests/qunit/transports/mw.IframeTransport.test.js
b/tests/qunit/transports/mw.IframeTransport.test.js
deleted file mode 100644
index 4ae9243..0000000
--- a/tests/qunit/transports/mw.IframeTransport.test.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This file is part of the MediaWiki extension UploadWizard.
- *
- * UploadWizard is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * UploadWizard is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with UploadWizard. If not, see <http://www.gnu.org/licenses/>.
- */
-
-( function ( mw, $ ) {
- QUnit.module( 'mw.IframeTransport', QUnit.newMwEnvironment() );
-
- function createTransport() {
- return new mw.IframeTransport( $( '<form>' ) );
- }
-
- QUnit.test( 'Constructor sanity test', 1, function ( assert ) {
- var transport = createTransport();
-
- assert.ok( transport );
- } );
-
- QUnit.test( 'getSetUpStatus', 2, function ( assert ) {
- var transport = createTransport(),
- sustat = transport.getSetUpStatus();
-
- assert.ok( sustat );
- assert.ok( sustat.state() );
- } );
-}( mediaWiki, jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/278420
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia38b5c36c20c86c6493d7bc3db4738fdbb0cf20c
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits