browser_graphs-13.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. // Tests that graph widgets may have a fixed width or height.
  5. const LineGraphWidget = require("devtools/client/shared/widgets/LineGraphWidget");
  6. add_task(function* () {
  7. yield addTab("about:blank");
  8. yield performTest();
  9. gBrowser.removeCurrentTab();
  10. });
  11. function* performTest() {
  12. let [host,, doc] = yield createHost();
  13. doc.body.setAttribute("style",
  14. "position: fixed; width: 100%; height: 100%; margin: 0;");
  15. let graph = new LineGraphWidget(doc.body, "fps");
  16. graph.fixedWidth = 200;
  17. graph.fixedHeight = 100;
  18. yield graph.ready();
  19. testGraph(host, graph);
  20. yield graph.destroy();
  21. host.destroy();
  22. }
  23. function testGraph(host, graph) {
  24. let bounds = host.frame.getBoundingClientRect();
  25. isnot(graph.width, bounds.width * window.devicePixelRatio,
  26. "The graph should not span all the parent node's width.");
  27. isnot(graph.height, bounds.height * window.devicePixelRatio,
  28. "The graph should not span all the parent node's height.");
  29. is(graph.width, graph.fixedWidth * window.devicePixelRatio,
  30. "The graph has the correct width.");
  31. is(graph.height, graph.fixedHeight * window.devicePixelRatio,
  32. "The graph has the correct height.");
  33. }