fune/toolkit/components/backgroundhangmonitor/tests/child_cause_hang.js
Victor Porof 815b9d372b Bug 1561435 - Fix linting errors for toolkit/, r=standard8
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D35955

--HG--
extra : source : e6571d8ed75be94bdcdef8fbd0d977bfa92f3a34
extra : intermediate-source : 1351521a4bb3f78be45cf6bf6df90b4c75a959c4
2019-06-25 23:43:58 +02:00

31 lines
957 B
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
function ensureProfilerInitialized() {
// Starting and stopping the profiler with the "stackwalk" flag will cause the
// profiler's stackwalking features to be synchronously initialized. This
// should prevent us from not initializing BHR quickly enough.
if (!Services.profiler.CanProfile()) {
return false;
}
let features = ["stackwalk"];
Services.profiler.StartProfiler(1000, 10, features);
Services.profiler.StopProfiler();
return true;
}
add_task(async function childCauseHang() {
if (!ensureProfilerInitialized()) {
return;
}
executeSoon(() => {
let startTime = Date.now();
// eslint-disable-next-line no-empty
while (Date.now() - startTime < 2000) {}
});
await do_await_remote_message("bhr_hangs_detected");
});