Skip to content

Commit 7011e57

Browse files
authored
chore(evaluate): explicitly annotate methods that wait for signals (#5859)
1 parent c550008 commit 7011e57

18 files changed

+117
-111
lines changed

src/dispatchers/electronDispatcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ export class ElectronApplicationDispatcher extends Dispatcher<ElectronApplicatio
5151

5252
async evaluateExpression(params: channels.ElectronApplicationEvaluateExpressionParams): Promise<channels.ElectronApplicationEvaluateExpressionResult> {
5353
const handle = this._object._nodeElectronHandle!;
54-
return { value: serializeResult(await handle._evaluateExpression(params.expression, params.isFunction, true /* returnByValue */, parseArgument(params.arg))) };
54+
return { value: serializeResult(await handle.evaluateExpression(params.expression, params.isFunction, true /* returnByValue */, parseArgument(params.arg))) };
5555
}
5656

5757
async evaluateExpressionHandle(params: channels.ElectronApplicationEvaluateExpressionHandleParams): Promise<channels.ElectronApplicationEvaluateExpressionHandleResult> {
5858
const handle = this._object._nodeElectronHandle!;
59-
const result = await handle._evaluateExpression(params.expression, params.isFunction, false /* returnByValue */, parseArgument(params.arg));
59+
const result = await handle.evaluateExpression(params.expression, params.isFunction, false /* returnByValue */, parseArgument(params.arg));
6060
return { handle: createHandle(this._scope, result) };
6161
}
6262

src/dispatchers/elementHandlerDispatcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ export class ElementHandleDispatcher extends JSHandleDispatcher implements chann
171171
}
172172

173173
async evalOnSelector(params: channels.ElementHandleEvalOnSelectorParams, metadata: CallMetadata): Promise<channels.ElementHandleEvalOnSelectorResult> {
174-
return { value: serializeResult(await this._elementHandle._$evalExpression(params.selector, params.expression, params.isFunction, parseArgument(params.arg))) };
174+
return { value: serializeResult(await this._elementHandle.$evalExpression(params.selector, params.expression, params.isFunction, parseArgument(params.arg))) };
175175
}
176176

177177
async evalOnSelectorAll(params: channels.ElementHandleEvalOnSelectorAllParams, metadata: CallMetadata): Promise<channels.ElementHandleEvalOnSelectorAllResult> {
178-
return { value: serializeResult(await this._elementHandle._$$evalExpression(params.selector, params.expression, params.isFunction, parseArgument(params.arg))) };
178+
return { value: serializeResult(await this._elementHandle.$$evalExpression(params.selector, params.expression, params.isFunction, parseArgument(params.arg))) };
179179
}
180180

181181
async waitForElementState(params: channels.ElementHandleWaitForElementStateParams, metadata: CallMetadata): Promise<void> {

src/dispatchers/frameDispatcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ export class FrameDispatcher extends Dispatcher<Frame, channels.FrameInitializer
6161
}
6262

6363
async evaluateExpression(params: channels.FrameEvaluateExpressionParams, metadata: CallMetadata): Promise<channels.FrameEvaluateExpressionResult> {
64-
return { value: serializeResult(await this._frame._evaluateExpression(params.expression, params.isFunction, parseArgument(params.arg), params.world)) };
64+
return { value: serializeResult(await this._frame.evaluateExpressionAndWaitForSignals(params.expression, params.isFunction, parseArgument(params.arg), params.world)) };
6565
}
6666

6767
async evaluateExpressionHandle(params: channels.FrameEvaluateExpressionHandleParams, metadata: CallMetadata): Promise<channels.FrameEvaluateExpressionHandleResult> {
68-
return { handle: createHandle(this._scope, await this._frame._evaluateExpressionHandle(params.expression, params.isFunction, parseArgument(params.arg), params.world)) };
68+
return { handle: createHandle(this._scope, await this._frame.evaluateExpressionHandleAndWaitForSignals(params.expression, params.isFunction, parseArgument(params.arg), params.world)) };
6969
}
7070

