index.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>BabylonJS - Build validation page</title>
  5. <link href="index.css" rel="stylesheet" />
  6. <script src="https://preview.babylonjs.com/draco_decoder_gltf.js"></script>
  7. <script src="https://unpkg.com/earcut@2.1.1/dist/earcut.min.js"></script>
  8. <script src="../../Tools/DevLoader/BabylonLoader.js"></script>
  9. </head>
  10. <body>
  11. <button id="buttonToggleResult" class="buttonToggleResult">Show only failed tests</button>
  12. <script>
  13. let toggle = 0, ebutton = document.getElementById("buttonToggleResult");
  14. ebutton.onclick = function(event) {
  15. Array.from(document.getElementsByClassName("container")).forEach((elem) => {
  16. const result = elem.getAttribute("result");
  17. elem.style.display = toggle === 0 && result !== "false" ? "none" : "";
  18. });
  19. toggle ^= 1;
  20. if (toggle) {
  21. ebutton.innerHTML = "Show all tests";
  22. } else {
  23. ebutton.innerHTML = "Show only failed tests";
  24. }
  25. };
  26. function QueryString() {
  27. const idx = window.location.search.indexOf('?');
  28. if (idx < 0) {
  29. return {};
  30. }
  31. const queryString = {},
  32. query = window.location.search.substring(idx + 1),
  33. vars = query.split("&");
  34. for (let i = 0; i < vars.length; i++) {
  35. const pair = vars[i].split("=");
  36. const name = decodeURIComponent(pair[0]);
  37. const val = pair.length > 1 ? decodeURIComponent(pair[1]) : null;
  38. if (val === null) {
  39. queryString["test"] = name;
  40. } else if (queryString[name] === undefined) {
  41. queryString[name] = val;
  42. } else if (typeof queryString[name] === "string") {
  43. queryString[name] = [ queryString[name], val ];
  44. } else {
  45. queryString[name].push(val);
  46. }
  47. }
  48. return queryString;
  49. }
  50. BABYLONDEVTOOLS.Loader.require('validation.js')
  51. .load(function() {
  52. // Loading tests
  53. var xhr = new XMLHttpRequest();
  54. var qs = QueryString();
  55. xhr.open("GET", qs.list ? qs.list + ".json" : "config.json", true);
  56. xhr.addEventListener("load", async function() {
  57. if (xhr.status === 200) {
  58. config = JSON.parse(xhr.responseText);
  59. // Run tests
  60. var index = 0;
  61. if (qs.test) {
  62. justOnce = true;
  63. for (var index = 0; index < config.tests.length; index++) {
  64. if (config.tests[index].title === qs.test) {
  65. break;
  66. }
  67. }
  68. }
  69. if (qs.fromtest) {
  70. for (var index = 0; index < config.tests.length; index++) {
  71. if (config.tests[index].title === qs.fromtest) {
  72. break;
  73. }
  74. }
  75. }
  76. await init(qs.engine || "webgl2");
  77. var recursiveRunTest = function(i) {
  78. runTest(i, function() {
  79. i++;
  80. if (justOnce || i >= config.tests.length) {
  81. showResultSummary();
  82. return;
  83. }
  84. recursiveRunTest(i);
  85. }, qs.list !== "config" && qs.list || "");
  86. }
  87. recursiveRunTest(index);
  88. }
  89. }, false);
  90. xhr.send();
  91. });
  92. </script>
  93. </body>
  94. </html>