4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"resources/webgl-test.js"></script>
8 <div id=
"description"></div>
9 <div id=
"console"></div>
12 description("Test of getActiveAttrib and getActiveUniform");
15 window
.internals
.settings
.setWebGLErrorsToConsoleEnabled(false);
17 var context
= create3DContext();
18 var context2
= create3DContext();
19 var program
= loadStandardProgram(context
);
20 var program2
= loadProgram(context2
,
21 "resources/intArrayUniformShader.vert",
22 "resources/noopUniformShader.frag");
24 glErrorShouldBe(context
, context
.NO_ERROR
);
25 shouldBe("context.getActiveUniform(program, 0).name", "'u_modelViewProjMatrix'");
26 shouldBe("context.getActiveUniform(program, 0).type", "context.FLOAT_MAT4");
27 shouldBe("context.getActiveUniform(program, 0).size", "1");
28 shouldBeNull("context.getActiveUniform(program, 1)");
29 glErrorShouldBe(context
, context
.INVALID_VALUE
);
30 shouldBeNull("context.getActiveUniform(program, -1)");
31 glErrorShouldBe(context
, context
.INVALID_VALUE
);
32 shouldBeNull("context.getActiveUniform(null, 0)");
33 glErrorShouldBe(context
, context
.INVALID_VALUE
);
35 // we don't know the order the attribs will appear.
37 context
.getActiveAttrib(program
, 0),
38 context
.getActiveAttrib(program
, 1)
40 for (var ii
= 0; ii
< info
.length
; ++ii
)
41 shouldBeNonNull("info[ii]");
44 { name
: 'a_normal', type
: context
.FLOAT_VEC3
, size
: 1 },
45 { name
: 'a_vertex', type
: context
.FLOAT_VEC4
, size
: 1 }
48 if (info
[0].name
!= expected
[0].name
) {
54 for (var ii
= 0; ii
< info
.length
; ++ii
) {
55 shouldBe("info[ii].name", "expected[ii].name");
56 shouldBe("info[ii].type", "expected[ii].type");
57 shouldBe("info[ii].size", "expected[ii].size");
60 // we don't know the order the uniforms will appear.
62 context2
.getActiveUniform(program2
, 0),
63 context2
.getActiveUniform(program2
, 1)
65 for (var ii
= 0; ii
< info2
.length
; ++ii
)
66 shouldBeNonNull("info2[ii]");
69 { name
: 'ival', type
: context2
.INT
, size
: 1 },
70 { name
: 'ival2[0]', type
: context2
.INT
, size
: 2 }
73 if (info2
[0].name
!= expected2
[0].name
) {
79 for (var ii
= 0; ii
< info2
.length
; ++ii
) {
80 shouldBe("info2[ii].name", "expected2[ii].name");
81 shouldBe("info2[ii].type", "expected2[ii].type");
82 shouldBe("info2[ii].size", "expected2[ii].size");
85 shouldBeNull("context.getActiveAttrib(program, 2)");
86 glErrorShouldBe(context
, context
.INVALID_VALUE
);
87 shouldBeNull("context.getActiveAttrib(program, -1)");
88 glErrorShouldBe(context
, context
.INVALID_VALUE
);
89 shouldBeNull("context.getActiveAttrib(null, 0)");
90 glErrorShouldBe(context
, context
.INVALID_VALUE
);
92 glErrorShouldBe(context2
, context
.NO_ERROR
);
94 debug("Check trying to get attribs from different context");
95 shouldBeNull("context2.getActiveAttrib(program, 0)");
96 glErrorShouldBe(context2
, context2
.INVALID_OPERATION
);
97 shouldBeNull("context2.getActiveUniform(program, 0)");
98 glErrorShouldBe(context2
, context2
.INVALID_OPERATION
);
100 debug("Check trying to get attribs from deleted program");
101 context
.deleteProgram(program
);
102 shouldBeNull("context.getActiveUniform(program, 0)");
103 glErrorShouldBe(context
, context
.INVALID_VALUE
);
104 shouldBeNull("context.getActiveAttrib(program, 0)");
105 glErrorShouldBe(context
, context
.INVALID_VALUE
);