7171
async waitForSelector(params: channels.FrameWaitForSelectorParams, metadata: CallMetadata): Promise<channels.FrameWaitForSelectorResult> {

src/dispatchers/jsHandleDispatcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ export class JSHandleDispatcher extends Dispatcher<js.JSHandle, channels.JSHandl
3131
}
3232

3333
async evaluateExpression(params: channels.JSHandleEvaluateExpressionParams): Promise<channels.JSHandleEvaluateExpressionResult> {
34-
return { value: serializeResult(await this._object._evaluateExpression(params.expression, params.isFunction, true /* returnByValue */, parseArgument(params.arg))) };
34+
return { value: serializeResult(await this._object.evaluateExpression(params.expression, params.isFunction, true /* returnByValue */, parseArgument(params.arg))) };
3535
}
3636

3737
async evaluateExpressionHandle(params: channels.JSHandleEvaluateExpressionHandleParams): Promise<channels.JSHandleEvaluateExpressionHandleResult> {
38-
const jsHandle = await this._object._evaluateExpression(params.expression, params.isFunction, false /* returnByValue */, parseArgument(params.arg));
38+
const jsHandle = await this._object.evaluateExpression(params.expression, params.isFunction, false /* returnByValue */, parseArgument(params.arg));
3939
return { handle: createHandle(this._scope, jsHandle) };
4040
}
4141

src/server/browserContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export abstract class BrowserContext extends SdkObject {
316316
const originStorage: types.OriginStorage = { origin, localStorage: [] };
317317
const frame = page.mainFrame();
318318
await frame.goto(internalMetadata, origin);
319-
const storage = await frame._evaluateExpression(`({
319+
const storage = await frame.evaluateExpression(`({
320320
localStorage: Object.keys(localStorage).map(name => ({ name, value: localStorage.getItem(name) })),
321321
})`, false, undefined, 'utility');
322322
originStorage.localStorage = storage.localStorage;
@@ -340,7 +340,7 @@ export abstract class BrowserContext extends SdkObject {
340340
for (const originState of state.origins) {
341341
const frame = page.mainFrame();
342342
await frame.goto(metadata, originState.origin);
343-
await frame._evaluateExpression(`
343+
await frame.evaluateExpression(`
344344
originState => {
345345
for (const { name, value } of (originState.localStorage || []))
346346
localStorage.setItem(name, value);

src/server/chromium/crPage.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class CRPage implements PageDelegate {
143143

144144
async exposeBinding(binding: PageBinding) {
145145
await this._forAllFrameSessions(frame => frame._initBinding(binding));
146-
await Promise.all(this._page.frames().map(frame => frame._evaluateExpression(binding.source, false, {}, binding.world).catch(e => {})));
146+
await Promise.all(this._page.frames().map(frame => frame.evaluateExpression(binding.source, false, {}, binding.world).catch(e => {})));
147147
}
148148

149149
async updateExtraHTTPHeaders(): Promise<void> {
@@ -284,7 +284,7 @@ export class CRPage implements PageDelegate {
284284
}
285285

286286
async setInputFiles(handle: dom.ElementHandle<HTMLInputElement>, files: types.FilePayload[]): Promise<void> {
287-
await handle._evaluateInUtility(([injected, node, files]) =>
287+
await handle.evaluateInUtility(([injected, node, files]) =>
288288
injected.setInputFiles(node, files), files);
289289
}
290290

@@ -421,9 +421,9 @@ class FrameSession {
421421
worldName: UTILITY_WORLD_NAME,
422422
});
423423
for (const binding of this._crPage._browserContext._pageBindings.values())
424-
frame._evaluateExpression(binding.source, false, undefined, binding.world).catch(e => {});
424+
frame.evaluateExpression(binding.source, false, undefined, binding.world).catch(e => {});
425425
for (const source of this._crPage._browserContext._evaluateOnNewDocumentSources)
426-
frame._evaluateExpression(source, false, undefined, 'main').catch(e => {});
426+
frame.evaluateExpression(source, false, undefined, 'main').catch(e => {});
427427
}
428428
const isInitialEmptyPage = this._isMainFrame() && this._page.mainFrame().url() === ':';
429429
if (isInitialEmptyPage) {

0 commit comments

Comments
 (0)