<style> div {
width: 200px;
height: 200px;
background-size: 200px 200px; background-image: url(sendimagenevercomplete.sjs)
}
</style>
<script>
/* sendimagenevercomplete.sjs sends us a partial png file and keeps the
* connection open but sends no more data. This is enough data to draw at last
* a partial frame. We do this so that we can distinguish from drawing a
* partial frame after we've been told all data has arrived, from drawing
* a partial frame while data is still arriving.
*/
function checkPixel(r, x, y, red, green, blue, alpha) {
let canvas = snapshotRect(window, r);
let context = canvas.getContext('2d');
let image = context.getImageData(x, y, 1, 1);
if (image.data[0] == red &&
image.data[1] == green &&
image.data[2] == blue &&
image.data[3] == alpha) {
return true;
}
return false;
}
async function runTest() {
let theDiv = document.createElement("div");
document.body.appendChild(theDiv);
let r = theDiv.getBoundingClientRect();
// Give that some time to partially load.
for (let i = 0; i < 10; i++) {
await new Promise(resolve => requestAnimationFrame(resolve));
}
let correct = false;
while (!correct) {
// Check the middle pixel part way down the partial frame.
correct = checkPixel(r, 100, 25, 0, 0, 255, 255);
await new Promise(resolve => requestAnimationFrame(resolve));
}
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.