Backed out changeset b462e7b742d8 (bug 1908261) for causing multiple reftest failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / extensions / get-extension.html
blob8d9a9bc6de349855a654b71276497a88bb6f7ca6
1 <!--
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.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
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>
15 </head>
16 <body>
17 <div id="description"></div>
18 <canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
19 <div id="console"></div>
20 <script>
21 "use strict";
23 var pseudoRandom = (function() {
24 var seed = 3;
25 return function() {
26 seed = (seed * 11 + 17) % 25;
27 return seed / 25;
29 })();
31 var randomizeCase = function(str) {
32 var newChars = [];
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();
36 newChars.push(m);
38 return newChars.join("");
41 description();
43 var wtu = WebGLTestUtils;
44 var canvas = document.getElementById("canvas");
45 var gl = wtu.create3DContext(canvas);
47 var ii;
49 debug("check every extension advertised can be enabled");
50 debug("");
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);
62 if (extension) {
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);
73 assertMsg(
74 extension === extension2,
75 "calling getExtension twice for the same extension returns the same object");
76 assertMsg(
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) {
85 assertMsg(
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");
91 debug("");
94 var successfullyParsed = true;
95 </script>
96 <script src="../../js/js-test-post.js"></script>
98 </body>
99 </html>