content/canvas/test/webgl-mochitest/test_webgl_request_mismatch.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/canvas/test/webgl-mochitest/test_webgl_request_mismatch.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<title>WebGL test: Mismatched 'webgl' and 'experimental-webgl' context requests</title>
     1.6 +<script src="/tests/SimpleTest/SimpleTest.js"></script>
     1.7 +<link rel="stylesheet" href="/tests/SimpleTest/test.css">
     1.8 +<body>
     1.9 +<canvas id="c1"></canvas>
    1.10 +<canvas id="c2"></canvas>
    1.11 +<canvas id="c3"></canvas>
    1.12 +<canvas id="c4"></canvas>
    1.13 +<script>
    1.14 +
    1.15 +function testContextRetrieval(canvasId, creationId, requestId) {
    1.16 +  var canvas = document.getElementById(canvasId);
    1.17 +  ok(canvas, 'Invalid `canvasId`: ' + canvasId);
    1.18 +
    1.19 +  var createdGL = canvas.getContext(creationId);
    1.20 +  if (!createdGL)
    1.21 +    return; // No WebGL on this machine?
    1.22 +
    1.23 +  var requestedGL = canvas.getContext(requestId);
    1.24 +  if (creationId == requestId) {
    1.25 +    ok(requestedGL, 'Request for \'' + requestId + '\' on from \'' + creationId + '\' should succeed.');
    1.26 +    ok(requestedGL == createdGL, 'Request for \'' + requestId + '\' on from \'' + creationId + '\' should match.');
    1.27 +  } else {
    1.28 +    ok(!requestedGL, 'Request for \'' + requestId + '\' on from \'' + creationId + '\' should fail.');
    1.29 +  }
    1.30 +}
    1.31 +
    1.32 +testContextRetrieval('c1', 'experimental-webgl', 'webgl');
    1.33 +testContextRetrieval('c2', 'webgl', 'experimental-webgl');
    1.34 +testContextRetrieval('c3', 'experimental-webgl', 'experimental-webgl');
    1.35 +testContextRetrieval('c4', 'webgl', 'webgl');
    1.36 +
    1.37 +</script>
    1.38 +

mercurial