browser_canvas-actor-test-03.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Tests if functions inside a single animation frame are recorded and stored
  5. * for a canvas context.
  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 functionCalls = animationOverview.calls;
  21. ok(functionCalls,
  22. "An array of function call actors was sent after recording.");
  23. is(functionCalls.length, 8,
  24. "The number of function call actors is correct.");
  25. is(functionCalls[0].type, CallWatcherFront.METHOD_FUNCTION,
  26. "The first called function is correctly identified as a method.");
  27. is(functionCalls[0].name, "clearRect",
  28. "The first called function's name is correct.");
  29. is(functionCalls[0].file, SIMPLE_CANVAS_URL,
  30. "The first called function's file is correct.");
  31. is(functionCalls[0].line, 25,
  32. "The first called function's line is correct.");
  33. is(functionCalls[0].argsPreview, "0, 0, 128, 128",
  34. "The first called function's args preview is correct.");
  35. is(functionCalls[0].callerPreview, "Object",
  36. "The first called function's caller preview is correct.");
  37. is(functionCalls[6].type, CallWatcherFront.METHOD_FUNCTION,
  38. "The penultimate called function is correctly identified as a method.");
  39. is(functionCalls[6].name, "fillRect",
  40. "The penultimate called function's name is correct.");
  41. is(functionCalls[6].file, SIMPLE_CANVAS_URL,
  42. "The penultimate called function's file is correct.");
  43. is(functionCalls[6].line, 21,
  44. "The penultimate called function's line is correct.");
  45. is(functionCalls[6].argsPreview, "10, 10, 55, 50",
  46. "The penultimate called function's args preview is correct.");
  47. is(functionCalls[6].callerPreview, "Object",
  48. "The penultimate called function's caller preview is correct.");
  49. is(functionCalls[7].type, CallWatcherFront.METHOD_FUNCTION,
  50. "The last called function is correctly identified as a method.");
  51. is(functionCalls[7].name, "requestAnimationFrame",
  52. "The last called function's name is correct.");
  53. is(functionCalls[7].file, SIMPLE_CANVAS_URL,
  54. "The last called function's file is correct.");
  55. is(functionCalls[7].line, 30,
  56. "The last called function's line is correct.");
  57. ok(functionCalls[7].argsPreview.includes("Function"),
  58. "The last called function's args preview is correct.");
  59. is(functionCalls[7].callerPreview, "Object",
  60. "The last called function's caller preview is correct.");
  61. yield removeTab(target.tab);
  62. finish();
  63. }