// Create files containing data we'll test with. We'll want long
// strings to ensure they span multiple buffers while loading
let canvasData;
let testBinaryData;
function imageLoadHandler(event, resolve) {
let origcanvas = $("canvas");
let testcanvas = $("testcanvas");
let image = event.target;
is(image.naturalWidth, origcanvas.width, "width correct");
is(image.naturalHeight, origcanvas.height, "height correct");
testcanvas.width = origcanvas.width;
testcanvas.height = origcanvas.height;
testcanvas.getContext("2d").drawImage(image, 0, 0);
// Do not use |is(testcanvas.toDataURL("image/png"), origcanvas.toDataURL("image/png"), "...");| that results in a _very_ long line.
let origDataURL = origcanvas.toDataURL("image/png");
let testDataURL = testcanvas.toDataURL("image/png");
is(testDataURL.length, origDataURL.length, "Length of correct image data");
ok(testDataURL == origDataURL, "Content of correct image data");
resolve();
}
createCanvasURL()
.then(data => {
for (var i = 0; i < 256; i++) {
testBinaryData += String.fromCharCode(i);
}
while (testBinaryData.length < 20000) {
testBinaryData += testBinaryData;
}
canvasData = data;
})
// image in the middle
.then(() => {
return createFile(testBinaryData + canvasData + testBinaryData, "middleTestFile");
})
// image in the middle - loader
.then(file => {
return new Promise(resolve => {
is(file.size, canvasData.length + testBinaryData.length * 2, "correct file size (middle)");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.