Backed out 2 changesets (bug 1943998) for causing wd failures @ phases.py CLOSED...
[gecko.git] / tools / profiler / tests / xpcshell / test_feature_js.js
blobd65d663b5691530505c6bd32a713e190bd7a8d41
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /**
6 * Test that JS capturing works as expected.
7 */
8 add_task(async () => {
9 const entries = 10000;
10 const interval = 1;
11 const threads = [];
12 const features = ["js"];
14 await Services.profiler.StartProfiler(entries, interval, features, threads);
16 // Call the following to get a nice stack in the profiler:
17 // functionA -> functionB -> functionC -> captureAtLeastOneJsSample
18 const sampleIndex = await functionA();
20 const profile = await ProfilerTestUtils.stopNowAndGetProfile();
22 const [thread] = profile.threads;
23 const { samples } = thread;
25 const inflatedStackFrames = getInflatedStackLocations(
26 thread,
27 samples.data[sampleIndex]
30 expectStackToContain(
31 inflatedStackFrames,
33 "(root)",
34 "js::RunScript",
35 // The following regexes match a string similar to:
37 // "functionA (/gecko/obj/_tests/xpcshell/tools/profiler/tests/xpcshell/test_feature_js.js:47:0)"
38 // or
39 // "functionA (test_feature_js.js:47:0)"
41 // this matches the script location
42 // | match the line number
43 // | | match the column number
44 // v v v
45 /^functionA \(.*test_feature_js\.js:\d+:\d+\)$/,
46 /^functionB \(.*test_feature_js\.js:\d+:\d+\)$/,
47 /^functionC \(.*test_feature_js\.js:\d+:\d+\)$/,
49 "The stack contains a few frame labels, as well as the JS functions that we called."
51 });
53 function functionA() {
54 return functionB();
57 function functionB() {
58 return functionC();
61 async function functionC() {
62 return ProfilerTestUtils.captureAtLeastOneJsSample();