chrome-devtools-frontend
Version:
Chrome DevTools UI
60 lines (49 loc) • 2.28 kB
text/typescript
// Copyright 2023 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {assert} from 'chai';
import {
addBreakpointForLine,
openFileInEditor,
PAUSE_INDICATOR_SELECTOR,
} from 'test/e2e/helpers/sources-helpers';
import {
click,
getBrowserAndPages,
getPendingEvents,
installEventListener,
waitFor,
waitForFunction,
waitForMany,
} from 'test/shared/helper.js';
import {
openTestSuiteResourceInSourcesPanel,
} from '../cxx-debugging-extension-helpers.js';
describe('LinearMemoryInspector', () => {
it('can show variables', async () => {
const {target, frontend} = getBrowserAndPages();
const test =
'extensions/cxx_debugging/e2e/resources/scope-view-primitives__Scope_view_formats_primitive_types_correctly_0.html';
await openTestSuiteResourceInSourcesPanel(test);
await installEventListener(frontend, 'DevTools.DebuggerPaused');
const file = 'scope-view-primitives.c';
const breakpoint = 14;
await openFileInEditor(file);
await addBreakpointForLine(Number(breakpoint));
await target.reload();
await waitForFunction(async () => ((await getPendingEvents(frontend, 'DevTools.DebuggerPaused')) || []).length > 0);
const stopped = await waitFor(PAUSE_INDICATOR_SELECTOR);
const stoppedText = await waitForFunction(async () => await stopped.evaluate(node => node.textContent));
assert.strictEqual(stoppedText, 'Paused on breakpoint');
const localVariable = await waitFor('[data-object-property-name-for-test="d"]');
await click('[title="Open in Memory inspector panel"]', {
root: localVariable,
});
const byteHighlights = await waitForMany('.byte-cell.highlight-area', 8);
const byteHighlightText = await Promise.all(byteHighlights.map(cell => cell.evaluate(cell => cell.textContent)));
assert.deepEqual(byteHighlightText, ['33', '33', '33', '33', '33', '33', 'F3', '3F']);
const valueHighlights = await waitForMany('.text-cell.highlight-area', 8);
const valueHighlightText = await Promise.all(valueHighlights.map(cell => cell.evaluate(cell => cell.textContent)));
assert.deepEqual(valueHighlightText, ['3', '3', '3', '3', '3', '3', '.', '?']);
});
});