5 <script src='/tests/SimpleTest/SimpleTest.js'
></script>
6 <link rel='stylesheet' href='/tests/SimpleTest/test.css'
>
9 <img id='e_blank_15000x10000' src='blank_15000x10000.png'
>
12 function shouldBe(testStr
, refStr
) {
13 ok(testStr
== refStr
, 'Expected "' + refStr
+ '", was "' + testStr
+ '".');
16 function getErrorStr(gl
, err
) {
17 if (!err
) return "NO_ERROR";
27 function glErrorShouldBe(gl
, expected
, opt_info
) {
29 opt_info
= opt_info
+ ': '
34 if (!expected
.length
) {
35 expected
= [expected
];
37 expected
= expected
.map(x
=> getErrorStr(gl
, x
));
38 let was
= gl
.getError();
39 was
= getErrorStr(gl
, was
);
40 ok(expected
.includes(was
),
41 `${opt_info}Expected gl.getError() in [${expected}], was ${was}.`);
43 SimpleTest
.waitForExplicitFinish();
45 const gl
= document
.createElement('canvas').getContext('webgl2');
48 todo(false, 'No webgl2, skipping...');
51 const tex
= gl
.createTexture();
52 gl
.bindTexture(gl
.TEXTURE_2D
, tex
);
55 //{w: 16000, h: 8000}, // TODO: This asserts.
56 //{w: 8000, h: 16000}, // TODO: This asserts.
61 const src
= document
.createElement('canvas').getContext('webgl',
62 {antialias
:false, depth
:false});
63 const maxTexSize
= gl
.getParameter(gl
.MAX_TEXTURE_SIZE
);
64 for (const t
of TESTS
) {
65 ok(true, 'canvas: ' + JSON
.stringify(t
));
66 if (t
.w
> maxTexSize
|| t
.h
> maxTexSize
) {
67 ok(true, `Larger than MAX_TEXTURE_SIZE of ${maxTexSize}`);
70 src
.canvas
.width
= t
.w
;
71 src
.canvas
.height
= t
.h
;
72 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA8
, gl
.RGBA
, gl
.UNSIGNED_BYTE
,
75 glErrorShouldBe(gl
, [0, gl
.OUT_OF_MEMORY
], `after texImage(${JSON.stringify(t)})`);
77 src
.canvas
.width
= src
.canvas
.height
= 1;
80 if (15000 > maxTexSize
) {
81 ok(true, `e_blank_15000x10000 larger than MAX_TEXTURE_SIZE of ${maxTexSize}, skipping.`);
83 await e_blank_15000x10000
.decode(); // Otherwise it will not have loaded yet.
84 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA8
, gl
.RGBA
, gl
.UNSIGNED_BYTE
,
86 glErrorShouldBe(gl
, [0, gl
.OUT_OF_MEMORY
], `after texImage(e_blank_15000x10000)`);
87 ok(!gl
.isContextLost(), '!gl.isContextLost()');