blob: def8c4cd274dafe94bd6afb4354f2ddbba22b4b8 [file] [log] [blame]
Danil Somsikov80b65292022-11-03 11:54:051// Copyright 2022 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
Benedikt Meurer39e51332025-01-07 13:17:545import * as Platform from '../core/platform/platform.js';
Benedikt Meurerd1f04bf2024-02-26 14:49:546import {assertNotNullOrUndefined} from '../core/platform/platform.js';
7import * as SDK from '../core/sdk/sdk.js';
8import type * as Protocol from '../generated/protocol.js';
Danil Somsikov80b65292022-11-03 11:54:059
Benedikt Meurer39e51332025-01-07 13:17:5410const {urlString} = Platform.DevToolsPath;
11
Danil Somsikov80b65292022-11-03 11:54:0512export class MockExecutionContext extends SDK.RuntimeModel.ExecutionContext {
13 constructor(target: SDK.Target.Target) {
14 const runtimeModel = target.model(SDK.RuntimeModel.RuntimeModel);
15 assertNotNullOrUndefined(runtimeModel);
Benedikt Meurer39e51332025-01-07 13:17:5416 super(runtimeModel, 1 as Protocol.Runtime.ExecutionContextId, 'test id', 'test name', urlString`test origin`, true);
Danil Somsikov80b65292022-11-03 11:54:0517 }
18
Nikolay Vitkovaa0af542025-04-11 12:48:2719 override async evaluate(_options: SDK.RuntimeModel.EvaluationOptions, userGesture: boolean, _awaitPromise: boolean):
Danil Somsikov80b65292022-11-03 11:54:0520 Promise<SDK.RuntimeModel.EvaluationResult> {
21 assert.isTrue(userGesture);
22 return {error: 'test'};
23 }
24}