browser_canvas-frontend-call-list.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Tests if all the function calls associated with an animation frame snapshot
  5. * are properly displayed in the UI.
  6. */
  7. function* ifTestingSupported() {
  8. let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
  9. let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
  10. yield reload(target);
  11. let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
  12. let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
  13. SnapshotsListView._onRecordButtonClick();
  14. yield promise.all([recordingFinished, callListPopulated]);
  15. is(CallsListView.itemCount, 8,
  16. "All the function calls should now be displayed in the UI.");
  17. testItem(CallsListView.getItemAtIndex(0),
  18. "1", "Object", "clearRect", "(0, 0, 128, 128)", "doc_simple-canvas.html:25");
  19. testItem(CallsListView.getItemAtIndex(1),
  20. "2", "Object", "fillStyle", " = rgb(192, 192, 192)", "doc_simple-canvas.html:20");
  21. testItem(CallsListView.getItemAtIndex(2),
  22. "3", "Object", "fillRect", "(0, 0, 128, 128)", "doc_simple-canvas.html:21");
  23. testItem(CallsListView.getItemAtIndex(3),
  24. "4", "Object", "fillStyle", " = rgba(0, 0, 192, 0.5)", "doc_simple-canvas.html:20");
  25. testItem(CallsListView.getItemAtIndex(4),
  26. "5", "Object", "fillRect", "(30, 30, 55, 50)", "doc_simple-canvas.html:21");
  27. testItem(CallsListView.getItemAtIndex(5),
  28. "6", "Object", "fillStyle", " = rgba(192, 0, 0, 0.5)", "doc_simple-canvas.html:20");
  29. testItem(CallsListView.getItemAtIndex(6),
  30. "7", "Object", "fillRect", "(10, 10, 55, 50)", "doc_simple-canvas.html:21");
  31. testItem(CallsListView.getItemAtIndex(7),
  32. "8", "", "requestAnimationFrame", "(Function)", "doc_simple-canvas.html:30");
  33. function testItem(item, index, context, name, args, location) {
  34. let i = CallsListView.indexOfItem(item);
  35. is(i, index - 1,
  36. "The item at index " + index + " is correctly displayed in the UI.");
  37. is($(".call-item-index", item.target).getAttribute("value"), index,
  38. "The item's gutter label has the correct text.");
  39. if (context) {
  40. is($(".call-item-context", item.target).getAttribute("value"), context,
  41. "The item's context label has the correct text.");
  42. } else {
  43. is($(".call-item-context", item.target) + "", "[object XULElement]",
  44. "The item's context label should not be available.");
  45. }
  46. is($(".call-item-name", item.target).getAttribute("value"), name,
  47. "The item's name label has the correct text.");
  48. is($(".call-item-args", item.target).getAttribute("value"), args,
  49. "The item's args label has the correct text.");
  50. is($(".call-item-location", item.target).getAttribute("value"), location,
  51. "The item's location label has the correct text.");
  52. }
  53. yield teardown(panel);
  54. finish();
  55. }