From 4bf2a09a13450c530b24288d65791fd5c4d4dce7 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Mon, 13 Nov 2023 13:27:17 +0100 Subject: [PATCH] fix: mitt types should not be exported (#11371) --- docs/api/index.md | 1 + docs/api/puppeteer.browsercontextevents.md | 2 +- docs/api/puppeteer.browserevents.md | 2 +- docs/api/puppeteer.cdpsessionevents.md | 2 +- docs/api/puppeteer.eventswithwildcard.md | 2 + docs/api/puppeteer.eventtype.md | 11 ++ docs/api/puppeteer.frameevents.md | 2 +- docs/api/puppeteer.locatorevents.md | 2 +- docs/api/puppeteer.pageevents.md | 2 +- docs/api/puppeteer.webworker.md | 2 +- .../src/api/locators/locators.ts | 2 +- .../puppeteer-core/src/common/EventEmitter.ts | 11 +- test/TestExpectations.json | 149 +++++++++--------- 13 files changed, 100 insertions(+), 90 deletions(-) create mode 100644 docs/api/puppeteer.eventtype.md diff --git a/docs/api/index.md b/docs/api/index.md index 21bb1ad2..31d987e8 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -178,6 +178,7 @@ sidebar_label: API | [EvaluateFunc](./puppeteer.evaluatefunc.md) | | | [EvaluateFuncWith](./puppeteer.evaluatefuncwith.md) | | | [EventsWithWildcard](./puppeteer.eventswithwildcard.md) | | +| [EventType](./puppeteer.eventtype.md) | | | [ExperimentsConfiguration](./puppeteer.experimentsconfiguration.md) |

Defines experiment options for Puppeteer.

See individual properties for more information.

| | [FlattenHandle](./puppeteer.flattenhandle.md) | | | [HandleFor](./puppeteer.handlefor.md) | | diff --git a/docs/api/puppeteer.browsercontextevents.md b/docs/api/puppeteer.browsercontextevents.md index 92dee37e..4f2c6d8c 100644 --- a/docs/api/puppeteer.browsercontextevents.md +++ b/docs/api/puppeteer.browsercontextevents.md @@ -10,7 +10,7 @@ sidebar_label: BrowserContextEvents export interface BrowserContextEvents extends Record ``` -**Extends:** Record<EventType, unknown> +**Extends:** Record<[EventType](./puppeteer.eventtype.md), unknown> ## Properties diff --git a/docs/api/puppeteer.browserevents.md b/docs/api/puppeteer.browserevents.md index e1789dfe..734340f7 100644 --- a/docs/api/puppeteer.browserevents.md +++ b/docs/api/puppeteer.browserevents.md @@ -10,7 +10,7 @@ sidebar_label: BrowserEvents export interface BrowserEvents extends Record ``` -**Extends:** Record<EventType, unknown> +**Extends:** Record<[EventType](./puppeteer.eventtype.md), unknown> ## Properties diff --git a/docs/api/puppeteer.cdpsessionevents.md b/docs/api/puppeteer.cdpsessionevents.md index 6804162c..87ae0f53 100644 --- a/docs/api/puppeteer.cdpsessionevents.md +++ b/docs/api/puppeteer.cdpsessionevents.md @@ -10,7 +10,7 @@ sidebar_label: CDPSessionEvents export interface CDPSessionEvents extends CDPEvents, Record ``` -**Extends:** [CDPEvents](./puppeteer.cdpevents.md), Record<EventType, unknown> +**Extends:** [CDPEvents](./puppeteer.cdpevents.md), Record<[EventType](./puppeteer.eventtype.md), unknown> ## Properties diff --git a/docs/api/puppeteer.eventswithwildcard.md b/docs/api/puppeteer.eventswithwildcard.md index 5a285f4a..592cd4f2 100644 --- a/docs/api/puppeteer.eventswithwildcard.md +++ b/docs/api/puppeteer.eventswithwildcard.md @@ -12,3 +12,5 @@ export type EventsWithWildcard> = '*': Events[keyof Events]; }; ``` + +**References:** [EventType](./puppeteer.eventtype.md) diff --git a/docs/api/puppeteer.eventtype.md b/docs/api/puppeteer.eventtype.md new file mode 100644 index 00000000..db529a6a --- /dev/null +++ b/docs/api/puppeteer.eventtype.md @@ -0,0 +1,11 @@ +--- +sidebar_label: EventType +--- + +# EventType type + +#### Signature: + +```typescript +export type EventType = string | symbol; +``` diff --git a/docs/api/puppeteer.frameevents.md b/docs/api/puppeteer.frameevents.md index 6ee8d30a..0628eb09 100644 --- a/docs/api/puppeteer.frameevents.md +++ b/docs/api/puppeteer.frameevents.md @@ -10,4 +10,4 @@ sidebar_label: FrameEvents export interface FrameEvents extends Record ``` -**Extends:** Record<EventType, unknown> +**Extends:** Record<[EventType](./puppeteer.eventtype.md), unknown> diff --git a/docs/api/puppeteer.locatorevents.md b/docs/api/puppeteer.locatorevents.md index 585a5971..ec142d99 100644 --- a/docs/api/puppeteer.locatorevents.md +++ b/docs/api/puppeteer.locatorevents.md @@ -10,7 +10,7 @@ sidebar_label: LocatorEvents export interface LocatorEvents extends Record ``` -**Extends:** Record<EventType, unknown> +**Extends:** Record<[EventType](./puppeteer.eventtype.md), unknown> ## Properties diff --git a/docs/api/puppeteer.pageevents.md b/docs/api/puppeteer.pageevents.md index d6ebc325..14835709 100644 --- a/docs/api/puppeteer.pageevents.md +++ b/docs/api/puppeteer.pageevents.md @@ -14,7 +14,7 @@ See [PageEvent](./puppeteer.pageevent.md) for more detail on the events and when export interface PageEvents extends Record ``` -**Extends:** Record<EventType, unknown> +**Extends:** Record<[EventType](./puppeteer.eventtype.md), unknown> ## Properties diff --git a/docs/api/puppeteer.webworker.md b/docs/api/puppeteer.webworker.md index 84c1dfb5..8991a223 100644 --- a/docs/api/puppeteer.webworker.md +++ b/docs/api/puppeteer.webworker.md @@ -12,7 +12,7 @@ This class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web export declare class WebWorker extends EventEmitter> ``` -**Extends:** [EventEmitter](./puppeteer.eventemitter.md)<Record<EventType, unknown>> +**Extends:** [EventEmitter](./puppeteer.eventemitter.md)<Record<[EventType](./puppeteer.eventtype.md), unknown>> ## Remarks diff --git a/packages/puppeteer-core/src/api/locators/locators.ts b/packages/puppeteer-core/src/api/locators/locators.ts index a504f007..2faae118 100644 --- a/packages/puppeteer-core/src/api/locators/locators.ts +++ b/packages/puppeteer-core/src/api/locators/locators.ts @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import type {EventType} from '../../../third_party/mitt/mitt.js'; import type { Observable, OperatorFunction, @@ -41,6 +40,7 @@ import { raceWith, tap, } from '../../../third_party/rxjs/rxjs.js'; +import type {EventType} from '../../common/EventEmitter.js'; import {EventEmitter} from '../../common/EventEmitter.js'; import type {Awaitable, HandleFor, NodeFor} from '../../common/types.js'; import {debugError, timeout} from '../../common/util.js'; diff --git a/packages/puppeteer-core/src/common/EventEmitter.ts b/packages/puppeteer-core/src/common/EventEmitter.ts index fbf259ec..802e55e8 100644 --- a/packages/puppeteer-core/src/common/EventEmitter.ts +++ b/packages/puppeteer-core/src/common/EventEmitter.ts @@ -17,16 +17,13 @@ import mitt, { type Emitter, type EventHandlerMap, - type EventType, } from '../../third_party/mitt/mitt.js'; import {disposeSymbol} from '../util/disposable.js'; -export type { - /** - * @public - */ - EventType, -} from '../../third_party/mitt/mitt.js'; +/** + * @public + */ +export type EventType = string | symbol; /** * @public diff --git a/test/TestExpectations.json b/test/TestExpectations.json index 31220939..f9ffc042 100644 --- a/test/TestExpectations.json +++ b/test/TestExpectations.json @@ -371,6 +371,12 @@ "parameters": ["webDriverBiDi"], "expectations": ["PASS"] }, + { + "testIdPattern": "[ariaqueryhandler.spec] AriaQueryHandler waitForSelector (aria) should throw when frame is detached", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["webDriverBiDi"], + "expectations": ["PASS"] + }, { "testIdPattern": "[autofill.spec] *", "platforms": ["darwin", "linux", "win32"], @@ -845,6 +851,54 @@ "parameters": ["cdp", "firefox"], "expectations": ["SKIP"] }, + { + "testIdPattern": "[oopif.spec] OOPIF clickablePoint, boundingBox, boxModel should work for elements inside OOPIFs", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["webDriverBiDi"], + "expectations": ["PASS"] + }, + { + "testIdPattern": "[oopif.spec] OOPIF should provide access to elements", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["webDriverBiDi"], + "expectations": ["PASS"] + }, + { + "testIdPattern": "[oopif.spec] OOPIF should support evaluating in oop iframes", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["webDriverBiDi"], + "expectations": ["PASS"] + }, + { + "testIdPattern": "[oopif.spec] OOPIF should support frames within OOP frames", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["webDriverBiDi"], + "expectations": ["PASS"] + }, + { + "testIdPattern": "[oopif.spec] OOPIF should support frames within OOP iframes", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["webDriverBiDi"], + "expectations": ["PASS"] + }, + { + "testIdPattern": "[oopif.spec] OOPIF should track navigations within OOP iframes", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["webDriverBiDi"], + "expectations": ["PASS"] + }, + { + "testIdPattern": "[oopif.spec] OOPIF should treat OOP iframes and normal iframes the same", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["webDriverBiDi"], + "expectations": ["PASS"] + }, + { + "testIdPattern": "[oopif.spec] OOPIF waitForFrame should resolve immediately if the frame already exists", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["webDriverBiDi"], + "expectations": ["PASS"] + }, { "testIdPattern": "[page.spec] Page BrowserContext.overridePermissions should be prompt by default", "platforms": ["darwin", "linux", "win32"], @@ -971,6 +1025,12 @@ "parameters": ["webDriverBiDi"], "expectations": ["PASS"] }, + { + "testIdPattern": "[page.spec] Page Page.setUserAgent *", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["chrome", "webDriverBiDi"], + "expectations": ["PASS"] + }, { "testIdPattern": "[page.spec] Page Page.title should return the page title", "platforms": ["darwin", "linux", "win32"], @@ -1157,6 +1217,18 @@ "parameters": ["webDriverBiDi"], "expectations": ["PASS"] }, + { + "testIdPattern": "[target.spec] Target should report when a new page is created and closed", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["webDriverBiDi"], + "expectations": ["PASS"] + }, + { + "testIdPattern": "[target.spec] Target should report when a target url changes", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["webDriverBiDi"], + "expectations": ["PASS"] + }, { "testIdPattern": "[TargetManager.spec] *", "platforms": ["darwin", "linux", "win32"], @@ -1241,12 +1313,6 @@ "parameters": ["chrome", "webDriverBiDi"], "expectations": ["PASS"] }, - { - "testIdPattern": "[ariaqueryhandler.spec] AriaQueryHandler waitForSelector (aria) should throw when frame is detached", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, { "testIdPattern": "[bfcache.spec] BFCache can navigate to a BFCached page containing an OOPIF and a worker", "platforms": ["darwin", "linux", "win32"], @@ -2682,34 +2748,9 @@ "expectations": ["FAIL"] }, { - "testIdPattern": "[oopif.spec] OOPIF clickablePoint, boundingBox, boxModel should work for elements inside OOPIFs", + "testIdPattern": "[oopif.spec] OOPIF should keep track of a frames OOP state", "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - - { - "testIdPattern": "[oopif.spec] OOPIF should provide access to elements", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[oopif.spec] OOPIF should support evaluating in oop iframes", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[oopif.spec] OOPIF should support frames within OOP frames", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[oopif.spec] OOPIF should support frames within OOP iframes", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], + "parameters": ["firefox", "webDriverBiDi"], "expectations": ["PASS"] }, { @@ -2724,24 +2765,6 @@ "parameters": ["cdp", "chrome"], "expectations": ["PASS", "TIMEOUT"] }, - { - "testIdPattern": "[oopif.spec] OOPIF should track navigations within OOP iframes", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[oopif.spec] OOPIF should treat OOP iframes and normal iframes the same", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[oopif.spec] OOPIF waitForFrame should resolve immediately if the frame already exists", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, { "testIdPattern": "[page.spec] Page \"after all\" hook in \"Page\"", "platforms": ["darwin", "linux", "win32"], @@ -3432,12 +3455,6 @@ "parameters": ["cdp", "firefox"], "expectations": ["SKIP"] }, - { - "testIdPattern": "[target.spec] Target should report when a new page is created and closed", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, { "testIdPattern": "[target.spec] Target should report when a service worker is created and destroyed", "platforms": ["darwin", "linux", "win32"], @@ -3701,23 +3718,5 @@ "platforms": ["darwin", "linux", "win32"], "parameters": ["cdp", "chrome", "headless"], "expectations": ["FAIL", "PASS"] - }, - { - "testIdPattern": "[page.spec] Page Page.setUserAgent *", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["chrome", "webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[target.spec] Target should report when a target url changes", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["webDriverBiDi"], - "expectations": ["PASS"] - }, - { - "testIdPattern": "[oopif.spec] OOPIF should keep track of a frames OOP state", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["PASS"] } ]