summaryrefslogtreecommitdiffstats
path: root/toolkit/components/backgroundhangmonitor/tests/child_cause_hang.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/backgroundhangmonitor/tests/child_cause_hang.js')
-rw-r--r--toolkit/components/backgroundhangmonitor/tests/child_cause_hang.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/toolkit/components/backgroundhangmonitor/tests/child_cause_hang.js b/toolkit/components/backgroundhangmonitor/tests/child_cause_hang.js
new file mode 100644
index 0000000000..adf96170b6
--- /dev/null
+++ b/toolkit/components/backgroundhangmonitor/tests/child_cause_hang.js
@@ -0,0 +1,23 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+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.
+ let features = ["stackwalk"];
+ Services.profiler.StartProfiler(1000, 10, features);
+ Services.profiler.StopProfiler();
+}
+
+add_task(async function childCauseHang() {
+ ensureProfilerInitialized();
+
+ executeSoon(() => {
+ let startTime = Date.now();
+ // eslint-disable-next-line no-empty
+ while (Date.now() - startTime < 2000) {}
+ });
+
+ await do_await_remote_message("bhr_hangs_detected");
+});