diff --git a/www/assert/index.html b/www/assert/index.html index f4867629f..eb0bd659f 100644 --- a/www/assert/index.html +++ b/www/assert/index.html @@ -19,6 +19,11 @@ .error { border: 1px solid red; } + .thumb { + max-height: 150px; + width: auto; + border: 3px solid black; + } @@ -36,6 +41,7 @@

"pewpewpew"

+

Test 2

@@ -45,3 +51,6 @@

Here is a macro


+ + + diff --git a/www/assert/main.js b/www/assert/main.js index 7124f58d9..4a2ccc3d8 100644 --- a/www/assert/main.js +++ b/www/assert/main.js @@ -5,8 +5,9 @@ define([ 'json.sortify', '/common/cryptpad-common.js', '/drive/tests.js', - '/common/test.js' -], function ($, Hyperjson, TextPatcher, Sortify, Cryptpad, Drive, Test) { + '/common/test.js', + '/common/common-thumbnail.js', +], function ($, Hyperjson, TextPatcher, Sortify, Cryptpad, Drive, Test, Thumb) { window.Hyperjson = Hyperjson; window.TextPatcher = TextPatcher; window.Sortify = Sortify; @@ -207,6 +208,31 @@ define([ return cb(true); }, "version 2 hash failed to parse correctly"); + assert(function (cb) { + var getBlob = function (url, cb) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", url, true); + xhr.responseType = "blob"; + xhr.onload = function () { + cb(void 0, this.response); + }; + xhr.send(); + }; + + var $img = $('img#thumb-orig'); + getBlob($img.attr('src'), function (e, blob) { + console.log(e, blob); + Thumb.fromImageBlob(blob, function (e, thumb) { + console.log(thumb); + var th = new Image(); + th.src = URL.createObjectURL(thumb); + th.onload = function () { + $(document.body).append($(th).addClass('thumb')); + cb(th.width === 100 && th.height === 100); + }; + }); + }); + }); Drive.test(assert);