Skip to content

Commit 94824a1

Browse files
OrKoNDevtools-frontend LUCI CQ
authored andcommitted
[cleanup] remove duplicate configs in InspectorFrontendHost
Bug: none Change-Id: I8bf9767bdd5e86d78dd45a7252ab764b5f159418 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6264605 Reviewed-by: Benedikt Meurer <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
1 parent 85f3ea4 commit 94824a1

File tree

3 files changed

+20
-50
lines changed

3 files changed

+20
-50
lines changed

front_end/core/host/InspectorFrontendHost.ts

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -404,48 +404,15 @@ export class InspectorFrontendHostStub implements InspectorFrontendHostAPI {
404404
}
405405

406406
getHostConfig(callback: (hostConfig: Root.Runtime.HostConfig) => void): void {
407-
const result: Root.Runtime.HostConfig = {
408-
aidaAvailability: {
409-
enabled: true,
410-
blockedByAge: false,
411-
blockedByEnterprisePolicy: false,
412-
blockedByGeo: false,
413-
disallowLogging: true,
414-
enterprisePolicyValue: 0,
415-
},
416-
devToolsConsoleInsights: {
417-
modelId: '',
418-
temperature: -1,
419-
enabled: false,
420-
},
421-
devToolsFreestyler: {
422-
modelId: '',
423-
temperature: -1,
424-
enabled: false,
425-
},
426-
devToolsImprovedWorkspaces: {
427-
enabled: false,
428-
},
407+
// This HostConfig config is used in the hosted mode (see the
408+
// comment on top of this class). Only add non-default config params
409+
// here that you want to also apply in the hosted mode. For tests
410+
// use the hostConfigForTesting override.
411+
const hostConfigForHostedMode: Root.Runtime.HostConfig = {
429412
devToolsVeLogging: {
430413
enabled: true,
431-
testing: false,
432-
},
433-
devToolsWellKnown: {
434-
enabled: true,
435-
},
436-
devToolsPrivacyUI: {
437-
enabled: false,
438-
},
439-
devToolsEnableOriginBoundCookies: {
440-
portBindingEnabled: false,
441-
schemeBindingEnabled: false,
442-
},
443-
devToolsAnimationStylesInStylesTab: {
444-
enabled: false,
445414
},
446-
isOffTheRecord: false,
447415
thirdPartyCookieControls: {
448-
thirdPartyCookieRestrictionEnabled: false,
449416
thirdPartyCookieMetadataEnabled: true,
450417
thirdPartyCookieHeuristicsEnabled: true,
451418
managedBlockThirdPartyCookies: 'Unset',
@@ -455,19 +422,19 @@ export class InspectorFrontendHostStub implements InspectorFrontendHostAPI {
455422
const {hostConfigForTesting} = (globalThis as unknown as {hostConfigForTesting: Root.Runtime.HostConfig});
456423
for (const key of Object.keys(hostConfigForTesting)) {
457424
const mergeEntry = <K extends keyof Root.Runtime.HostConfig>(key: K): void => {
458-
if (typeof result[key] === 'object' && typeof hostConfigForTesting[key] === 'object') {
425+
if (typeof hostConfigForHostedMode[key] === 'object' && typeof hostConfigForTesting[key] === 'object') {
459426
// If the config is an object, merge the settings, but preferring
460427
// the hostConfigForTesting values over the result values.
461-
result[key] = {...result[key], ...hostConfigForTesting[key]};
428+
hostConfigForHostedMode[key] = {...hostConfigForHostedMode[key], ...hostConfigForTesting[key]};
462429
} else {
463430
// Override with the testing config if the value is present + not null/undefined.
464-
result[key] = hostConfigForTesting[key] ?? result[key];
431+
hostConfigForHostedMode[key] = hostConfigForTesting[key] ?? hostConfigForHostedMode[key];
465432
}
466433
};
467434
mergeEntry(key as keyof Root.Runtime.HostConfig);
468435
}
469436
}
470-
callback(result);
437+
callback(hostConfigForHostedMode);
471438
}
472439

473440
upgradeDraggedFileSystemPermissions(fileSystem: FileSystem): void {

test/e2e/ai_assistance/ai_assistance_test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ describe('AI Assistance', function() {
202202

203203
await setupMocks(
204204
{
205-
aidaAvailability: {},
205+
aidaAvailability: {
206+
enabled: true,
207+
disallowLogging: true,
208+
enterprisePolicyValue: 0,
209+
},
206210
devToolsFreestyler: {
207211
enabled: true,
208212
},

test/e2e/console/console-insight_test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ describe('ConsoleInsight', function() {
2828
waitUntil: 'networkidle0',
2929
});
3030
}
31-
3231
it('shows an insight for a console message via the context menu', async () => {
3332
const {target} = getBrowserAndPages();
34-
await setupMocks({}, {enabled: true});
33+
await setupMocks({enabled: true}, {enabled: true});
3534
await click(CONSOLE_TAB_SELECTOR);
3635
await target.evaluate(() => {
3736
console.error(new Error('Unexpected error'));
@@ -42,7 +41,7 @@ describe('ConsoleInsight', function() {
4241

4342
it('shows an insight for a console message via the hover button', async () => {
4443
const {target} = getBrowserAndPages();
45-
await setupMocks({}, {enabled: true});
44+
await setupMocks({enabled: true}, {enabled: true});
4645
await click(CONSOLE_TAB_SELECTOR);
4746
await target.evaluate(() => {
4847
console.error(new Error('Unexpected error'));
@@ -75,7 +74,7 @@ describe('ConsoleInsight', function() {
7574
it('shows the hover button even if locale is not supported', async () => {
7675
const {target} = getBrowserAndPages();
7776
await setDevToolsSettings({language: 'zh'});
78-
await setupMocks({}, {enabled: true});
77+
await setupMocks({enabled: true}, {enabled: true});
7978
await click(CONSOLE_TAB_SELECTOR);
8079
await target.evaluate(() => {
8180
console.error(new Error('Unexpected error'));
@@ -86,7 +85,7 @@ describe('ConsoleInsight', function() {
8685

8786
it('shows the hover button even if age check is not passing', async () => {
8887
const {target} = getBrowserAndPages();
89-
await setupMocks({blockedByAge: true}, {enabled: true});
88+
await setupMocks({blockedByAge: true, enabled: true}, {enabled: true});
9089
await click(CONSOLE_TAB_SELECTOR);
9190
await target.evaluate(() => {
9291
console.error(new Error('Unexpected error'));
@@ -97,7 +96,7 @@ describe('ConsoleInsight', function() {
9796

9897
it('does not show the hover button if policy does not allow it', async () => {
9998
const {target} = getBrowserAndPages();
100-
await setupMocks({blockedByEnterprisePolicy: true}, {enabled: true});
99+
await setupMocks({blockedByEnterprisePolicy: true, enabled: true}, {enabled: true});
101100
await click(CONSOLE_TAB_SELECTOR);
102101
await target.evaluate(() => {
103102
console.error(new Error('Unexpected error'));
@@ -108,7 +107,7 @@ describe('ConsoleInsight', function() {
108107

109108
it('shows the hover button even if it is restriced by geography', async () => {
110109
const {target} = getBrowserAndPages();
111-
await setupMocks({blockedByGeo: true}, {enabled: true});
110+
await setupMocks({blockedByGeo: true, enabled: true}, {enabled: true});
112111
await click(CONSOLE_TAB_SELECTOR);
113112
await target.evaluate(() => {
114113
console.error(new Error('Unexpected error'));

0 commit comments

Comments
 (0)