4 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
5 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
11 WEBGL_TYPES
['experimental-webgl'] = true;
12 WEBGL_TYPES
.webgl
= true;
14 function AreBothIn(a
, b
, set) {
15 return (a
in set) && (b
in set);
18 function IsAlias(typeA
, typeB
) {
22 if (AreBothIn(typeA
, typeB
, WEBGL_TYPES
))
28 function TestContextRetrieval(creationType
, requestType
, functionalTypeSet
) {
29 var canvas
= document
.createElement('canvas');
30 var createdGL
= canvas
.getContext(creationType
);
32 var didCreationSucceed
= (createdGL
!= null);
33 if (creationType
in functionalTypeSet
) {
34 ok(createdGL
, 'Context creation should succeed for type \'' +
37 ok(!createdGL
, 'Context creation should fail for type \'' +
42 var requestedGL
= canvas
.getContext(requestType
);
44 if (requestType
in functionalTypeSet
&&
45 IsAlias(creationType
, requestType
))
47 ok(requestedGL
, 'Request for \'' + requestType
+ '\' from \'' +
48 creationType
+ '\' should succeed.');
49 ok(requestedGL
== createdGL
, 'Request for \'' + requestType
+
50 '\' from \'' + creationType
+
53 ok(!requestedGL
, 'Request for \'' + requestType
+ '\' from \'' +
54 creationType
+ '\' should fail.');
58 function IsWebGLFunctional() {
59 var canvas
= document
.createElement('canvas');
60 return canvas
.getContext('experimental-webgl') != null;
63 function IsWebGLConformant() {
64 var canvas
= document
.createElement('canvas');
65 return canvas
.getContext('webgl') != null;
68 var typeList
= ['2d', 'experimental-webgl', 'webgl'];
69 var functionalTypeSet
= {};
70 functionalTypeSet
['2d'] = true;
72 if (IsWebGLFunctional())
73 functionalTypeSet
['experimental-webgl'] = true;
75 if (IsWebGLConformant())
76 functionalTypeSet
.webgl
= true;
78 for (var i
in typeList
) {
79 var creationType
= typeList
[i
];
81 for (var j
in typeList
) {
82 var requestType
= typeList
[j
];
84 TestContextRetrieval(creationType
, requestType
, functionalTypeSet
);