-
Notifications
You must be signed in to change notification settings - Fork 54
/
2d.imageData.put.unchanged.html
42 lines (36 loc) · 1.39 KB
/
2d.imageData.put.unchanged.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /offscreen-canvas/tools/gentest.py. -->
<title>OffscreenCanvas test: 2d.imageData.put.unchanged</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/2dcontext/resources/canvas-tests.js"></script>
<h1>2d.imageData.put.unchanged</h1>
<p class="desc">putImageData(getImageData(...), ...) has no effect</p>
<script>
var t = async_test("putImageData(getImageData(...), ...) has no effect");
var t_pass = t.done.bind(t);
var t_fail = t.step_func(function(reason) {
throw reason;
});
t.step(function() {
var offscreenCanvas = new OffscreenCanvas(100, 50);
var ctx = offscreenCanvas.getContext('2d');
var i = 0;
for (var y = 0; y < 16; ++y) {
for (var x = 0; x < 16; ++x, ++i) {
ctx.fillStyle = 'rgba(' + i + ',' + (Math.floor(i*1.5) % 256) + ',' + (Math.floor(i*23.3) % 256) + ',' + (i/256) + ')';
ctx.fillRect(x, y, 1, 1);
}
}
var imgdata1 = ctx.getImageData(0.1, 0.2, 15.8, 15.9);
var olddata = [];
for (var i = 0; i < imgdata1.data.length; ++i)
olddata[i] = imgdata1.data[i];
ctx.putImageData(imgdata1, 0.1, 0.2);
var imgdata2 = ctx.getImageData(0.1, 0.2, 15.8, 15.9);
for (var i = 0; i < imgdata2.data.length; ++i) {
_assertSame(olddata[i], imgdata2.data[i], "olddata[\""+(i)+"\"]", "imgdata2.data[\""+(i)+"\"]");
}
t.done();
});
</script>