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/. */
6 * Test that JS capturing works as expected.
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(
27 samples
.data
[sampleIndex
]
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)"
39 // "functionA (test_feature_js.js:47:0)"
41 // this matches the script location
42 // | match the line number
43 // | | match the column number
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."
53 function functionA() {
57 function functionB() {
61 async
function functionC() {
62 return ProfilerTestUtils
.captureAtLeastOneJsSample();