2015-09-09 21:44:09 +02:00
|
|
|
ModuleLoader.require([
|
|
|
|
"tinymce/file/ImageScanner",
|
2016-07-12 02:19:47 +02:00
|
|
|
"tinymce/file/UploadStatus",
|
2015-09-09 21:44:09 +02:00
|
|
|
"tinymce/file/BlobCache",
|
|
|
|
"tinymce/Env"
|
2016-07-12 02:19:47 +02:00
|
|
|
], function(ImageScanner, UploadStatus, BlobCache, Env) {
|
2015-09-09 21:44:09 +02:00
|
|
|
if (!tinymce.Env.fileApi) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
module("tinymce.file.ImageScanner");
|
|
|
|
|
|
|
|
var base64Src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==';
|
|
|
|
|
|
|
|
QUnit.asyncTest("findAll", function() {
|
2016-07-12 02:19:47 +02:00
|
|
|
var imageScanner = new ImageScanner(new UploadStatus(), new BlobCache());
|
2015-09-09 21:44:09 +02:00
|
|
|
|
|
|
|
document.getElementById('view').innerHTML = (
|
|
|
|
'<img src="' + base64Src + '">' +
|
|
|
|
'<img src="' + Env.transparentSrc + '">' +
|
|
|
|
'<img src="' + base64Src + '" data-mce-bogus="1">' +
|
|
|
|
'<img src="' + base64Src + '" data-mce-placeholder="1">'
|
|
|
|
);
|
|
|
|
|
|
|
|
imageScanner.findAll(document.getElementById('view')).then(function(result) {
|
|
|
|
QUnit.start();
|
|
|
|
equal(result.length, 1);
|
|
|
|
equal('data:image/gif;base64,' + result[0].blobInfo.base64(), base64Src);
|
|
|
|
strictEqual(result[0].image, document.getElementById('view').firstChild);
|
|
|
|
});
|
|
|
|
});
|
2016-01-20 05:17:22 +01:00
|
|
|
|
|
|
|
QUnit.asyncTest("findAll (filtered)", function() {
|
2016-07-12 02:19:47 +02:00
|
|
|
var imageScanner = new ImageScanner(new UploadStatus(), new BlobCache());
|
2016-01-20 05:17:22 +01:00
|
|
|
|
|
|
|
function predicate(img) {
|
|
|
|
return !img.hasAttribute('data-skip');
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById('view').innerHTML = (
|
|
|
|
'<img src="' + base64Src + '">' +
|
|
|
|
'<img src="' + base64Src + '" data-skip="1">'
|
|
|
|
);
|
|
|
|
|
|
|
|
imageScanner.findAll(document.getElementById('view'), predicate).then(function(result) {
|
|
|
|
QUnit.start();
|
|
|
|
equal(result.length, 1);
|
|
|
|
equal('data:image/gif;base64,' + result[0].blobInfo.base64(), base64Src);
|
|
|
|
strictEqual(result[0].image, document.getElementById('view').firstChild);
|
|
|
|
});
|
|
|
|
});
|
2015-09-09 21:44:09 +02:00
|
|
|
});
|