chrome-devtools-frontend 1.0.1014346 → 1.0.1015658

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/.eslintignore +1 -0
  2. package/config/gni/devtools_grd_files.gni +4 -2
  3. package/front_end/core/common/JavaScriptMetaData.ts +20 -0
  4. package/front_end/core/i18n/locales/af.json +195 -93
  5. package/front_end/core/i18n/locales/am.json +191 -89
  6. package/front_end/core/i18n/locales/ar.json +193 -91
  7. package/front_end/core/i18n/locales/as.json +192 -90
  8. package/front_end/core/i18n/locales/az.json +191 -89
  9. package/front_end/core/i18n/locales/be.json +191 -89
  10. package/front_end/core/i18n/locales/bg.json +190 -88
  11. package/front_end/core/i18n/locales/bn.json +191 -89
  12. package/front_end/core/i18n/locales/bs.json +193 -91
  13. package/front_end/core/i18n/locales/ca.json +189 -87
  14. package/front_end/core/i18n/locales/cs.json +191 -89
  15. package/front_end/core/i18n/locales/cy.json +191 -89
  16. package/front_end/core/i18n/locales/da.json +191 -89
  17. package/front_end/core/i18n/locales/de.json +193 -91
  18. package/front_end/core/i18n/locales/el.json +174 -72
  19. package/front_end/core/i18n/locales/en-GB.json +132 -30
  20. package/front_end/core/i18n/locales/en-US.json +3 -3
  21. package/front_end/core/i18n/locales/en-XL.json +3 -3
  22. package/front_end/core/i18n/locales/es-419.json +192 -90
  23. package/front_end/core/i18n/locales/es.json +200 -98
  24. package/front_end/core/i18n/locales/et.json +190 -88
  25. package/front_end/core/i18n/locales/eu.json +197 -95
  26. package/front_end/core/i18n/locales/fa.json +192 -90
  27. package/front_end/core/i18n/locales/fi.json +192 -90
  28. package/front_end/core/i18n/locales/fil.json +190 -88
  29. package/front_end/core/i18n/locales/fr-CA.json +191 -89
  30. package/front_end/core/i18n/locales/fr.json +192 -90
  31. package/front_end/core/i18n/locales/gl.json +173 -71
  32. package/front_end/core/i18n/locales/gu.json +192 -90
  33. package/front_end/core/i18n/locales/he.json +191 -89
  34. package/front_end/core/i18n/locales/hi.json +172 -70
  35. package/front_end/core/i18n/locales/hr.json +180 -78
  36. package/front_end/core/i18n/locales/hu.json +191 -89
  37. package/front_end/core/i18n/locales/hy.json +192 -90
  38. package/front_end/core/i18n/locales/id.json +192 -90
  39. package/front_end/core/i18n/locales/is.json +176 -74
  40. package/front_end/core/i18n/locales/it.json +192 -90
  41. package/front_end/core/i18n/locales/ja.json +190 -88
  42. package/front_end/core/i18n/locales/ka.json +190 -88
  43. package/front_end/core/i18n/locales/kk.json +198 -96
  44. package/front_end/core/i18n/locales/km.json +195 -93
  45. package/front_end/core/i18n/locales/kn.json +193 -91
  46. package/front_end/core/i18n/locales/ko.json +190 -88
  47. package/front_end/core/i18n/locales/ky.json +193 -91
  48. package/front_end/core/i18n/locales/lo.json +192 -90
  49. package/front_end/core/i18n/locales/lt.json +193 -91
  50. package/front_end/core/i18n/locales/lv.json +175 -73
  51. package/front_end/core/i18n/locales/mk.json +193 -91
  52. package/front_end/core/i18n/locales/ml.json +193 -91
  53. package/front_end/core/i18n/locales/mn.json +190 -88
  54. package/front_end/core/i18n/locales/mr.json +191 -89
  55. package/front_end/core/i18n/locales/ms.json +190 -88
  56. package/front_end/core/i18n/locales/my.json +191 -89
  57. package/front_end/core/i18n/locales/ne.json +172 -70
  58. package/front_end/core/i18n/locales/nl.json +191 -89
  59. package/front_end/core/i18n/locales/no.json +191 -89
  60. package/front_end/core/i18n/locales/or.json +196 -94
  61. package/front_end/core/i18n/locales/pa.json +191 -89
  62. package/front_end/core/i18n/locales/pl.json +191 -89
  63. package/front_end/core/i18n/locales/pt-PT.json +199 -97
  64. package/front_end/core/i18n/locales/pt.json +191 -89
  65. package/front_end/core/i18n/locales/ro.json +193 -91
  66. package/front_end/core/i18n/locales/ru.json +193 -91
  67. package/front_end/core/i18n/locales/si.json +191 -89
  68. package/front_end/core/i18n/locales/sk.json +192 -90
  69. package/front_end/core/i18n/locales/sl.json +191 -89
  70. package/front_end/core/i18n/locales/sq.json +193 -91
  71. package/front_end/core/i18n/locales/sr-Latn.json +190 -88
  72. package/front_end/core/i18n/locales/sr.json +190 -88
  73. package/front_end/core/i18n/locales/sv.json +191 -89
  74. package/front_end/core/i18n/locales/sw.json +192 -90
  75. package/front_end/core/i18n/locales/ta.json +193 -91
  76. package/front_end/core/i18n/locales/te.json +134 -32
  77. package/front_end/core/i18n/locales/th.json +190 -88
  78. package/front_end/core/i18n/locales/tr.json +193 -91
  79. package/front_end/core/i18n/locales/uk.json +193 -91
  80. package/front_end/core/i18n/locales/ur.json +191 -89
  81. package/front_end/core/i18n/locales/uz.json +190 -88
  82. package/front_end/core/i18n/locales/vi.json +190 -88
  83. package/front_end/core/i18n/locales/zh-HK.json +192 -90
  84. package/front_end/core/i18n/locales/zh-TW.json +195 -93
  85. package/front_end/core/i18n/locales/zh.json +191 -89
  86. package/front_end/core/i18n/locales/zu.json +192 -90
  87. package/front_end/core/sdk/DOMModel.ts +9 -0
  88. package/front_end/core/sdk/DebuggerModel.ts +0 -28
  89. package/front_end/core/sdk/Script.ts +5 -14
  90. package/front_end/core/sdk/SourceMap.ts +88 -27
  91. package/front_end/generated/InspectorBackendCommands.js +7 -3
  92. package/front_end/generated/protocol-mapping.d.ts +16 -0
  93. package/front_end/generated/protocol-proxy-api.d.ts +18 -0
  94. package/front_end/generated/protocol.ts +31 -5
  95. package/front_end/models/bindings/ResourceScriptMapping.ts +1 -2
  96. package/front_end/models/emulation/EmulatedDevices.ts +0 -13
  97. package/front_end/models/javascript_metadata/DOMPinnedProperties.ts +247 -225
  98. package/front_end/models/javascript_metadata/JavaScriptMetadata.ts +3 -0
  99. package/front_end/models/javascript_metadata/NativeFunctions.js +4 -4
  100. package/front_end/models/javascript_metadata/javascript_metadata.ts +3 -0
  101. package/front_end/models/source_map_scopes/NamesResolver.ts +99 -23
  102. package/front_end/panels/elements/ElementsTreeElement.ts +7 -3
  103. package/front_end/panels/elements/components/ElementsBreadcrumbs.ts +3 -4
  104. package/front_end/panels/elements/components/LayoutPane.ts +3 -4
  105. package/front_end/panels/elements/components/QueryContainer.ts +3 -4
  106. package/front_end/panels/elements/components/components.ts +0 -2
  107. package/front_end/panels/lighthouse/lighthouseStartView.css +3 -1
  108. package/front_end/panels/sources/ScopeChainSidebarPane.ts +4 -42
  109. package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorController.ts +64 -8
  110. package/front_end/{panels/elements/components → ui/components/node_text}/NodeText.ts +2 -1
  111. package/front_end/{panels/elements/components → ui/components/node_text}/nodeText.css +0 -0
  112. package/front_end/ui/components/node_text/node_text.ts +9 -0
  113. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +8 -5
  114. package/front_end/ui/legacy/components/object_ui/objectValue.css +1 -4
  115. package/package.json +1 -1
  116. package/scripts/webidl-properties/config.js +305 -239
  117. package/scripts/webidl-properties/get-props.js +23 -12
  118. package/scripts/webidl-properties/index.js +14 -9
  119. package/scripts/webidl-properties/tests.js +58 -14
