chrome-devtools-frontend
Version:
Chrome DevTools UI
33 lines (25 loc) • 1.05 kB
text/typescript
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as LinearMemoryInspectorComponents from '../../../../panels/linear_memory_inspector/components/components.js';
import * as FrontendHelpers from '../../../../testing/EnvironmentHelpers.js';
import * as ComponentHelpers from '../../helpers/helpers.js';
await ComponentHelpers.ComponentServerSetup.setup();
await FrontendHelpers.initializeGlobalVars();
const array = [];
const string = 'Hello this is a string from the memory buffer!';
for (let i = 0; i < string.length; ++i) {
array.push(string.charCodeAt(i));
}
for (let i = -1000; i < 1000; ++i) {
array.push(i);
}
const memory = new Uint8Array(array);
const memoryInspector = new LinearMemoryInspectorComponents.LinearMemoryInspector.LinearMemoryInspector();
document.getElementById('container')?.appendChild(memoryInspector);
memoryInspector.data = {
memory,
address: 0,
memoryOffset: 0,
outerMemoryLength: memory.length,
};