Files
react-native-devtools-frontend/front_end/testing/LanguagePluginHelpers.ts
T
Benedikt Meurer 39e5133b95 [test] Introduce Platform.DevToolsPath.urlString helper.
This adds a helper function to avoid sprinkling casts to
`Platform.DevToolsPath.UrlString` all over our unit test
suite, combined with an ESLint rule to enforce that we
use this helper consistently.

This leads to much more readable test code for unit tests
that are concerned with APIs that take `UrlString`s, and
the code is more consistent.

Bug: 323797639
Change-Id: I6d797c0db9e5bd2fd019b83b9a7a269c7437ebdf
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6148578
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Danil Somsikov <dsv@chromium.org>
2025-01-07 05:49:23 -08:00

92 lines
2.8 KiB
TypeScript

// Copyright 2022 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 type {Chrome} from '../../extension-api/ExtensionAPI.js';
import * as Platform from '../core/platform/platform.js';
import type * as SDK from '../core/sdk/sdk.js';
import type * as Bindings from '../models/bindings/bindings.js';
const {urlString} = Platform.DevToolsPath;
export class TestPlugin implements Bindings.DebuggerLanguagePlugins.DebuggerLanguagePlugin {
constructor(name: string) {
this.name = name;
}
name: string;
handleScript(_script: SDK.Script.Script): boolean {
return false;
}
createPageResourceLoadInitiator(): SDK.PageResourceLoader.PageResourceLoadInitiator {
const extensionId = 'chrome-extension-id';
return {
target: null,
frameId: null,
extensionId,
initiatorUrl: urlString`${extensionId}`,
};
}
async evaluate(
_expression: string, _context: Chrome.DevTools.RawLocation,
_stopId: Bindings.DebuggerLanguagePlugins.StopId): Promise<Chrome.DevTools.RemoteObject|null> {
return null;
}
async getProperties(_objectId: string): Promise<Chrome.DevTools.PropertyDescriptor[]> {
return [];
}
async releaseObject(_objectId: string): Promise<void> {
}
async addRawModule(_rawModuleId: string, _symbolsURL: string, _rawModule: Chrome.DevTools.RawModule):
Promise<string[]> {
return [];
}
async sourceLocationToRawLocation(_sourceLocation: Chrome.DevTools.SourceLocation):
Promise<Chrome.DevTools.RawLocationRange[]> {
return [];
}
async rawLocationToSourceLocation(_rawLocation: Chrome.DevTools.RawLocation):
Promise<Chrome.DevTools.SourceLocation[]> {
return [];
}
async getScopeInfo(type: string): Promise<Chrome.DevTools.ScopeInfo> {
return {type, typeName: type};
}
async listVariablesInScope(_rawLocation: Chrome.DevTools.RawLocation): Promise<Chrome.DevTools.Variable[]> {
return [];
}
async removeRawModule(_rawModuleId: string): Promise<void> {
}
async getFunctionInfo(_rawLocation: Chrome.DevTools.RawLocation): Promise<{
frames: Array<Chrome.DevTools.FunctionInfo>,
missingSymbolFiles: Array<string>,
}|{frames: Array<Chrome.DevTools.FunctionInfo>}|{missingSymbolFiles: Array<string>}> {
return {frames: []};
}
async getInlinedFunctionRanges(_rawLocation: Chrome.DevTools.RawLocation):
Promise<Chrome.DevTools.RawLocationRange[]> {
return [];
}
async getInlinedCalleesRanges(_rawLocation: Chrome.DevTools.RawLocation):
Promise<Chrome.DevTools.RawLocationRange[]> {
return [];
}
async getMappedLines(_rawModuleId: string, _sourceFileURL: string): Promise<number[]|undefined> {
return undefined;
}
}