@@ -54,12 +54,19 @@ const computeScopeTree = async function(functionScope: SDK.DebuggerModel.ScopeCh
54
54
  functionEndLocation.columnNumber);
55
55
  const scopeText = text.extract(scopeRange);
56
56
  const scopeStart = text.toSourceRange(scopeRange).offset;
57
- let prefix = 'function fui';
58
- let scopeTree = await Formatter.FormatterWorkerPool.formatterWorkerPool().javaScriptScopeTree(prefix + scopeText);
57
+ // We wrap the scope in a class constructor. This handles the case where the
58
+ // scope is a (non-arrow) function and the case where it is a constructor
59
+ // (so that parsing 'super' calls succeeds).
60
+ let prefix = 'class DummyClass extends DummyBase { constructor';
61
+ let suffix = '}';
62
+ let scopeTree =
63
+ await Formatter.FormatterWorkerPool.formatterWorkerPool().javaScriptScopeTree(prefix + scopeText + suffix);
59
64
  if (!scopeTree) {
60
65
  // Try to parse the function as an arrow function.
61
- prefix = 'let fui = ';
62
- scopeTree = await Formatter.FormatterWorkerPool.formatterWorkerPool().javaScriptScopeTree(prefix + scopeText);
66
+ prefix = '';
67
+ suffix = '';
68
+ scopeTree =
69
+ await Formatter.FormatterWorkerPool.formatterWorkerPool().javaScriptScopeTree(prefix + scopeText + suffix);
63
70
  }
