Bug 1690698 - [devtools] Remove performReload option and call reload from the frontend r=ochameau,bomsy,devtools-backward-compat-reviewers

Depends on D104424

performReload is not a regular configuration option as it is not persisted.
It is rather a flag for a single call to Target::reconfigure.
As we move configuration options outside of the target, it will be easier to drive the reload from the frontend.
The call sites using performReload are quite rare and only found in the netmonitor so it doesn't feel like this
requires a framework solution for now. We add explicit calls to TargetFront::reload() in spots where the netmonitor
used to pass performReload = true.

Differential Revision: https://phabricator.services.mozilla.com/D104891
This commit is contained in:
Julian Descottes 2021-02-15 22:41:59 +00:00
Родитель 853a765c1f
Коммит c2ea869048
4 изменённых файлов: 16 добавлений и 24 удалений

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

@ -471,43 +471,41 @@ class Connector {
};
// Reconfigures the tab and waits for the target to finish navigating.
const reconfigureTabAndWaitForNavigation = options => {
options.performReload = true;
const reconfigureTabAndReload = async options => {
const navigationFinished = waitForNavigation();
return reconfigureTab(options).then(() => navigationFinished);
await reconfigureTab(options);
await this.toolbox.target.reload();
await navigationFinished;
};
switch (type) {
case ACTIVITY_TYPE.RELOAD.WITH_CACHE_DEFAULT:
return reconfigureTabAndWaitForNavigation({}).then(standBy);
return reconfigureTabAndReload({}).then(standBy);
case ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED:
this.currentActivity = ACTIVITY_TYPE.ENABLE_CACHE;
this.currentTarget.once("will-navigate", () => {
this.currentActivity = type;
});
return reconfigureTabAndWaitForNavigation({
return reconfigureTabAndReload({
cacheDisabled: false,
performReload: true,
}).then(standBy);
case ACTIVITY_TYPE.RELOAD.WITH_CACHE_DISABLED:
this.currentActivity = ACTIVITY_TYPE.DISABLE_CACHE;
this.currentTarget.once("will-navigate", () => {
this.currentActivity = type;
});
return reconfigureTabAndWaitForNavigation({
return reconfigureTabAndReload({
cacheDisabled: true,
performReload: true,
}).then(standBy);
case ACTIVITY_TYPE.ENABLE_CACHE:
this.currentActivity = type;
return reconfigureTab({
cacheDisabled: false,
performReload: false,
}).then(standBy);
case ACTIVITY_TYPE.DISABLE_CACHE:
this.currentActivity = type;
return reconfigureTab({
cacheDisabled: true,
performReload: false,
}).then(standBy);
}
this.currentActivity = ACTIVITY_TYPE.NONE;

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

@ -206,16 +206,17 @@ function waitForNavigation(target) {
});
}
function toggleCache(toolbox, disabled) {
const options = { cacheDisabled: disabled, performReload: true };
async function toggleCache(toolbox, disabled) {
const options = { cacheDisabled: disabled };
const navigationFinished = waitForNavigation(toolbox.target);
// Disable the cache for any toolbox that it is opened from this point on.
Services.prefs.setBoolPref("devtools.cache.disabled", disabled);
return toolbox.targetList
.updateConfiguration(options)
.then(() => navigationFinished);
await toolbox.targetList.updateConfiguration(options);
await toolbox.target.reload();
await navigationFinished;
}
/**

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

@ -1275,14 +1275,8 @@ const browsingContextTargetPrototype = {
if (typeof options.restoreFocus == "boolean") {
this._restoreFocus = options.restoreFocus;
}
// Reload if:
// - there's an explicit `performReload` flag and it's true
// - there's no `performReload` flag, but it makes sense to do so
const hasExplicitReloadFlag = "performReload" in options;
if (
(hasExplicitReloadFlag && options.performReload) ||
(!hasExplicitReloadFlag && reload)
) {
if (reload) {
this.reload();
}
},

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

@ -47,7 +47,6 @@ types.addDictType("browsingContextTarget.reconfigure", {
cacheDisabled: "nullable:boolean",
colorSchemeSimulation: "nullable:string",
serviceWorkersTestingEnabled: "nullable:boolean",
performReload: "nullable:boolean",
printSimulationEnabled: "nullable:boolean",
});