test: enable queryObjects for bidi (#10964)

This commit is contained in:
Alex Rudenko 2023-09-21 10:49:30 +02:00 committed by GitHub
parent c505c85b31
commit 9cfc195794
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 11 deletions

View File

@ -10,7 +10,7 @@ This method iterates the JavaScript heap and finds all objects with the given pr
```typescript ```typescript
class Page { class Page {
queryObjects<Prototype>( abstract queryObjects<Prototype>(
prototypeHandle: JSHandle<Prototype> prototypeHandle: JSHandle<Prototype>
): Promise<JSHandle<Prototype[]>>; ): Promise<JSHandle<Prototype[]>>;
} }

View File

@ -1073,12 +1073,9 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @returns Promise which resolves to a handle to an array of objects with * @returns Promise which resolves to a handle to an array of objects with
* this prototype. * this prototype.
*/ */
async queryObjects<Prototype>( abstract queryObjects<Prototype>(
prototypeHandle: JSHandle<Prototype> prototypeHandle: JSHandle<Prototype>
): Promise<JSHandle<Prototype[]>>; ): Promise<JSHandle<Prototype[]>>;
async queryObjects<Prototype>(): Promise<JSHandle<Prototype[]>> {
throw new Error('Not implemented');
}
/** /**
* This method runs `document.querySelector` within the page and passes the * This method runs `document.querySelector` within the page and passes the

View File

@ -76,6 +76,7 @@ import {BidiFrame, lifeCycleToReadinessState} from './Frame.js';
import {type BidiHTTPRequest} from './HTTPRequest.js'; import {type BidiHTTPRequest} from './HTTPRequest.js';
import {type BidiHTTPResponse} from './HTTPResponse.js'; import {type BidiHTTPResponse} from './HTTPResponse.js';
import {BidiKeyboard, BidiMouse, BidiTouchscreen} from './Input.js'; import {BidiKeyboard, BidiMouse, BidiTouchscreen} from './Input.js';
import {type BidiJSHandle} from './JSHandle.js';
import {BidiNetworkManager} from './NetworkManager.js'; import {BidiNetworkManager} from './NetworkManager.js';
import {createBidiHandle} from './Realm.js'; import {createBidiHandle} from './Realm.js';
import {BidiSerializer} from './Serializer.js'; import {BidiSerializer} from './Serializer.js';
@ -219,6 +220,26 @@ export class BidiPage extends Page {
await this._client().send('Page.setBypassCSP', {enabled}); await this._client().send('Page.setBypassCSP', {enabled});
} }
override async queryObjects<Prototype>(
prototypeHandle: BidiJSHandle<Prototype>
): Promise<BidiJSHandle<Prototype[]>> {
assert(!prototypeHandle.disposed, 'Prototype JSHandle is disposed!');
assert(
prototypeHandle.id,
'Prototype JSHandle must not be referencing primitive value'
);
const response = await this.mainFrame().client.send(
'Runtime.queryObjects',
{
prototypeObjectId: prototypeHandle.id,
}
);
return createBidiHandle(this.mainFrame().mainRealm(), {
type: 'array',
handle: response.objects.objectId,
}) as BidiJSHandle<Prototype[]>;
}
_setBrowserContext(browserContext: BidiBrowserContext): void { _setBrowserContext(browserContext: BidiBrowserContext): void {
this.#browserContext = browserContext; this.#browserContext = browserContext;
} }

View File

@ -983,6 +983,12 @@
"parameters": ["webDriverBiDi"], "parameters": ["webDriverBiDi"],
"expectations": ["PASS"] "expectations": ["PASS"]
}, },
{
"testIdPattern": "[page.spec] Page ExecutionContext.queryObjects *",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
},
{ {
"testIdPattern": "[page.spec] Page Page.addScriptTag should throw when added with content to the CSP page", "testIdPattern": "[page.spec] Page Page.addScriptTag should throw when added with content to the CSP page",
"platforms": ["darwin", "linux", "win32"], "platforms": ["darwin", "linux", "win32"],
@ -3413,6 +3419,12 @@
"parameters": ["cdp", "firefox"], "parameters": ["cdp", "firefox"],
"expectations": ["FAIL"] "expectations": ["FAIL"]
}, },
{
"testIdPattern": "[page.spec] Page Page.setCacheEnabled should enable or disable the cache based on the state passed",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
},
{ {
"testIdPattern": "[page.spec] Page Page.setCacheEnabled should stay disabled when toggling request interception on/off", "testIdPattern": "[page.spec] Page Page.setCacheEnabled should stay disabled when toggling request interception on/off",
"platforms": ["darwin", "linux", "win32"], "platforms": ["darwin", "linux", "win32"],
@ -4084,11 +4096,5 @@
"platforms": ["darwin", "linux", "win32"], "platforms": ["darwin", "linux", "win32"],
"parameters": ["cdp", "chrome", "new-headless", "tabTarget"], "parameters": ["cdp", "chrome", "new-headless", "tabTarget"],
"expectations": ["FAIL"] "expectations": ["FAIL"]
},
{
"testIdPattern": "[page.spec] Page Page.setCacheEnabled should enable or disable the cache based on the state passed",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
} }
] ]