summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/browser/browser_timeline_iframes.js
blob: d4163c611d36e6bdf89d7ff18161d8709115a1b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test the timeline front receives markers events for operations that occur in
// iframes.

const {TimelineFront} = require("devtools/shared/fronts/timeline");

add_task(function* () {
  let browser = yield addTab(MAIN_DOMAIN + "timeline-iframe-parent.html");
  let doc = browser.contentDocument;

  initDebuggerServer();
  let client = new DebuggerClient(DebuggerServer.connectPipe());
  let form = yield connectDebuggerClient(client);
  let front = TimelineFront(client, form);

  info("Start timeline marker recording");
  yield front.start({ withMarkers: true });

  // Check that we get markers for a few iterations of the timer that runs in
  // the child frame.
  for (let i = 0; i < 3; i++) {
    yield wait(300); // That's the time the child frame waits before changing styles.
    let markers = yield once(front, "markers");
    ok(markers.length, "Markers were received for operations in the child frame");
  }

  info("Stop timeline marker recording");
  yield front.stop();
  yield client.close();
  gBrowser.removeCurrentTab();
});

function wait(ms) {
  return new Promise(resolve =>
    setTimeout(resolve, ms));
}