browser_canvas-actor-test-10.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Tests that the correct framebuffer, renderbuffer and textures are re-bound
  5. * after generating screenshots using the actor.
  6. */
  7. function* ifTestingSupported() {
  8. let { target, front } = yield initCanvasDebuggerBackend(WEBGL_BINDINGS_URL);
  9. loadFrameScripts();
  10. let navigated = once(target, "navigate");
  11. yield front.setup({ reload: true });
  12. ok(true, "The front was setup up successfully.");
  13. yield navigated;
  14. ok(true, "Target automatically navigated when the front was set up.");
  15. let snapshotActor = yield front.recordAnimationFrame();
  16. let animationOverview = yield snapshotActor.getOverview();
  17. let functionCalls = animationOverview.calls;
  18. let firstScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[0]);
  19. is(firstScreenshot.index, -1,
  20. "The first screenshot didn't encounter any draw call.");
  21. is(firstScreenshot.scaling, 0.25,
  22. "The first screenshot has the correct scaling.");
  23. is(firstScreenshot.width, CanvasFront.WEBGL_SCREENSHOT_MAX_HEIGHT,
  24. "The first screenshot has the correct width.");
  25. is(firstScreenshot.height, CanvasFront.WEBGL_SCREENSHOT_MAX_HEIGHT,
  26. "The first screenshot has the correct height.");
  27. is(firstScreenshot.flipped, true,
  28. "The first screenshot has the correct 'flipped' flag.");
  29. is(firstScreenshot.pixels.length, 0,
  30. "The first screenshot should be empty.");
  31. is((yield evalInDebuggee("gl.getParameter(gl.FRAMEBUFFER_BINDING) === customFramebuffer")),
  32. true,
  33. "The debuggee's gl context framebuffer wasn't changed.");
  34. is((yield evalInDebuggee("gl.getParameter(gl.RENDERBUFFER_BINDING) === customRenderbuffer")),
  35. true,
  36. "The debuggee's gl context renderbuffer wasn't changed.");
  37. is((yield evalInDebuggee("gl.getParameter(gl.TEXTURE_BINDING_2D) === customTexture")),
  38. true,
  39. "The debuggee's gl context texture binding wasn't changed.");
  40. is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[0]")),
  41. 128,
  42. "The debuggee's gl context viewport's left coord. wasn't changed.");
  43. is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[1]")),
  44. 256,
  45. "The debuggee's gl context viewport's left coord. wasn't changed.");
  46. is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[2]")),
  47. 384,
  48. "The debuggee's gl context viewport's left coord. wasn't changed.");
  49. is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[3]")),
  50. 512,
  51. "The debuggee's gl context viewport's left coord. wasn't changed.");
  52. let secondScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[1]);
  53. is(secondScreenshot.index, 1,
  54. "The second screenshot has the correct index.");
  55. is(secondScreenshot.width, CanvasFront.WEBGL_SCREENSHOT_MAX_HEIGHT,
  56. "The second screenshot has the correct width.");
  57. is(secondScreenshot.height, CanvasFront.WEBGL_SCREENSHOT_MAX_HEIGHT,
  58. "The second screenshot has the correct height.");
  59. is(secondScreenshot.scaling, 0.25,
  60. "The second screenshot has the correct scaling.");
  61. is(secondScreenshot.flipped, true,
  62. "The second screenshot has the correct 'flipped' flag.");
  63. is(secondScreenshot.pixels.length, Math.pow(CanvasFront.WEBGL_SCREENSHOT_MAX_HEIGHT, 2) * 4,
  64. "The second screenshot should not be empty.");
  65. is(secondScreenshot.pixels[0], 0,
  66. "The second screenshot has the correct red component.");
  67. is(secondScreenshot.pixels[1], 0,
  68. "The second screenshot has the correct green component.");
  69. is(secondScreenshot.pixels[2], 255,
  70. "The second screenshot has the correct blue component.");
  71. is(secondScreenshot.pixels[3], 255,
  72. "The second screenshot has the correct alpha component.");
  73. is((yield evalInDebuggee("gl.getParameter(gl.FRAMEBUFFER_BINDING) === customFramebuffer")),
  74. true,
  75. "The debuggee's gl context framebuffer still wasn't changed.");
  76. is((yield evalInDebuggee("gl.getParameter(gl.RENDERBUFFER_BINDING) === customRenderbuffer")),
  77. true,
  78. "The debuggee's gl context renderbuffer still wasn't changed.");
  79. is((yield evalInDebuggee("gl.getParameter(gl.TEXTURE_BINDING_2D) === customTexture")),
  80. true,
  81. "The debuggee's gl context texture binding still wasn't changed.");
  82. is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[0]")),
  83. 128,
  84. "The debuggee's gl context viewport's left coord. still wasn't changed.");
  85. is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[1]")),
  86. 256,
  87. "The debuggee's gl context viewport's left coord. still wasn't changed.");
  88. is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[2]")),
  89. 384,
  90. "The debuggee's gl context viewport's left coord. still wasn't changed.");
  91. is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[3]")),
  92. 512,
  93. "The debuggee's gl context viewport's left coord. still wasn't changed.");
  94. yield removeTab(target.tab);
  95. finish();
  96. }