devtools/client/performance-new/test/chrome/test_perf-state-02.html
author Mark Banner <standard8@mozilla.com>
Fri, 19 Oct 2018 12:55:39 +0000
changeset 490493 edc4ae8f78e2fb02647d7cd85cb19830a17dcd1d
parent 466441 07e342719f5eeae8d846f8b530bc28209b6e7938
permissions -rw-r--r--
Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop Differential Revision: https://phabricator.services.mozilla.com/D8389

<!DOCTYPE HTML>
<html>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<head>
  <meta charset="utf-8">
  <title>Perf component test</title>
  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
  <div id="container"></div>

  <pre id="test">
    <script src="head.js" type="application/javascript"></script>
    <script type="application/javascript">
      "use strict";

      /**
       * Test the perf component when the profiler is already started.
       */
      addPerfTest(async () => {
        const {
          perfFrontMock,
          getRecordingState,
          mountComponent,
          container,
        } = createPerfComponent();

        ok(true, "Start the profiler before initiliazing the component, to simulate" +
                 "the profiler being controlled by another tool.");

        perfFrontMock.startProfiler();
        await perfFrontMock._flushAsyncQueue();

        mountComponent();

        is(getRecordingState(), "not-yet-known",
          "The component at first is in an unknown state.");

        await perfFrontMock._flushAsyncQueue();
        is(getRecordingState(), "other-is-recording",
          "The profiler is not available to record.");

        const button = container.querySelector("button");
        ok(button, "Selected a button on the component");
        button.click();
        is(getRecordingState(), "request-to-stop-profiler",
          "We can request to stop the profiler.");

        await perfFrontMock._flushAsyncQueue();
        is(getRecordingState(), "available-to-record",
          "The profiler is now available to record.");
      });
    </script>
  </pre>
</body>
</html>