Skip to content

Commit e8cddcb

Browse files
bmeurerDevtools-frontend LUCI CQ
authored andcommitted
[project_settings] Add "workspace.uuid" field.
Adapt the implementation to the latest design changes, and require a "uuid" in addition to the "root". Also change the validation of the `devtools.json` to require "workspace" to be either absent or an object that contains both "root" and "uuid" string properties. Doc: https://goo.gle/devtools-json-design Bug: 395037775, 395562934 Change-Id: Ia73568152abe7150db3823d210470e791c6a7b90 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6264208 Commit-Queue: Alex Rudenko <[email protected]> Auto-Submit: Benedikt Meurer <[email protected]> Reviewed-by: Alex Rudenko <[email protected]>
1 parent dbb235d commit e8cddcb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

front_end/models/project_settings/ProjectSettingsModel.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('ProjectSettingsModel', () => {
9393
sinon.stub(frame, 'id').get(() => frameId);
9494

9595
pageResourceLoader.loadResource.withArgs(url, sinon.match({target, frameId, initiatorUrl}))
96-
.returns(Promise.resolve({content: '{"workspace":{"root":"/home/foo"}}'}));
96+
.returns(Promise.resolve({content: '{"workspace":{"root":"/home/foo","uuid":"foo"}}'}));
9797

9898
const projectSettingsModel = ProjectSettingsModel.instance({
9999
forceNew: true,
@@ -103,7 +103,7 @@ describe('ProjectSettingsModel', () => {
103103
});
104104

105105
const projectSettings = await projectSettingsModel.projectSettingsPromise;
106-
assert.deepEqual(projectSettings, {workspace: {root: '/home/foo'}});
106+
assert.deepEqual(projectSettings, {workspace: {root: '/home/foo', uuid: 'foo'}});
107107
});
108108

109109
it('listens for navigations', () => {

front_end/models/project_settings/ProjectSettingsModel.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import * as SDK from '../../core/sdk/sdk.js';
1313
* @see https://goo.gle/devtools-json-design
1414
*/
1515
export interface ProjectSettings {
16-
readonly workspace?: {readonly root?: string};
16+
readonly workspace?: {readonly root: string, readonly uuid: string};
1717
}
1818

1919
const EMPTY_PROJECT_SETTINGS: ProjectSettings = Object.freeze({});
@@ -140,8 +140,11 @@ export class ProjectSettingsModel extends Common.ObjectWrapper.ObjectWrapper<Eve
140140
if (typeof workspace !== 'object' || workspace === null) {
141141
throw new Error('Invalid "workspace" field');
142142
}
143-
if (!['string', 'undefined'].includes(typeof workspace.root)) {
144-
throw new Error('Invalid "workspace.root" field');
143+
if (typeof workspace.root !== 'string') {
144+
throw new Error('Invalid or missing "workspace.root" field');
145+
}
146+
if (typeof workspace.uuid !== 'string') {
147+
throw new Error('Invalid or missing "workspace.uuid" field');
145148
}
146149
}
147150
return Object.freeze(devtoolsJSON);

0 commit comments

Comments
 (0)