Bug 1729472 - [devtools performance] Adapt the multi-panel interaction tests so that they work in environments where some features are missing r=jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D125049
This commit is contained in:
Julien Wajsberg 2021-09-14 17:22:32 +00:00
Родитель e8ab10943e
Коммит 3590bbfc67
1 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -582,6 +582,29 @@ async function devToolsActiveConfigurationHasFeature(document, feature) {
} }
/* exported devToolsActiveConfigurationHasFeature */ /* exported devToolsActiveConfigurationHasFeature */
/**
* This adapts the expectation using the current build's available profiler
* features.
* @param {string} fixture It can be either already trimmed or untrimmed.
* @returns {string}
*/
function _adaptCustomPresetExpectationToCustomBuild(fixture) {
const supportedFeatures = Services.profiler.GetFeatures();
info("Supported features are: " + supportedFeatures.join(", "));
// Some platforms do not support stack walking, we can adjust the passed
// fixture so that tests are passing in these platforms too.
// Most notably MacOS outside of Nightly and DevEdition.
if (!supportedFeatures.includes("stackwalk")) {
info(
"Supported features do not include stackwalk, let's remove the Native Stacks from the expected output."
);
fixture = fixture.replace(/^.*Native Stacks.*\n/m, "");
}
return fixture;
}
/** /**
* This checks if the content of the preset description equals the fixture in * This checks if the content of the preset description equals the fixture in
* string form. * string form.
@ -591,6 +614,8 @@ async function devToolsActiveConfigurationHasFeature(document, feature) {
function checkDevtoolsCustomPresetContent(devtoolsDocument, fixture) { function checkDevtoolsCustomPresetContent(devtoolsDocument, fixture) {
// This removes all indentations and any start or end new line and other space characters. // This removes all indentations and any start or end new line and other space characters.
fixture = fixture.replace(/^\s+/gm, "").trim(); fixture = fixture.replace(/^\s+/gm, "").trim();
// This removes unavailable features from the fixture content.
fixture = _adaptCustomPresetExpectationToCustomBuild(fixture);
is(devtoolsDocument.querySelector(".perf-presets-custom").innerText, fixture); is(devtoolsDocument.querySelector(".perf-presets-custom").innerText, fixture);
} }
/* exported checkDevtoolsCustomPresetContent */ /* exported checkDevtoolsCustomPresetContent */