diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/canvas/test/webgl-mochitest/test_webgl_request_mismatch.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/canvas/test/webgl-mochitest/test_webgl_request_mismatch.html')
-rw-r--r-- | dom/canvas/test/webgl-mochitest/test_webgl_request_mismatch.html | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-mochitest/test_webgl_request_mismatch.html b/dom/canvas/test/webgl-mochitest/test_webgl_request_mismatch.html new file mode 100644 index 000000000..8b8920603 --- /dev/null +++ b/dom/canvas/test/webgl-mochitest/test_webgl_request_mismatch.html @@ -0,0 +1,90 @@ +<!DOCTYPE HTML> +<html> +<head> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> +</head> +<body> +<script> + +WEBGL_TYPES = {}; +WEBGL_TYPES['experimental-webgl'] = true; +WEBGL_TYPES['webgl'] = true; + +function AreBothIn(a, b, set) { + return (a in set) && (b in set); +} + +function IsAlias(typeA, typeB) { + if (typeA == typeB) + return true; + + if (AreBothIn(typeA, typeB, WEBGL_TYPES)) + return true; + + return false; +} + +function TestContextRetrieval(creationType, requestType, functionalTypeSet) { + var canvas = document.createElement('canvas'); + var createdGL = canvas.getContext(creationType); + + var didCreationSucceed = (createdGL != null); + if (creationType in functionalTypeSet) { + ok(createdGL, 'Context creation should succeed for type \'' + + creationType + '\''); + } else { + ok(!createdGL, 'Context creation should fail for type \'' + + creationType + '\''); + return; + } + + var requestedGL = canvas.getContext(requestType); + + if (requestType in functionalTypeSet && + IsAlias(creationType, requestType)) + { + ok(requestedGL, 'Request for \'' + requestType + '\' from \'' + + creationType + '\' should succeed.'); + ok(requestedGL == createdGL, 'Request for \'' + requestType + + '\' from \'' + creationType + + '\' should match.'); + } else { + ok(!requestedGL, 'Request for \'' + requestType + '\' from \'' + + creationType + '\' should fail.'); + } +} + +function IsWebGLFunctional() { + var canvas = document.createElement('canvas'); + return canvas.getContext('experimental-webgl') != null; +} + +function IsWebGLConformant() { + var canvas = document.createElement('canvas'); + return canvas.getContext('webgl') != null; +} + +var typeList = ['2d', 'experimental-webgl', 'webgl']; +var functionalTypeSet = {}; +functionalTypeSet['2d'] = true; + +if (IsWebGLFunctional()) + functionalTypeSet['experimental-webgl'] = true; + +if (IsWebGLConformant()) + functionalTypeSet['webgl'] = true; + +for (var i in typeList) { + var creationType = typeList[i]; + + for (var j in typeList) { + var requestType = typeList[j]; + + TestContextRetrieval(creationType, requestType, functionalTypeSet); + } +} + +</script> +</body> +</html> |