Hi all,
We’ve recently landed a couple of changes that make it easier to write
Firefox tests that use the gecko profiler. The gecko profiler can be a
really useful tool for testing that Firefox is doing what you expect,
for example by validating that markers are generated by your code, or
giving you a way to examine whether something did or did not happen by
looking at a captured profile during a test.
To make using the gecko profiler easier to use when testing outside the
`tools/profiler` directory, we’ve landed a couple of changes:
Firstly, we’ve moved a lot of useful functions for working with the
profiler into a new `ProfilerTestUtils.sys.mjs` module [1]. This
includes useful wrapper functions for conveniently starting and stopping
the profiler, and functions for extracting specific information such as
markers, threads or schemas from profiles. To use the new module, simply
add the following import to your JS test:
```
const { ProfilerTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/ProfilerTestUtils.sys.mjs"
);
```
An example of this being used in the wild can be found in
`security/sandbox/test/browser_sandbox_profiler.js` [2].
Secondly, we’ve added support for the gecko profiler to `mozinfo.py`,
allowing users to enable/disable tests contingent on whether Firefox has
been compiled with support for the profiler. The gecko profiler is
supported on all tier 1 and 2 platforms, however some tier 3 platforms
(such as BSD) are unsupported. In order to ensure that tests that use
the profiler extensively don’t fail on these platforms, we recommend
using a variation of the following to conditionally disable tests:
```
["test_ProfilerMarkers.js"]
skip-if = ["!gecko_profiler"] # Skip this test if we build without the
profiler
```
For an example, see `security/sandbox/test/browser_profiler.toml` [3],
where we use this to conditionally disable
`browser_sandbox_profiler.js`, mentioned above.
Please feel free to reach out to us on the #profiler channel on matrix
with any questions or requests,
Yours
Adam Brouwers-Harries
[1]
https://searchfox.org/mozilla-central/rev/937d8e66a5bfe2fc8eb9aa0080629ce7f8dd6cc6/tools/profiler/tests/ProfilerTestUtils.sys.mjs
[2]
https://searchfox.org/mozilla-central/rev/937d8e66a5bfe2fc8eb9aa0080629ce7f8dd6cc6/security/sandbox/test/browser_sandbox_profiler.js#6
[3]
https://searchfox.org/mozilla-central/rev/937d8e66a5bfe2fc8eb9aa0080629ce7f8dd6cc6/security/sandbox/test/browser_profiler.toml#4
--
You received this message because you are subscribed to the Google Groups
"[email protected]" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/9aaa72b5-c7e8-4425-b6bd-4e1b12fbaf69%40mozilla.com.