Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: remove page.queryObjects API (#31)
Pavel Feldman48a78b2c8a96
diff --git a/docs/api.md b/docs/api.mdindex 3453af073c..b7317c2891 100644--- a/docs/api.md+++ b/docs/api.md@@ -117,7 +117,6 @@* [page.mainFrame()](#pagemainframe)* [page.mouse](#pagemouse)* [page.pdf](#pagepdf)- * [page.queryObjects(prototypeHandle)](#pagequeryobjectsprototypehandle)* [page.reload([options])](#pagereloadoptions)* [page.screenshot([options])](#pagescreenshotoptions)* [page.select(selector, ...values)](#pageselectselector-values)@@ -236,7 +235,6 @@* [executionContext.evaluate(pageFunction[, ...args])](#executioncontextevaluatepagefunction-args)* [executionContext.evaluateHandle(pageFunction[, ...args])](#executioncontextevaluatehandlepagefunction-args)* [executionContext.frame()](#executioncontextframe)- * [executionContext.queryObjects(prototypeHandle)](#executioncontextqueryobjectsprototypehandle)- [class: JSHandle](#class-jshandle)* [jsHandle.asElement()](#jshandleaselement)* [jsHandle.dispose()](#jshandledispose)@@ -1624,27 +1622,6 @@ Page is guaranteed to have a main frame which persists during navigations.#### page.pdf- returns: <[PDF]>-#### page.queryObjects(prototypeHandle)-- `prototypeHandle` <[JSHandle]> A handle to the object prototype.-- returns: <[Promise]<[JSHandle]>> Promise which resolves to a handle to an array of objects with this prototype.--The method iterates the JavaScript heap and finds all the objects with the given prototype.--```js-// Create a Map object-await page.evaluate(() => window.map = new Map());-// Get a handle to the Map object prototype-const mapPrototype = await page.evaluateHandle(() => Map.prototype);-// Query all map instances into an array-const mapInstances = await page.queryObjects(mapPrototype);-// Count amount of map objects in heap-const count = await page.evaluate(maps => maps.length, mapInstances);-await mapInstances.dispose();-await mapPrototype.dispose();-```--Shortcut for [page.mainFrame().executionContext().queryObjects(prototypeHandle)](#executioncontextqueryobjectsprototypehandle).-#### page.reload([options])- `options` <[Object]> Navigation parameters which might have the following properties:- `timeout` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.@@ -3222,26 +3199,6 @@ await resultHandle.dispose();> **NOTE** Not every execution context is associated with a frame. For example, workers and extensions have execution contexts that are not associated with frames.--#### executionContext.queryObjects(prototypeHandle)-- `prototypeHandle` <[JSHandle]> A handle to the object prototype.-- returns: <[Promise]<[JSHandle]>> A handle to an array of objects with this prototype--The method iterates the JavaScript heap and finds all the objects with the given prototype.--```js-// Create a Map object-await page.evaluate(() => window.map = new Map());-// Get a handle to the Map object prototype-const mapPrototype = await page.evaluateHandle(() => Map.prototype);-// Query all map instances into an array-const mapInstances = await page.queryObjects(mapPrototype);-// Count amount of map objects in heap-const count = await page.evaluate(maps => maps.length, mapInstances);-await mapInstances.dispose();-await mapPrototype.dispose();-```-### class: JSHandleJSHandle represents an in-page JavaScript object. JSHandles can be created with the [page.evaluateHandle](#pageevaluatehandlepagefunction-args) method.diff --git a/src/chromium/ExecutionContext.ts b/src/chromium/ExecutionContext.tsindex be711fb164..a3bad49c41 100644--- a/src/chromium/ExecutionContext.ts+++ b/src/chromium/ExecutionContext.ts@@ -147,15 +147,6 @@ export class ExecutionContext {}}- async queryObjects(prototypeHandle: JSHandle): Promise<JSHandle> {- assert(!prototypeHandle._disposed, 'Prototype JSHandle is disposed!');- assert(prototypeHandle._remoteObject.objectId, 'Prototype JSHandle must not be referencing primitive value');- const response = await this._client.send('Runtime.queryObjects', {- prototypeObjectId: prototypeHandle._remoteObject.objectId- });- return createJSHandle(this, response.objects);- }-async _adoptElementHandle(elementHandle: ElementHandle): Promise<ElementHandle> {assert(elementHandle.executionContext() !== this, 'Cannot adopt handle that already belongs to this execution context');assert(this._world, 'Cannot adopt handle without DOMWorld');diff --git a/src/chromium/Page.ts b/src/chromium/Page.tsindex 91820a45c6..320890f9bd 100644--- a/src/chromium/Page.ts+++ b/src/chromium/Page.ts@@ -252,11 +252,6 @@ export class Page extends EventEmitter {return context.evaluateHandle(pageFunction, ...args);}- async queryObjects(prototypeHandle: JSHandle): Promise<JSHandle> {- const context = await this.mainFrame().executionContext();- return context.queryObjects(prototypeHandle);- }-async $eval(selector: string, pageFunction: Function | string, ...args: any[]): Promise<(object | undefined)> {return this.mainFrame().$eval(selector, pageFunction, ...args);}diff --git a/test/page.spec.js b/test/page.spec.jsindex 99af44e4c6..2bd8e87cad 100644--- a/test/page.spec.js+++ b/test/page.spec.js@@ -284,41 +284,6 @@ module.exports.addTests = function({testRunner, expect, headless, playwright, FF});});- describe.skip(FFOX || WEBKIT)('ExecutionContext.queryObjects', function() {- it('should work', async({page, server}) => {- // Instantiate an object- await page.evaluate(() => window.set = new Set(['hello', 'world']));- const prototypeHandle = await page.evaluateHandle(() => Set.prototype);- const objectsHandle = await page.queryObjects(prototypeHandle);- const count = await page.evaluate(objects => objects.length, objectsHandle);- expect(count).toBe(1);- const values = await page.evaluate(objects => Array.from(objects[0].values()), objectsHandle);- expect(values).toEqual(['hello', 'world']);- });- it('should work for non-blank page', async({page, server}) => {- // Instantiate an object- await page.goto(server.EMPTY_PAGE);- await page.evaluate(() => window.set = new Set(['hello', 'world']));- const prototypeHandle = await page.evaluateHandle(() => Set.prototype);- const objectsHandle = await page.queryObjects(prototypeHandle);- const count = await page.evaluate(objects => objects.length, objectsHandle);- expect(count).toBe(1);- });- it('should fail for disposed handles', async({page, server}) => {- const prototypeHandle = await page.evaluateHandle(() => HTMLBodyElement.prototype);- await prototypeHandle.dispose();- let error = null;- await page.queryObjects(prototypeHandle).catch(e => error = e);- expect(error.message).toBe('Prototype JSHandle is disposed!');- });- it('should fail primitive values as prototypes', async({page, server}) => {- const prototypeHandle = await page.evaluateHandle(() => 42);- let error = null;- await page.queryObjects(prototypeHandle).catch(e => error = e);- expect(error.message).toBe('Prototype JSHandle must not be referencing primitive value');- });- });-describe('Page.Events.Console', function() {it('should work', async({page, server}) => {let message = null;