browser_canvas-actor-test-05.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Tests if draw calls inside a single animation frame generate and retrieve
  5. * the correct "end result" screenshot.
  6. */
  7. function* ifTestingSupported() {
  8. let { target, front } = yield initCanvasDebuggerBackend(SIMPLE_CANVAS_URL);
  9. let navigated = once(target, "navigate");
  10. yield front.setup({ reload: true });
  11. ok(true, "The front was setup up successfully.");
  12. yield navigated;
  13. ok(true, "Target automatically navigated when the front was set up.");
  14. let snapshotActor = yield front.recordAnimationFrame();
  15. ok(snapshotActor,
  16. "A snapshot actor was sent after recording.");
  17. let animationOverview = yield snapshotActor.getOverview();
  18. ok(snapshotActor,
  19. "An animation overview could be retrieved after recording.");
  20. let screenshot = animationOverview.screenshot;
  21. ok(screenshot,
  22. "A screenshot was sent after recording.");
  23. is(screenshot.index, 6,
  24. "The screenshot's index is correct.");
  25. is(screenshot.width, 128,
  26. "The screenshot's width is correct.");
  27. is(screenshot.height, 128,
  28. "The screenshot's height is correct.");
  29. is(screenshot.flipped, false,
  30. "The screenshot's flipped flag is correct.");
  31. is([].find.call(Uint32(screenshot.pixels), e => e > 0), 4290822336,
  32. "The screenshot's pixels seem to not be completely transparent.");
  33. yield removeTab(target.tab);
  34. finish();
  35. }
  36. function Uint32(src) {
  37. let charView = new Uint8Array(src);
  38. return new Uint32Array(charView.buffer);
  39. }