зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1597381 - Add tests for the about:profiling presets; r=julienw
Differential Revision: https://phabricator.services.mozilla.com/D58467 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
258b0879c5
Коммит
3851bf14af
|
@ -357,6 +357,26 @@ function revertRecordingPreferences() {
|
|||
Services.prefs.clearUserPref(DURATION_PREF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the prefs based on a preset. This mechanism is used by the popup to
|
||||
* easily switch between different settings.
|
||||
* @param {string} presetName
|
||||
*/
|
||||
function changePreset(presetName) {
|
||||
const objdirs = _getArrayOfStringsHostPref(OBJDIRS_PREF);
|
||||
let recordingPrefs = getRecordingPrefsFromPreset(presetName, objdirs);
|
||||
|
||||
if (!recordingPrefs) {
|
||||
// No recordingPrefs were found for that preset. Most likely this means this
|
||||
// is a custom preset, or it's one that we dont recognize for some reason.
|
||||
// Get the preferences from the individual preference values.
|
||||
Services.prefs.setCharPref(PRESET_PREF, presetName);
|
||||
recordingPrefs = getRecordingPreferencesFromBrowser();
|
||||
}
|
||||
|
||||
setRecordingPreferencesOnBrowser(recordingPrefs);
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple cache for the default recording preferences.
|
||||
* @type {RecordingStateFromPreferences}
|
||||
|
@ -408,6 +428,7 @@ module.exports = {
|
|||
getRecordingPreferencesFromBrowser,
|
||||
setRecordingPreferencesOnBrowser,
|
||||
revertRecordingPreferences,
|
||||
changePreset,
|
||||
getDefaultRecordingPreferencesForOlderFirefox,
|
||||
};
|
||||
|
||||
|
|
|
@ -11,6 +11,10 @@ support-files =
|
|||
skip-if = !nightly_build || os == 'android'
|
||||
[browser_aboutprofiling-threads.js]
|
||||
skip-if = !nightly_build || os == 'android'
|
||||
[browser_aboutprofiling-presets.js]
|
||||
skip-if = !nightly_build || os == 'android'
|
||||
[browser_aboutprofiling-presets-custom.js]
|
||||
skip-if = !nightly_build || os == 'android'
|
||||
|
||||
[browser_popup-end-to-end-click.js]
|
||||
[browser_popup-env-restart-button.js]
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test() {
|
||||
info(
|
||||
"Test that about:profiling presets override the individual settings when changed."
|
||||
);
|
||||
|
||||
if (!Services.profiler.GetFeatures().includes("stackwalk")) {
|
||||
ok(true, "This platform does not support stackwalking, skip this test.");
|
||||
return;
|
||||
}
|
||||
|
||||
await openAboutProfiling(async document => {
|
||||
const webdevPreset = await getNearestInputFromText(
|
||||
document,
|
||||
"Web Developer"
|
||||
);
|
||||
const customPreset = await getNearestInputFromText(document, "Custom");
|
||||
const stackwalkFeature = await getNearestInputFromText(
|
||||
document,
|
||||
"Native Stacks"
|
||||
);
|
||||
const geckoMainThread = await getNearestInputFromText(
|
||||
document,
|
||||
"GeckoMain"
|
||||
);
|
||||
|
||||
{
|
||||
info("Check the defaults on the about:profiling page.");
|
||||
ok(
|
||||
webdevPreset.checked,
|
||||
"By default the Web Developer preset is checked."
|
||||
);
|
||||
ok(!customPreset.checked, "By default the custom preset is not checked.");
|
||||
ok(
|
||||
!stackwalkFeature.checked,
|
||||
"Stack walking is not enabled for Web Developer."
|
||||
);
|
||||
ok(
|
||||
!activeConfigurationHasFeature("stackwalk"),
|
||||
"Stack walking is not in the active configuration."
|
||||
);
|
||||
ok(
|
||||
geckoMainThread.checked,
|
||||
"The GeckoMain thread is tracked for the Web Developer preset"
|
||||
);
|
||||
ok(
|
||||
activeConfigurationHasThread("GeckoMain"),
|
||||
"The GeckoMain thread is in the active configuration."
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
info("Change some settings, which will move the preset over to Custom.");
|
||||
|
||||
info("Click stack walking.");
|
||||
stackwalkFeature.click();
|
||||
|
||||
info("Click the GeckoMain thread.");
|
||||
geckoMainThread.click();
|
||||
}
|
||||
|
||||
{
|
||||
info("Check that the various settings were actually updated in the UI.");
|
||||
ok(
|
||||
!webdevPreset.checked,
|
||||
"The Web Developer preset is no longer enabled."
|
||||
);
|
||||
ok(customPreset.checked, "The Custom preset is now checked.");
|
||||
ok(stackwalkFeature.checked, "Stack walking was enabled");
|
||||
ok(
|
||||
activeConfigurationHasFeature("stackwalk"),
|
||||
"Stack walking is in the active configuration."
|
||||
);
|
||||
ok(
|
||||
!geckoMainThread.checked,
|
||||
"GeckoMain was removed from tracked threads."
|
||||
);
|
||||
ok(
|
||||
!activeConfigurationHasThread("GeckoMain"),
|
||||
"The GeckoMain thread is not in the active configuration."
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
info(
|
||||
"Click the Web Developer preset, which should revert the other settings."
|
||||
);
|
||||
webdevPreset.click();
|
||||
}
|
||||
|
||||
{
|
||||
info(
|
||||
"Now verify that everything was reverted back to the original settings."
|
||||
);
|
||||
ok(webdevPreset.checked, "The Web Developer preset is checked again.");
|
||||
ok(!customPreset.checked, "The custom preset is not checked.");
|
||||
ok(
|
||||
!stackwalkFeature.checked,
|
||||
"Stack walking is reverted for the Web Developer preset."
|
||||
);
|
||||
ok(
|
||||
!activeConfigurationHasFeature("stackwalk"),
|
||||
"Stack walking is not in the active configuration."
|
||||
);
|
||||
ok(
|
||||
geckoMainThread.checked,
|
||||
"GeckoMain was added back to the tracked threads."
|
||||
);
|
||||
ok(
|
||||
activeConfigurationHasThread("GeckoMain"),
|
||||
"The GeckoMain thread is in the active configuration."
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const { revertRecordingPreferences } = ChromeUtils.import(
|
||||
"resource://devtools/client/performance-new/popup/background.jsm.js"
|
||||
);
|
||||
|
||||
revertRecordingPreferences();
|
||||
});
|
|
@ -0,0 +1,59 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test() {
|
||||
info("Test that about:profiling presets configure the profiler");
|
||||
|
||||
if (!Services.profiler.GetFeatures().includes("stackwalk")) {
|
||||
ok(true, "This platform does not support stackwalking, skip this test.");
|
||||
return;
|
||||
}
|
||||
|
||||
await openAboutProfiling(async document => {
|
||||
const webdev = await getNearestInputFromText(document, "Web Developer");
|
||||
ok(webdev.checked, "By default the Web Developer preset is selected.");
|
||||
|
||||
ok(
|
||||
!activeConfigurationHasFeature("stackwalk"),
|
||||
"Stackwalking is not enabled for the Web Developer workflow"
|
||||
);
|
||||
|
||||
const platform = await getNearestInputFromText(
|
||||
document,
|
||||
"Firefox Platform"
|
||||
);
|
||||
|
||||
ok(!platform.checked, "The Firefox Platform preset is not checked.");
|
||||
platform.click();
|
||||
ok(
|
||||
platform.checked,
|
||||
"After clicking the input, the Firefox Platform preset is now checked."
|
||||
);
|
||||
|
||||
ok(
|
||||
activeConfigurationHasFeature("stackwalk"),
|
||||
"The Firefox Platform preset uses stackwalking."
|
||||
);
|
||||
|
||||
const frontEnd = await getNearestInputFromText(
|
||||
document,
|
||||
"Firefox Front-End"
|
||||
);
|
||||
|
||||
ok(!frontEnd.checked, "The Firefox front-end preset is not checked.");
|
||||
frontEnd.click();
|
||||
ok(
|
||||
frontEnd.checked,
|
||||
"After clicking the input, the Firefox front-end preset is now checked."
|
||||
);
|
||||
});
|
||||
|
||||
const { revertRecordingPreferences } = ChromeUtils.import(
|
||||
"resource://devtools/client/performance-new/popup/background.jsm.js"
|
||||
);
|
||||
|
||||
revertRecordingPreferences();
|
||||
});
|
|
@ -45,7 +45,7 @@
|
|||
document.querySelector("#perf-settings-features-summary").click();
|
||||
|
||||
is(selectors.getFeatures(getState()).join(","),
|
||||
filterFeatures(["js", "leaf", "stackwalk"]).join(","),
|
||||
filterFeatures(["js"]).join(","),
|
||||
"The features starts out with the default");
|
||||
is(recordingPreferencesCalls.length, 0,
|
||||
"No calls have been made to set preferences");
|
||||
|
@ -55,18 +55,18 @@
|
|||
|
||||
|
||||
is(selectors.getFeatures(getState()).join(","),
|
||||
filterFeatures(["leaf", "stackwalk"]).join(","),
|
||||
filterFeatures([]).join(","),
|
||||
"The feature has been removed.");
|
||||
is(recordingPreferencesCalls.length, 1,
|
||||
"The preferences have been updated.");
|
||||
is(recordingPreferencesCalls[0].features.join(","),
|
||||
filterFeatures(["leaf", "stackwalk"]).join(","),
|
||||
filterFeatures([]).join(","),
|
||||
"The preferences have been updated.");
|
||||
|
||||
// Enable a feature
|
||||
document.querySelector("#perf-settings-feature-checkbox-screenshots").click();
|
||||
is(selectors.getFeatures(getState()).join(","),
|
||||
filterFeatures(["screenshots", "leaf", "stackwalk"]).join(","),
|
||||
filterFeatures(["screenshots"]).join(","),
|
||||
"Another feature was added");
|
||||
|
||||
// Start the profiler by clicking the start button, and flushing the async
|
||||
|
@ -77,7 +77,7 @@
|
|||
is(perfFrontMock._startProfilerCalls.length, 1,
|
||||
"Start profiler was called once");
|
||||
is(perfFrontMock._startProfilerCalls[0].features.join(","),
|
||||
filterFeatures(["screenshots", "leaf", "stackwalk"]).join(","),
|
||||
filterFeatures(["screenshots"]).join(","),
|
||||
"Start profiler was called with the correct features");
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
document.querySelector("#perf-settings-threads-summary").click();
|
||||
|
||||
const threadTextEl = document.querySelector("#perf-settings-thread-text");
|
||||
is(selectors.getThreads(getState()).join(","), "GeckoMain,Compositor,Renderer",
|
||||
is(selectors.getThreads(getState()).join(","), "GeckoMain,Compositor,Renderer,DOM Worker",
|
||||
"The threads starts out with the default");
|
||||
is(threadTextEl.value, "GeckoMain,Compositor,Renderer",
|
||||
is(threadTextEl.value, "GeckoMain,Compositor,Renderer,DOM Worker",
|
||||
"The threads starts out with the default in the thread text input");
|
||||
is(recordingPreferencesCalls.length, 0,
|
||||
"No calls have been made to set preferences");
|
||||
|
@ -45,20 +45,20 @@
|
|||
// Click the Compositor checkbox.
|
||||
document.querySelector("#perf-settings-thread-checkbox-compositor").click();
|
||||
|
||||
is(selectors.getThreads(getState()).join(","), "GeckoMain,Renderer",
|
||||
is(selectors.getThreads(getState()).join(","), "GeckoMain,Renderer,DOM Worker",
|
||||
"The threads have been updated");
|
||||
is(threadTextEl.value, "GeckoMain,Renderer",
|
||||
is(threadTextEl.value, "GeckoMain,Renderer,DOM Worker",
|
||||
"The threads have been updated in the thread text input");
|
||||
is(recordingPreferencesCalls.length, 1,
|
||||
"The preferences have been updated.");
|
||||
is(recordingPreferencesCalls[0].threads.join(","), "GeckoMain,Renderer",
|
||||
is(recordingPreferencesCalls[0].threads.join(","), "GeckoMain,Renderer,DOM Worker",
|
||||
"The preferences have been updated.");
|
||||
|
||||
// Enable a thread
|
||||
document.querySelector("#perf-settings-thread-checkbox-dom-worker").click();
|
||||
is(selectors.getThreads(getState()).join(","), "GeckoMain,Renderer,DOM Worker",
|
||||
document.querySelector("#perf-settings-thread-checkbox-dns-resolver").click();
|
||||
is(selectors.getThreads(getState()).join(","), "GeckoMain,Renderer,DOM Worker,DNS Resolver",
|
||||
"Another thread was added");
|
||||
is(threadTextEl.value, "GeckoMain,Renderer,DOM Worker",
|
||||
is(threadTextEl.value, "GeckoMain,Renderer,DOM Worker,DNS Resolver",
|
||||
"Another thread was in the thread text input");
|
||||
|
||||
// See the initial state of the checkbox
|
||||
|
@ -68,27 +68,27 @@
|
|||
"The style thread is not checked.");
|
||||
|
||||
// Set the input box directly
|
||||
setReactFriendlyInputValue(threadTextEl, "GeckoMain,DOM Worker,StyleThread");
|
||||
setReactFriendlyInputValue(threadTextEl, "GeckoMain,DOM Worker,DNS Resolver,StyleThread");
|
||||
threadTextEl.dispatchEvent(new Event("blur", { bubbles: true }));
|
||||
|
||||
ok(styleThreadCheckbox.checked,
|
||||
"The style thread is now checked.");
|
||||
is(selectors.getThreads(getState()).join(","), "GeckoMain,DOM Worker,StyleThread",
|
||||
is(selectors.getThreads(getState()).join(","), "GeckoMain,DOM Worker,DNS Resolver,StyleThread",
|
||||
"Another thread was added");
|
||||
is(threadTextEl.value, "GeckoMain,DOM Worker,StyleThread",
|
||||
is(threadTextEl.value, "GeckoMain,DOM Worker,DNS Resolver,StyleThread",
|
||||
"Another thread was in the thread text input");
|
||||
|
||||
// Enable profiling of all threads
|
||||
const allThreadsCheckbox = document.querySelector(
|
||||
"#perf-settings-thread-checkbox-all-threads");
|
||||
allThreadsCheckbox.click();
|
||||
is(selectors.getThreads(getState()).join(","), "GeckoMain,DOM Worker,StyleThread,*",
|
||||
is(selectors.getThreads(getState()).join(","), "GeckoMain,DOM Worker,DNS Resolver,StyleThread,*",
|
||||
"Asterisk was added")
|
||||
is(threadTextEl.value, "GeckoMain,DOM Worker,StyleThread,*",
|
||||
is(threadTextEl.value, "GeckoMain,DOM Worker,DNS Resolver,StyleThread,*",
|
||||
"Asterisk was in the thread text input");
|
||||
|
||||
// Remove the asterisk
|
||||
setReactFriendlyInputValue(threadTextEl, "GeckoMain,DOM Worker,StyleThread");
|
||||
setReactFriendlyInputValue(threadTextEl, "GeckoMain,DOM Worker,DNS Resolver,StyleThread");
|
||||
threadTextEl.dispatchEvent(new Event("blur", { bubbles: true }));
|
||||
ok(!allThreadsCheckbox.checked,
|
||||
"The all threads checkbox is not checked.");
|
||||
|
@ -101,7 +101,7 @@
|
|||
is(perfFrontMock._startProfilerCalls.length, 1,
|
||||
"Start profiler was called once");
|
||||
is(perfFrontMock._startProfilerCalls[0].threads.join(","),
|
||||
"GeckoMain,DOM Worker,StyleThread",
|
||||
"GeckoMain,DOM Worker,DNS Resolver,StyleThread",
|
||||
"Start profiler was called with the correct threads");
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -69,8 +69,11 @@ add_task(function test() {
|
|||
getRecordingPreferencesFromBrowser,
|
||||
setRecordingPreferencesOnBrowser,
|
||||
revertRecordingPreferences,
|
||||
changePreset,
|
||||
} = setupBackgroundJsm();
|
||||
|
||||
changePreset("custom");
|
||||
|
||||
Assert.ok(
|
||||
getRecordingPreferencesFromBrowser().features.includes("js"),
|
||||
"The js preference is present initially."
|
||||
|
|
Загрузка…
Ссылка в новой задаче