summaryrefslogtreecommitdiff
path: root/browser/devtools/debugger/test/browser_dbg_tracing-08.js
blob: eb20ffa9fccda63e8a0866a3da3fedaa025eef09 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Test that tracing about:config doesn't produce errors.
 */

const TAB_URL = "about:config";

let gPanel, gDoneChecks;

function test() {
  gDoneChecks = promise.defer();
  const tracerPref = promise.defer();
  const configPref = promise.defer();
  SpecialPowers.pushPrefEnv({'set': [["devtools.debugger.tracer", true]]}, tracerPref.resolve);
  SpecialPowers.pushPrefEnv({'set': [["general.warnOnAboutConfig", false]]}, configPref.resolve);
  promise.all([tracerPref.promise, configPref.promise]).then(() => {
    initDebugger(TAB_URL).then(([,, aPanel]) => {
      gPanel = aPanel;
      gPanel.panelWin.gClient.addOneTimeListener("traces", testTraceLogs);
    }).then(() => startTracing(gPanel))
      .then(generateTrace)
      .then(() => waitForClientEvents(gPanel, "traces"))
      .then(() => gDoneChecks.promise)
      .then(() => stopTracing(gPanel))
      .then(resetPreferences)
      .then(() => closeDebuggerAndFinish(gPanel))
      .then(null, aError => {
        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
      });
  });
}

function testTraceLogs(name, packet) {
  info("Traces: " + packet.traces.length);
  ok(packet.traces.length > 0, "Got some traces.");
  ok(packet.traces.every(t => t.type != "enteredFrame" || !!t.location),
     "All enteredFrame traces contain location.");
  gDoneChecks.resolve();
}

function generateTrace(name, packet) {
  // Interact with the page to cause JS execution.
  let search = content.document.getElementById("textbox");
  info("Interacting with the page.");
  search.value = "devtools";
}

function resetPreferences() {
  const deferred = promise.defer();
  SpecialPowers.popPrefEnv(() => SpecialPowers.popPrefEnv(deferred.resolve));
  return deferred.promise;
}

registerCleanupFunction(function() {
  gPanel = null;
  gDoneChecks = null;
});