|
1 <!DOCTYPE HTML> |
|
2 <title>WebGL test: Mismatched 'webgl' and 'experimental-webgl' context requests</title> |
|
3 <script src="/tests/SimpleTest/SimpleTest.js"></script> |
|
4 <link rel="stylesheet" href="/tests/SimpleTest/test.css"> |
|
5 <body> |
|
6 <canvas id="c1"></canvas> |
|
7 <canvas id="c2"></canvas> |
|
8 <canvas id="c3"></canvas> |
|
9 <canvas id="c4"></canvas> |
|
10 <script> |
|
11 |
|
12 function testContextRetrieval(canvasId, creationId, requestId) { |
|
13 var canvas = document.getElementById(canvasId); |
|
14 ok(canvas, 'Invalid `canvasId`: ' + canvasId); |
|
15 |
|
16 var createdGL = canvas.getContext(creationId); |
|
17 if (!createdGL) |
|
18 return; // No WebGL on this machine? |
|
19 |
|
20 var requestedGL = canvas.getContext(requestId); |
|
21 if (creationId == requestId) { |
|
22 ok(requestedGL, 'Request for \'' + requestId + '\' on from \'' + creationId + '\' should succeed.'); |
|
23 ok(requestedGL == createdGL, 'Request for \'' + requestId + '\' on from \'' + creationId + '\' should match.'); |
|
24 } else { |
|
25 ok(!requestedGL, 'Request for \'' + requestId + '\' on from \'' + creationId + '\' should fail.'); |
|
26 } |
|
27 } |
|
28 |
|
29 testContextRetrieval('c1', 'experimental-webgl', 'webgl'); |
|
30 testContextRetrieval('c2', 'webgl', 'experimental-webgl'); |
|
31 testContextRetrieval('c3', 'experimental-webgl', 'experimental-webgl'); |
|
32 testContextRetrieval('c4', 'webgl', 'webgl'); |
|
33 |
|
34 </script> |
|
35 |