2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <title>WebGL Extension Conformance Tests
</title>
12 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
13 <script src=
"../../js/js-test-pre.js"></script>
14 <script src=
"../../js/webgl-test-utils.js"></script>
17 <div id=
"description"></div>
18 <canvas id=
"canvas" style=
"width: 50px; height: 50px;"> </canvas>
19 <div id=
"console"></div>
23 var pseudoRandom
= (function() {
26 seed
= (seed
* 11 + 17) % 25;
31 var randomizeCase = function(str
) {
33 for (var ii
= 0; ii
< str
.length
; ++ii
) {
34 var c
= str
.substr(ii
, 1);
35 var m
= (pseudoRandom() > 0.5) ? c
.toLowerCase() : c
.toUpperCase();
38 return newChars
.join("");
43 var wtu
= WebGLTestUtils
;
44 var canvas
= document
.getElementById("canvas");
45 var gl
= wtu
.create3DContext(canvas
);
49 debug("check every extension advertised can be enabled");
51 var extensionNames
= gl
.getSupportedExtensions();
52 var extensionNamesLower
= [];
53 for (ii
= 0; ii
< extensionNames
.length
; ++ii
) {
54 extensionNamesLower
.push(extensionNames
[ii
].toLowerCase());
57 for (ii
= 0; ii
< extensionNames
.length
; ++ii
) {
58 var originalName
= extensionNames
[ii
];
59 var mixedName
= randomizeCase(originalName
);
60 var extension
= gl
.getExtension(mixedName
);
61 assertMsg(extension
, "able to get " + originalName
+ " as " + mixedName
);
63 var kTestString
= "this is a test";
64 var kTestNumber
= 123;
65 var kTestFunction = function() { };
66 var kTestObject
= { };
67 extension
.testStringProperty
= kTestString
;
68 extension
.testNumberProperty
= kTestNumber
;
69 extension
.testFunctionProperty
= kTestFunction
;
70 extension
.testObjectProperty
= kTestObject
;
71 webglHarnessCollectGarbage();
72 var extension2
= gl
.getExtension(originalName
);
74 extension
=== extension2
,
75 "calling getExtension twice for the same extension returns the same object");
77 extension2
.testStringProperty
=== kTestString
&&
78 extension2
.testFunctionProperty
=== kTestFunction
&&
79 extension2
.testObjectProperty
=== kTestObject
&&
80 extension2
.testNumberProperty
=== kTestNumber
,
81 "object returned by 2nd call to getExtension has same properties");
83 var prefixedVariants
= wtu
.getExtensionPrefixedNames(originalName
);
84 for (var jj
= 0; jj
< prefixedVariants
.length
; ++jj
) {
86 gl
.getExtension(prefixedVariants
[jj
]) === null ||
87 extensionNamesLower
.indexOf(prefixedVariants
[jj
].toLowerCase()) !== -1,
88 "getExtension('" + prefixedVariants
[jj
] + "') returns an object only if the name is returned by getSupportedExtensions");
94 var successfullyParsed
= true;
96 <script src=
"../../js/js-test-post.js"></script>