64
71
  if (!scopeTree) {
65
72
  return null;
@@ -174,6 +181,15 @@ export const scopeIdentifiers = async function(
174
181
  }
175
182
  };
176
183
 
184
+ const identifierAndPunctuationRegExp = /^\s*([A-Za-z_$][A-Za-z_$0-9]*)\s*([.;,]?)\s*$/;
185
+
186
+ const enum Punctuation {
187
+ None = 0,
188
+ Comma = 1,
189
+ Dot = 2,
190
+ Semicolon = 3,
191
+ }
192
+
177
193
  const resolveScope =
178
194
  async(scope: SDK.DebuggerModel
179
195
  .ScopeChainEntry): Promise<{variableMapping: Map<string, string>, thisMapping: string | null}> => {
@@ -182,8 +198,6 @@ const resolveScope =
182
198
  const sourceMap = Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().sourceMapForScript(script);
183
199
 
184
200
  if (!cachedScopeMap || cachedScopeMap.sourceMap !== sourceMap) {
185
- // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration)
186
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
187
201
  // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration)
188
202
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
189
203
  const identifiersPromise =
@@ -260,33 +274,95 @@ const resolveScope =
260
274
  script: SDK.Script.Script, sourceMap: SDK.SourceMap.SourceMap, name: string,
261
275
  position: {lineNumber: number, columnNumber: number},
262
276
  textCache: Map<string, TextUtils.Text.Text>): Promise<string|null> {
263
- const startEntry = sourceMap.findEntry(position.lineNumber, position.columnNumber);
264
- const endEntry = sourceMap.findEntry(position.lineNumber, position.columnNumber + name.length);
265
- if (!startEntry || !endEntry || !startEntry.sourceURL || startEntry.sourceURL !== endEntry.sourceURL ||
266
- !startEntry.sourceLineNumber || !startEntry.sourceColumnNumber || !endEntry.sourceLineNumber ||
267
- !endEntry.sourceColumnNumber) {
277
+ const ranges = sourceMap.findEntryRanges(position.lineNumber, position.columnNumber);
278
+ if (!ranges) {
268
279
  return null;
269
280
  }
270
- const sourceTextRange = new TextUtils.TextRange.TextRange(
271
- startEntry.sourceLineNumber, startEntry.sourceColumnNumber, endEntry.sourceLineNumber,
272
- endEntry.sourceColumnNumber);
281
+ // Extract the underlying text from the compiled code's range and make sure that
282
+ // it starts with the identifier |name|.
273
283
  const uiSourceCode =
274
284
  Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().uiSourceCodeForSourceMapSourceURL(
275
- script.debuggerModel, startEntry.sourceURL, script.isContentScript());
285
+ script.debuggerModel, ranges.sourceURL, script.isContentScript());
276
286
  if (!uiSourceCode) {
277
287
  return null;
278
288
  }
279
- const {content} = await uiSourceCode.requestContent();
280
- if (!content) {
289
+ const compiledText = getTextFor((await script.requestContent()).content);
290
+ if (!compiledText) {
291
+ return null;
292
+ }
293
+ const compiledToken = compiledText.extract(ranges.range);
294
+ const parsedCompiledToken = extractIdentifier(compiledToken);
295
+ if (!parsedCompiledToken) {
281
296
  return null;
282
297
  }
283
- let text = textCache.get(content);
284
- if (!text) {
285
- text = new TextUtils.Text.Text(content);
286
- textCache.set(content, text);
298
+ const {name: compiledName, punctuation: compiledPunctuation} = parsedCompiledToken;
299
+ if (compiledName !== name) {
300
+ return null;
301
+ }
302
+
303
+ // Extract the mapped name from the source code range and ensure that the punctuation
304
+ // matches the one from the compiled code.
305
+ const sourceText = getTextFor((await uiSourceCode.requestContent()).content);
306
+ if (!sourceText) {
307
+ return null;
308
+ }
309
+ const sourceToken = sourceText.extract(ranges.sourceRange);
310
+ const parsedSourceToken = extractIdentifier(sourceToken);
311
+ if (!parsedSourceToken) {
312
+ return null;
313
+ }
314
+ const {name: sourceName, punctuation: sourcePunctuation} = parsedSourceToken;
315
+ // Accept the source name if it is followed by the same punctuation.
316
+ if (compiledPunctuation === sourcePunctuation) {
317
+ return sourceName;
318
+ }
319
+ // Let us also allow semicolons into commas since that it is a common transformation.
320
+ if (compiledPunctuation === Punctuation.Comma && sourcePunctuation === Punctuation.Semicolon) {
321
+ return sourceName;
322
+ }
323
+
324
+ return null;
325
+
326
+ function extractIdentifier(token: string): {name: string, punctuation: Punctuation}|null {
327
+ const match = token.match(identifierAndPunctuationRegExp);
328
+ if (!match) {
329
+ return null;
330
+ }
331
+
332
+ const name = match[1];
333
+ let punctuation: Punctuation|null = null;
334
+ switch (match[2]) {
335
+ case '.':
336
+ punctuation = Punctuation.Dot;
337
+ break;
338
+ case ',':
339
+ punctuation = Punctuation.Comma;
340
+ break;
341
+ case ';':
342
+ punctuation = Punctuation.Semicolon;
343
+ break;
344
+ case '':
345
+ punctuation = Punctuation.None;
346
+ break;
347
+ default:
348
+ console.error(`Name token parsing error: unexpected token "${match[2]}"`);
349
+ return null;
350
+ }
351
+
352
+ return {name, punctuation};
353
+ }
354
+
355
+ function getTextFor(content: string|null): TextUtils.Text.Text|null {
356
+ if (!content) {
357
+ return null;
358
+ }
359
+ let text = textCache.get(content);
360
+ if (!text) {
361
+ text = new TextUtils.Text.Text(content);
362
+ textCache.set(content, text);
363
+ }
364
+ return text;
287
365
  }
288
- const originalIdentifier = text.extract(sourceTextRange).trim();
289
- return /[a-zA-Z0-9_$]+/.test(originalIdentifier) ? originalIdentifier : null;
290
366
  }
291
367
 
292
368
  function findFunctionScope(): SDK.DebuggerModel.ScopeChainEntry|null {
@@ -1706,9 +1706,13 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
1706
1706
  break;
1707
1707
 
1708
1708
  case Node.ELEMENT_NODE: {
1709
- const pseudoType = node.pseudoType();
1710
- if (pseudoType) {
1711
- this.buildPseudoElementDOM(titleDOM, pseudoType);
1709
+ let pseudoElementName = node.pseudoType();
1710
+ if (pseudoElementName) {
1711
+ const pseudoIdentifier = node.pseudoIdentifier();
1712
+ if (pseudoIdentifier) {
1713
+ pseudoElementName += `(${pseudoIdentifier})`;
1714
+ }
1715
+ this.buildPseudoElementDOM(titleDOM, pseudoElementName);
1712
1716
  break;
1713
1717
  }
1714
1718
 
@@ -14,8 +14,7 @@ import {crumbsToRender} from './ElementsBreadcrumbsUtils.js';
14
14
  import type * as SDK from '../../../core/sdk/sdk.js';
15
15
  import type {DOMNode} from './Helper.js';
16
16
 
17
- import {NodeText} from './NodeText.js';
18
- import type {NodeTextData} from './NodeText.js';
17
+ import * as NodeText from '../../../ui/components/node_text/node_text.js';
19
18
 
20
19
  const UIStrings = {
21
20
  /**
@@ -300,11 +299,11 @@ export class ElementsBreadcrumbs extends HTMLElement {
300
299
  @mouseleave=${this.#onCrumbMouseLeave(crumb.node)}
301
300
  @focus=${this.#onCrumbFocus(crumb.node)}
302
301
  @blur=${this.#onCrumbBlur(crumb.node)}
303
- ><${NodeText.litTagName} data-node-title=${crumb.title.main} .data=${{
302
+ ><${NodeText.NodeText.NodeText.litTagName} data-node-title=${crumb.title.main} .data=${{
304
303
  nodeTitle: crumb.title.main,
305
304
  nodeId: crumb.title.extras.id,
306
305
  nodeClasses: crumb.title.extras.classes,
307
- } as NodeTextData}></${NodeText.litTagName}></a>
306
+ } as NodeText.NodeText.NodeTextData}></${NodeText.NodeText.NodeText.litTagName}></a>
308
307
  </li>`;
309
308
  })}
310
309
  </ul>
@@ -10,10 +10,9 @@ import * as LitHtml from '../../../ui/lit-html/lit-html.js';
10
10
  import type {BooleanSetting, EnumSetting, Setting} from './LayoutPaneUtils.js';
11
11
  import type {LayoutElement} from './LayoutPaneUtils.js';
12
12
 
13
- import type {NodeTextData} from './NodeText.js';
14
- import {NodeText} from './NodeText.js';
15
13
  import layoutPaneStyles from '../layoutPane.css.js';
16
14
  import * as Input from '../../../ui/components/input/input.js';
15
+ import * as NodeText from '../../../ui/components/node_text/node_text.js';
17
16
  // eslint-disable-next-line rulesdir/es_modules_import
18
17
  import inspectorCommonStyles from '../../../ui/legacy/inspectorCommon.css.js';
19
18
 
@@ -262,11 +261,11 @@ export class LayoutPane extends HTMLElement {
262
261
  <label data-element="true" class="checkbox-label">
263
262
  <input data-input="true" type="checkbox" .checked=${element.enabled} @change=${onElementToggle} />
264
263
  <span class="node-text-container" data-label="true" @mouseenter=${onMouseEnter} @mouseleave=${onMouseLeave}>
265
- <${NodeText.litTagName} .data=${{
264
+ <${NodeText.NodeText.NodeText.litTagName} .data=${{
266
265
  nodeId: element.domId,
267
266
  nodeTitle: element.name,
268
267
  nodeClasses: element.domClasses,
269
- } as NodeTextData}></${NodeText.litTagName}>
268
+ } as NodeText.NodeText.NodeTextData}></${NodeText.NodeText.NodeText.litTagName}>
270
269
  </span>
271
270
  </label>
272
271
  <label @keyup=${onColorLabelKeyUp} @keydown=${onColorLabelKeyDown} tabindex="0" title=${i18nString(UIStrings.chooseElementOverlayColor)} class="color-picker-label" style="background: ${element.color};">
@@ -5,11 +5,10 @@
5
5
  import * as SDK from '../../../core/sdk/sdk.js';
6
6
  import * as ComponentHelpers from '../../../ui/components/helpers/helpers.js';
7
7
  import * as IconButton from '../../../ui/components/icon_button/icon_button.js';
8
+ import * as NodeText from '../../../ui/components/node_text/node_text.js';
8
9
  import * as LitHtml from '../../../ui/lit-html/lit-html.js';
9
10
 
10
11
  import type {DOMNode} from './Helper.js';
11
- import {NodeText} from './NodeText.js';
12
- import type {NodeTextData} from './NodeText.js';
13
12
  import queryContainerStyles from './queryContainer.css.js';
14
13
 
15
14
  const {render, html} = LitHtml;
@@ -90,13 +89,13 @@ export class QueryContainer extends HTMLElement {
90
89
  @click=${this.#onContainerLinkClick}
91
90
  @mouseenter=${this.#onContainerLinkMouseEnter}
92
91
  @mouseleave=${this.#onContainerLinkMouseLeave}
93
- ><${NodeText.litTagName}
92
+ ><${NodeText.NodeText.NodeText.litTagName}
94
93
  data-node-title=${nodeTitle}
95
94
  .data=${{
96
95
  nodeTitle,
97
96
  nodeId: idToDisplay,
98
97
  nodeClasses: classesToDisplay,
99
- } as NodeTextData}></${NodeText.litTagName}></a>
98
+ } as NodeText.NodeText.NodeTextData}></${NodeText.NodeText.NodeText.litTagName}></a>
100
99
  ${this.#isContainerLinkHovered ? this.#renderQueriedSizeDetails() : LitHtml.nothing}
101
100
  `, this.#shadow, {
102
101
  host: this,
@@ -15,7 +15,6 @@ import * as ElementsPanelLink from './ElementsPanelLink.js';
15
15
  import * as Helper from './Helper.js';
16
16
  import * as LayoutPane from './LayoutPane.js';
17
17
  import * as LayoutPaneUtils from './LayoutPaneUtils.js';
18
- import * as NodeText from './NodeText.js';
19
18
  import * as QueryContainer from './QueryContainer.js';
20
19
  import * as StylePropertyEditor from './StylePropertyEditor.js';
21
20
 
@@ -33,7 +32,6 @@ export {
33
32
  Helper,
34
33
  LayoutPane,
35
34
  LayoutPaneUtils,
36
- NodeText,
37
35
  QueryContainer,
38
36
  StylePropertyEditor,
39
37
  };
@@ -18,7 +18,9 @@
18
18
  }
19
19
 
20
20
  .lighthouse-start-view-fr {
21
- margin: 24px;
21
+ padding: 24px;
22
+ overflow: auto;
23
+ height: 100%;
22
24
  }
23
25
 
24
26
  .lighthouse-start-view header {
@@ -28,12 +28,11 @@
28
28
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
29
  */
30
30
 
31
- import * as Common from '../../core/common/common.js';
31
+ import type * as Common from '../../core/common/common.js';
32
32
  import * as Host from '../../core/host/host.js';
33
33
  import * as i18n from '../../core/i18n/i18n.js';
34
34
  import * as SDK from '../../core/sdk/sdk.js';
35
35
  import * as Protocol from '../../generated/protocol.js';
36
- import * as Bindings from '../../models/bindings/bindings.js';
37
36
  import * as SourceMapScopes from '../../models/source_map_scopes/source_map_scopes.js';
38
37
  import * as LinearMemoryInspector from '../../ui/components/linear_memory_inspector/linear_memory_inspector.js';
39
38
  import * as ObjectUI from '../../ui/legacy/components/object_ui/object_ui.js';
@@ -76,10 +75,6 @@ const UIStrings = {
76
75
  *@description A context menu item in the Scope View of the Sources Panel
77
76
  */
78
77
  revealInMemoryInspectorPanel: 'Reveal in Memory Inspector panel',
79
- /**
80
- *@description Error message that shows up in the console if a buffer to be opened in the lienar memory inspector cannot be found.
81
- */
82
- couldNotOpenLinearMemory: 'Could not open linear memory inspector: failed locating buffer.',
83
78
  };
84
79
  const str_ = i18n.i18n.registerUIStrings('panels/sources/ScopeChainSidebarPane.ts', UIStrings);
85
80
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -310,24 +305,10 @@ export class OpenLinearMemoryInspector extends UI.Widget.VBox implements UI.Cont
310
305
  return openLinearMemoryInspectorInstance;
311
306
  }
312
307
 
313
- private isMemoryObjectProperty(obj: SDK.RemoteObject.RemoteObject): boolean {
314
- const isWasmOrBuffer = obj.type === 'object' && obj.subtype &&
315
- LinearMemoryInspector.LinearMemoryInspectorController.ACCEPTED_MEMORY_TYPES.includes(obj.subtype);
316
- if (isWasmOrBuffer) {
317
- return true;
318
- }
319
-
320
- const isWasmDWARF = obj instanceof Bindings.DebuggerLanguagePlugins.ValueNode;
321
- if (isWasmDWARF) {
322
- return obj.inspectableAddress !== undefined;
323
- }
324
-
325
- return false;
326
- }
327
-
328
308
  appendApplicableItems(event: Event, contextMenu: UI.ContextMenu.ContextMenu, target: Object): void {
329
309
  if (target instanceof ObjectUI.ObjectPropertiesSection.ObjectPropertyTreeElement) {
330
- if (target.property && target.property.value && this.isMemoryObjectProperty(target.property.value)) {
310
+ if (target.property && target.property.value &&
311
+ LinearMemoryInspector.LinearMemoryInspectorController.isMemoryObjectProperty(target.property.value)) {
331
312
  contextMenu.debugSection().appendItem(
332
313
  i18nString(UIStrings.revealInMemoryInspectorPanel),
333
314
  this.openMemoryInspector.bind(this, target.property.value));
@@ -337,26 +318,7 @@ export class OpenLinearMemoryInspector extends UI.Widget.VBox implements UI.Cont
337
318
 
338
319
  private async openMemoryInspector(obj: SDK.RemoteObject.RemoteObject): Promise<void> {
339
320
  const controller = LinearMemoryInspector.LinearMemoryInspectorController.LinearMemoryInspectorController.instance();
340
- let address = 0;
341
- let memoryObj: SDK.RemoteObject.RemoteObject = obj;
342
-
343
- if (obj instanceof Bindings.DebuggerLanguagePlugins.ValueNode) {
344
- const valueNode = obj;
345
- address = valueNode.inspectableAddress || 0;
346
- const callFrame = valueNode.callFrame;
347
- const response = await obj.debuggerModel().agent.invoke_evaluateOnCallFrame({
348
- callFrameId: callFrame.id,
349
- expression: 'memories[0]',
350
- });
351
- const error = response.getError();
352
- if (error) {
353
- console.error(error);
354
- Common.Console.Console.instance().error(i18nString(UIStrings.couldNotOpenLinearMemory));
355
- }
356
- const runtimeModel = obj.debuggerModel().runtimeModel();
357
- memoryObj = runtimeModel.createRemoteObject(response.result);
358
- }
359
321
  Host.userMetrics.linearMemoryInspectorRevealedFrom(Host.UserMetrics.LinearMemoryInspectorRevealedFrom.ContextMenu);
360
- void controller.openInspectorView(memoryObj, address);
322
+ void controller.openInspectorView(obj, 0);
361
323
  }
362
324
  }
@@ -4,6 +4,7 @@
4
4
 
5
5
  import * as Common from '../../../core/common/common.js';
6
6
  import * as Host from '../../../core/host/host.js';
7
+ import * as i18n from '../../../core/i18n/i18n.js';
7
8
  import * as SDK from '../../../core/sdk/sdk.js';
8
9
  import * as Protocol from '../../../generated/protocol.js';
9
10
  import * as UI from '../../legacy/legacy.js';
@@ -12,7 +13,17 @@ import type {Settings} from './LinearMemoryInspector.js';
12
13
  import {Events as LmiEvents, LinearMemoryInspectorPaneImpl} from './LinearMemoryInspectorPane.js';
13
14
  import type {ValueType, ValueTypeMode} from './ValueInterpreterDisplayUtils.js';
14
15
  import {Endianness, getDefaultValueTypeMapping} from './ValueInterpreterDisplayUtils.js';
16
+ import * as Bindings from '../../../models/bindings/bindings.js';
15
17
 
18
+ const UIStrings = {
19
+ /**
20
+ *@description Error message that shows up in the console if a buffer to be opened in the linear memory inspector cannot be found.
21
+ */
22
+ couldNotOpenLinearMemory: 'Could not open linear memory inspector: failed locating buffer.',
23
+ };
24
+ const str_ =
25
+ i18n.i18n.registerUIStrings('ui/components/linear_memory_inspector/LinearMemoryInspectorController.ts', UIStrings);
26
+ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
16
27
  const LINEAR_MEMORY_INSPECTOR_OBJECT_GROUP = 'linear-memory-inspector';
17
28
  const MEMORY_TRANSFER_MIN_CHUNK_SIZE = 1000;
18
29
  export const ACCEPTED_MEMORY_TYPES = ['webassemblymemory', 'typedarray', 'dataview', 'arraybuffer'];
@@ -66,6 +77,20 @@ async function getBufferFromObject(obj: SDK.RemoteObject.RemoteObject): Promise<
66
77
  return new SDK.RemoteObject.RemoteArrayBuffer(obj);
67
78
  }
68
79
 
80
+ export function isMemoryObjectProperty(obj: SDK.RemoteObject.RemoteObject): boolean {
81
+ const isWasmOrBuffer = obj.type === 'object' && obj.subtype && ACCEPTED_MEMORY_TYPES.includes(obj.subtype);
82
+ if (isWasmOrBuffer) {
83
+ return true;
84
+ }
85
+
86
+ const isWasmDWARF = obj instanceof Bindings.DebuggerLanguagePlugins.ValueNode;
87
+ if (isWasmDWARF) {
88
+ return obj.inspectableAddress !== undefined;
89
+ }
90
+
91
+ return false;
92
+ }
93
+
69
94
  type SerializableSettings = {
70
95
  valueTypes: ValueType[],
71
96
  valueTypeModes: [ValueType, ValueTypeMode][],
@@ -142,21 +167,52 @@ export class LinearMemoryInspectorController extends SDK.TargetManager.SDKModelO
142
167
  };
143
168
  }
144
169
 
170
+ static async retrieveDWARFMemoryObjectAndAddress(obj: SDK.RemoteObject.RemoteObject):
171
+ Promise<{obj: SDK.RemoteObject.RemoteObject, address: number}|undefined> {
172
+ if (!(obj instanceof Bindings.DebuggerLanguagePlugins.ValueNode)) {
173
+ return;
174
+ }
175
+
176
+ const valueNode = obj;
177
+ const address = valueNode.inspectableAddress || 0;
178
+ const callFrame = valueNode.callFrame;
179
+ const response = await obj.debuggerModel().agent.invoke_evaluateOnCallFrame({
180
+ callFrameId: callFrame.id,
181
+ expression: 'memories[0]',
182
+ });
183
+ const error = response.getError();
184
+ if (error) {
185
+ console.error(error);
186
+ Common.Console.Console.instance().error(i18nString(UIStrings.couldNotOpenLinearMemory));
187
+ }
188
+ const runtimeModel = obj.debuggerModel().runtimeModel();
189
+ obj = runtimeModel.createRemoteObject(response.result);
190
+ return {obj, address};
191
+ }
192
+
145
193
  async openInspectorView(obj: SDK.RemoteObject.RemoteObject, address?: number): Promise<void> {
146
- if (address !== undefined) {
194
+ const response = await LinearMemoryInspectorController.retrieveDWARFMemoryObjectAndAddress(obj);
195
+ let memoryObj = obj;
196
+ let memoryAddress = address;
197
+ if (response !== undefined) {
198
+ memoryAddress = response.address;
199
+ memoryObj = response.obj;
200
+ }
201
+
202
+ if (memoryAddress !== undefined) {
147
203
  Host.userMetrics.linearMemoryInspectorTarget(
148
204
  Host.UserMetrics.LinearMemoryInspectorTarget.DWARFInspectableAddress);
149
- } else if (obj.subtype === Protocol.Runtime.RemoteObjectSubtype.Arraybuffer) {
205
+ } else if (memoryObj.subtype === Protocol.Runtime.RemoteObjectSubtype.Arraybuffer) {
150
206
  Host.userMetrics.linearMemoryInspectorTarget(Host.UserMetrics.LinearMemoryInspectorTarget.ArrayBuffer);
151
- } else if (obj.subtype === Protocol.Runtime.RemoteObjectSubtype.Dataview) {
207
+ } else if (memoryObj.subtype === Protocol.Runtime.RemoteObjectSubtype.Dataview) {
152
208
  Host.userMetrics.linearMemoryInspectorTarget(Host.UserMetrics.LinearMemoryInspectorTarget.DataView);
153
- } else if (obj.subtype === Protocol.Runtime.RemoteObjectSubtype.Typedarray) {
209
+ } else if (memoryObj.subtype === Protocol.Runtime.RemoteObjectSubtype.Typedarray) {
154
210
  Host.userMetrics.linearMemoryInspectorTarget(Host.UserMetrics.LinearMemoryInspectorTarget.TypedArray);
155
211
  } else {
156
- console.assert(obj.subtype === Protocol.Runtime.RemoteObjectSubtype.Webassemblymemory);
212
+ console.assert(memoryObj.subtype === Protocol.Runtime.RemoteObjectSubtype.Webassemblymemory);
157
213
  Host.userMetrics.linearMemoryInspectorTarget(Host.UserMetrics.LinearMemoryInspectorTarget.WebAssemblyMemory);
158
214
  }
159
- const buffer = await getBufferFromObject(obj);
215
+ const buffer = await getBufferFromObject(memoryObj);
160
216
  const {internalProperties} = await buffer.object().getOwnProperties(false);
161
217
  const idProperty = internalProperties?.find(({name}) => name === '[[ArrayBufferData]]');
162
218
  const id = idProperty?.value?.value;
@@ -167,7 +223,7 @@ export class LinearMemoryInspectorController extends SDK.TargetManager.SDKModelO
167
223
  const memory = memoryProperty?.value;
168
224
 
169
225
  if (this.#bufferIdToRemoteObject.has(id)) {
170
- this.#paneInstance.reveal(id, address);
226
+ this.#paneInstance.reveal(id, memoryAddress);
171
227
  void UI.ViewManager.ViewManager.instance().showView('linear-memory-inspector');
172
228
  return;
173
229
  }
@@ -176,7 +232,7 @@ export class LinearMemoryInspectorController extends SDK.TargetManager.SDKModelO
176
232
  this.#bufferIdToRemoteObject.set(id, buffer.object());
177
233
  const arrayBufferWrapper = new RemoteArrayBufferWrapper(buffer);
178
234
 
179
- this.#paneInstance.create(id, title, arrayBufferWrapper, address);
235
+ this.#paneInstance.create(id, title, arrayBufferWrapper, memoryAddress);
180
236
  void UI.ViewManager.ViewManager.instance().showView('linear-memory-inspector');
181
237
  }
182
238
 
@@ -2,8 +2,9 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
- import * as ComponentHelpers from '../../../ui/components/helpers/helpers.js';
6
5
  import * as LitHtml from '../../../ui/lit-html/lit-html.js';
6
+ import * as ComponentHelpers from '../helpers/helpers.js';
7
+
7
8
  import nodeTextStyles from './nodeText.css.js';
8
9
 
9
10
  const {render, html} = LitHtml;
@@ -0,0 +1,9 @@
1
+ // Copyright 2021 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import * as NodeText from './NodeText.js';
6
+
7
+ export {
8
+ NodeText,
9
+ };
@@ -359,7 +359,7 @@ export class ObjectPropertiesSection extends UI.TreeOutline.TreeOutlineInShadow
359
359
  // TypedArrays DataViews are also supported, but showing the icon next to their
360
360
  // previews is quite a significant visual overhead, and users can easily get to
361
361
  // their buffers and open the memory inspector from there.
362
- if (obj.type !== 'object' || (obj.subtype !== 'arraybuffer' && obj.subtype !== 'webassemblymemory')) {
362
+ if (!LinearMemoryInspector.LinearMemoryInspectorController.isMemoryObjectProperty(obj)) {
363
363
  return;
364
364
  }
365
365
  const memoryIcon = new IconButton.Icon.Icon();
@@ -369,12 +369,15 @@ export class ObjectPropertiesSection extends UI.TreeOutline.TreeOutlineInShadow
369
369
  width: '13px',
370
370
  height: '13px',
371
371
  };
372
- memoryIcon.onclick = (event: MouseEvent): void => {
373
- Host.userMetrics.linearMemoryInspectorRevealedFrom(Host.UserMetrics.LinearMemoryInspectorRevealedFrom.MemoryIcon);
374
- void LinearMemoryInspector.LinearMemoryInspectorController.LinearMemoryInspectorController.instance()
375
- .openInspectorView(obj);
372
+
373
+ memoryIcon.onclick = async(event: MouseEvent): Promise<void> => {
376
374
  event.stopPropagation();
375
+ const controller =
376
+ LinearMemoryInspector.LinearMemoryInspectorController.LinearMemoryInspectorController.instance();
377
+ Host.userMetrics.linearMemoryInspectorRevealedFrom(Host.UserMetrics.LinearMemoryInspectorRevealedFrom.MemoryIcon);
378
+ void controller.openInspectorView(obj, 0);
377
379
  };
380
+
378
381
  UI.Tooltip.Tooltip.install(memoryIcon, 'Reveal in Memory Inspector panel');
379
382
  element.classList.add('object-value-with-memory-icon');
380
383
  element.appendChild(memoryIcon);
@@ -56,10 +56,7 @@
56
56
  display: inline-flex;
57
57
  }
58
58
 
59
- .object-value-arraybuffer devtools-icon,
60
- .object-value-dataview devtools-icon,
61
- .object-value-typedarray devtools-icon,
62
- .object-value-webassemblymemory devtools-icon {
59
+ .object-value-with-memory-icon > devtools-icon {
63
60
  cursor: pointer;
64
61
  }
65
62
 
package/package.json CHANGED
@@ -55,5 +55,5 @@
55
55
  "unittest": "scripts/test/run_unittests.py --no-text-coverage",
56
56
  "watch": "vpython third_party/node/node.py --output scripts/watch_build.js"
57
57
  },
58
- "version": "1.0.1014346"
58
+ "version": "1.0.1015658"
59
59
  }