diff --git a/plugins/easyimage/plugin.js b/plugins/easyimage/plugin.js index 1971c2f3a19..8c215012a1c 100644 --- a/plugins/easyimage/plugin.js +++ b/plugins/easyimage/plugin.js @@ -184,6 +184,7 @@ var data = evt.data, // Prevent XSS attacks. tempDoc = document.implementation.createHTMLDocument( '' ), + widgetDef = editor.widgets.registered.uploadeasyimage, temp = new CKEDITOR.dom.element( tempDoc.body ), imgs, img, i; @@ -203,7 +204,7 @@ // We are not uploading images in non-editable blocs and fake objects (http://dev.ckeditor.com/ticket/13003). if ( isDataInSrc && isRealObject && !img.data( 'cke-upload-id' ) && !img.isReadOnly( 1 ) ) { - var loader = editor.uploadRepository.create( img.getAttribute( 'src' ) ); + var loader = editor.uploadRepository.create( img.getAttribute( 'src' ), undefined, widgetDef.loaderType ); loader.upload(); fileTools.markElement( img, 'uploadeasyimage', loader.id ); diff --git a/tests/plugins/easyimage/uploadwidget.js b/tests/plugins/easyimage/uploadwidget.js index c0e2e5e0ba6..4a04d17b027 100644 --- a/tests/plugins/easyimage/uploadwidget.js +++ b/tests/plugins/easyimage/uploadwidget.js @@ -48,14 +48,6 @@ } } - CKEDITOR.on( 'instanceCreated', function() { - if ( !CKEDITOR.plugins.cloudservices.cloudServicesLoader.restore ) { - // Because of #1068 we can't provide loaderType directly. Instead we just replace cloudServicesLoader - // with our loader stub that is going to be customized in init method. - sinon.stub( CKEDITOR.plugins.cloudservices, 'cloudServicesLoader', CKEDITOR.fileTools.fileLoader ); - } - } ); - tests = { init: function() { var responseData = { @@ -68,27 +60,20 @@ resumeAfter = bender.tools.resumeAfter; - // This tests suite could be made much prettier, it would require #1068 to be resolved. Then you - // could just use LoaderStub type with stubbed methods, rather than overwrite base FileLoader type. - CKEDITOR.fileTools.fileLoader.prototype.loadAndUpload = function() { + // Approach taken from tests/plugins/uploadwidget/uploadwidget.js test. + CKEDITOR.plugins.cloudservices.cloudServicesLoader.prototype.loadAndUpload = function() { loadAndUploadCount++; this.responseData = CKEDITOR.tools.clone( responseData ); }; - CKEDITOR.fileTools.fileLoader.prototype.load = function() {}; + CKEDITOR.plugins.cloudservices.cloudServicesLoader.prototype.load = function() {}; - CKEDITOR.fileTools.fileLoader.prototype.upload = function() { + CKEDITOR.plugins.cloudservices.cloudServicesLoader.prototype.upload = function() { uploadCount++; this.responseData = CKEDITOR.tools.clone( responseData ); }; - - // Now stub can be safely removed, as it's used only in plugin.init, which has already been called, - // this workaround could be removed once #1068 is fixed. - if ( CKEDITOR.plugins.cloudservices.cloudServicesLoader.restore ) { - CKEDITOR.plugins.cloudservices.cloudServicesLoader.restore(); - } }, setUp: function() {