Files
react-native-devtools-frontend/front_end/testing/test_setup.ts
T
Andrés Olivares 092b0f0940 [RPP] Store code location source mappings
Just as we are doing with function names, this CL adds support to store
existing code location mappings (i.e. script url, line and column
numbers) whenever we detect that a source map has been attached in
devtools.

The SourceMapResolve is modified to store code locations in addition to function names. Also, instead of key-ing by profile node id, now we key based on code location, so that we can make use of the helper for  trace events with code location that are not profile calls.

With this in place, we can more accurately represent source locations in
all places in terms of the authored code. For example, when evaluating
if an entry's location is in the user ignore list we can first resolve
the corresponding authored code and then determine if it's ignore
listed (which this CL also does). This is consistent with what the
debugger does and with what devs expect in general.

In a follow up, I'll use mapped urls in more places in the Performance panel.

Fixed: 358572661
Change-Id: I232f83bf0de22c244e14f09e7c3013731070f8d6
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5882655
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Andres Olivares <andoli@chromium.org>
2024-09-26 11:56:51 +00:00

50 lines
1.9 KiB
TypeScript

// Copyright 2020 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.
/*
* This file is automatically loaded and run by Karma because it automatically
* loads and injects all *.js files it finds.
*/
import * as Common from '../core/common/common.js';
import * as Host from '../core/host/host.js';
import * as Trace from '../models/trace/trace.js';
import * as Timeline from '../panels/timeline/timeline.js';
import * as ThemeSupport from '../ui/legacy/theme_support/theme_support.js';
import {resetTestDOM} from './DOMHelpers.js';
import {createFakeSetting} from './EnvironmentHelpers.js';
import {
checkForPendingActivity,
startTrackingAsyncActivity,
stopTrackingAsyncActivity,
} from './TrackAsyncOperations.js';
beforeEach(() => {
resetTestDOM();
// Ensure that no trace data leaks between tests when testing the trace engine.
for (const handler of Object.values(Trace.Handlers.ModelHandlers)) {
handler.reset();
}
Trace.Helpers.SyntheticEvents.SyntheticEventsManager.reset();
Timeline.Utils.SourceMapsResolver.SourceMapsResolver.clearResolvedNodeNames();
// Don't retain host binding listeners across tests. Set this up before initializing ThemeSupport as
// ThemeSupport adds a host binding listener.
Host.InspectorFrontendHost.InspectorFrontendHostInstance.events = new Common.ObjectWrapper.ObjectWrapper();
// Some unit tests exercise code that assumes a ThemeSupport instance is available.
// Run this in a beforeEach in case an individual test overrides it.
const setting = createFakeSetting('theme', 'default');
ThemeSupport.ThemeSupport.instance({forceNew: true, setting});
startTrackingAsyncActivity();
});
afterEach(async () => {
await checkForPendingActivity();
sinon.restore();
stopTrackingAsyncActivity();
// Clear out any Sinon stubs or spies between individual tests.
});