From aa77d6033429bbc7d1589e004d07156c58d6a9c4 Mon Sep 17 00:00:00 2001 From: Erwan Jugand <47392755+erwanjugand@users.noreply.github.com> Date: Mon, 27 Oct 2025 19:02:39 +0100 Subject: [PATCH 01/23] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#73876=20[chr?= =?UTF-8?q?ome]=20update=20types=20namespace=20by=20@erwanjugand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/chrome/index.d.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 44bb090a6f8939..9de9f3de17821a 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -12247,16 +12247,16 @@ declare namespace chrome { */ value: T; /** Where to set the setting (default: regular). */ - scope?: ChromeSettingScope; + scope?: ChromeSettingScope | undefined; } /** Which setting to consider. */ export interface ChromeSettingGetDetails { /** Whether to return the value that applies to the incognito session (default false). */ - incognito?: boolean; + incognito?: boolean | undefined; } - /** Details of the currently effective value */ + /** Details of the currently effective value. */ export interface ChromeSettingGetResult { /** The level of control of the setting. */ levelOfControl: LevelOfControl; @@ -12264,7 +12264,7 @@ declare namespace chrome { value: T; /** * Whether the effective value is specific to the incognito session. - * This property will only be present if the incognito property in the details parameter of get() was true. + * This property will only be present if the `incognito` property in the `details` parameter of `get()` was true. */ incognitoSpecific?: boolean; } @@ -12272,17 +12272,14 @@ declare namespace chrome { /** Which setting to clear. */ export interface ChromeSettingClearDetails { /** Where to clear the setting (default: regular). */ - scope?: ChromeSettingScope; + scope?: ChromeSettingScope | undefined; } /** Details of the currently effective value. */ export interface ChromeSettingOnChangeDetails { - /** - * Whether the effective value is specific to the incognito session. T - * his property will only be present if the incognito property in the details parameter of get() was true. - */ + /** Whether the value that has changed is specific to the incognito session. This property will only be present if the user has enabled the extension in incognito mode. */ incognitoSpecific?: boolean; - /** The value of the setting. */ + /** The value of the setting after the change. */ value: T; /** The level of control of the setting. */ levelOfControl: LevelOfControl; @@ -12295,27 +12292,30 @@ declare namespace chrome { export interface ChromeSetting { /** * Sets the value of a setting. + * * Can return its result via Promise in Manifest V3 or later since Chrome 96. */ - set(details: ChromeSettingSetDetails, callback: () => void): void; set(details: ChromeSettingSetDetails): Promise; + set(details: ChromeSettingSetDetails, callback: () => void): void; /** * Gets the value of a setting. + * * Can return its result via Promise in Manifest V3 or later since Chrome 96. */ - get(details: ChromeSettingGetDetails, callback: (details: ChromeSettingGetResult) => void): void; get(details: ChromeSettingGetDetails): Promise>; + get(details: ChromeSettingGetDetails, callback: (details: ChromeSettingGetResult) => void): void; /** * Clears the setting, restoring any default value. + * * Can return its result via Promise in Manifest V3 or later since Chrome 96. */ - clear(details: ChromeSettingClearDetails, callback: () => void): void; clear(details: ChromeSettingClearDetails): Promise; + clear(details: ChromeSettingClearDetails, callback: () => void): void; /** Fired after the setting changes. */ - onChange: chrome.events.Event<(details: ChromeSettingOnChangeDetails) => void>; + onChange: events.Event<(details: ChromeSettingOnChangeDetails) => void>; } } From 1e0d776f02dfa48b393931dce6b95284c5bb3f27 Mon Sep 17 00:00:00 2001 From: Erwan Jugand <47392755+erwanjugand@users.noreply.github.com> Date: Mon, 27 Oct 2025 19:03:46 +0100 Subject: [PATCH 02/23] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#73875=20[chr?= =?UTF-8?q?ome]=20update=20webNavigation=20namespace=20by=20@erwanjugand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/chrome/index.d.ts | 275 +++++++++++++++++++++---------------- types/chrome/test/index.ts | 236 +++++++++++++++++++++++++------ 2 files changed, 350 insertions(+), 161 deletions(-) diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 9de9f3de17821a..a5bc0d1d3886a7 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -12572,33 +12572,84 @@ declare namespace chrome { * Permissions: "webNavigation" */ export namespace webNavigation { - export interface GetFrameDetails { - /** - * The ID of the process runs the renderer for this tab. - * @since Chrome 22 - * @deprecated since Chrome 49. Frames are now uniquely identified by their tab ID and frame ID; the process ID is no longer needed and therefore ignored. - */ - processId?: number | undefined; - /** The ID of the tab in which the frame is. */ - tabId: number; - /** The ID of the frame in the given tab. */ - frameId: number; + /** @since Chrome 44 */ + export enum TransitionQualifier { + CLIENT_REDIRECT = "client_redirect", + SERVER_REDIRECT = "server_redirect", + FORWARD_BACK = "forward_back", + FROM_ADDRESS_BAR = "from_address_bar", + } + + /** + * Cause of the navigation. The same transition types as defined in the history API are used. These are the same transition types as defined in the history API except with `"start_page"` in place of `"auto_toplevel"` (for backwards compatibility). + * @since Chrome 44 + */ + export enum TransitionType { + LINK = "link", + TYPED = "typed", + AUTO_BOOKMARK = "auto_bookmark", + AUTO_SUBFRAME = "auto_subframe", + MANUAL_SUBFRAME = "manual_subframe", + GENERATED = "generated", + START_PAGE = "start_page", + FORM_SUBMIT = "form_submit", + RELOAD = "reload", + KEYWORD = "keyword", + KEYWORD_GENERATED = "keyword_generated", } + export type GetFrameDetails = + & ({ + /** + * The ID of the process that runs the renderer for this tab. + * @deprecated since Chrome 49. Frames are now uniquely identified by their tab ID and frame ID; the process ID is no longer needed and therefore ignored. + */ + processId?: number | undefined; + }) + & ( + { + /** The ID of the tab in which the frame is. */ + tabId?: number | undefined; + /** The ID of the frame in the given tab. */ + frameId?: number | undefined; + /** + * The UUID of the document. If the frameId and/or tabId are provided they will be validated to match the document found by provided document ID. + * @since Chrome 106 + */ + documentId: string; + } | { + /** The ID of the tab in which the frame is. */ + tabId: number; + /** The ID of the frame in the given tab. */ + frameId: number; + /** + * The UUID of the document. If the frameId and/or tabId are provided they will be validated to match the document found by provided document ID. + * @since Chrome 106 + */ + documentId?: string | undefined; + } + ); + export interface GetFrameResultDetails { /** The URL currently associated with this frame, if the frame identified by the frameId existed at one point in the given tab. The fact that an URL is associated with a given frameId does not imply that the corresponding frame still exists. */ url: string; /** A UUID of the document loaded. */ documentId: string; - /** The lifecycle the document is in. */ + /** + * The lifecycle the document is in. + * @since Chrome 106 + */ documentLifecycle: extensionTypes.DocumentLifecycle; /** True if the last navigation in this frame was interrupted by an error, i.e. the onErrorOccurred event fired. */ errorOccurred: boolean; /** The type of frame the navigation occurred in. */ frameType: extensionTypes.FrameType; - /** A UUID of the parent document owning this frame. This is not set if there is no parent. */ + /** + * A UUID of the parent document owning this frame. This is not set if there is no parent. + * @since Chrome 106 + */ parentDocumentId?: string | undefined; - /** ID of frame that wraps the frame. Set to -1 of no parent frame exists. */ + /** The ID of the parent frame, or `-1` if this is the main frame. */ parentFrameId: number; } @@ -12607,83 +12658,86 @@ declare namespace chrome { tabId: number; } + /** A list of frames in the given tab, null if the specified tab ID is invalid. */ export interface GetAllFrameResultDetails extends GetFrameResultDetails { - /** The ID of the process runs the renderer for this tab. */ + /** The ID of the process that runs the renderer for this frame. */ processId: number; /** The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe. */ frameId: number; } - export interface WebNavigationCallbackDetails { - /** The ID of the tab in which the navigation is about to occur. */ - tabId: number; - /** The time when the browser was about to start the navigation, in milliseconds since the epoch. */ - timeStamp: number; - } - - export interface WebNavigationUrlCallbackDetails extends WebNavigationCallbackDetails { - url: string; - } - - export interface WebNavigationReplacementCallbackDetails extends WebNavigationCallbackDetails { + export interface WebNavigationReplacementCallbackDetails { /** The ID of the tab that was replaced. */ replacedTabId: number; + /** The ID of the tab that replaced the old tab. */ + tabId: number; + /** The time when the replacement happened, in milliseconds since the epoch. */ + timeStamp: number; } - export interface WebNavigationFramedCallbackDetails extends WebNavigationUrlCallbackDetails { - /** 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique for a given tab and process. */ + export interface WebNavigationBaseCallbackDetails { + /** The lifecycle the document is in. */ + documentLifecycle: extensionTypes.DocumentLifecycle; + /** 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab. */ frameId: number; /** The type of frame the navigation occurred in. */ frameType: extensionTypes.FrameType; - /** A UUID of the document loaded. (This is not set for onBeforeNavigate callbacks.) */ - documentId?: string | undefined; - /** The lifecycle the document is in. */ - documentLifecycle: extensionTypes.DocumentLifecycle; /** A UUID of the parent document owning this frame. This is not set if there is no parent. */ - parentDocumentId?: string | undefined; + parentDocumentId?: string; + /** The ID of the parent frame, or `-1` if this is the main frame. */ + parentFrameId: number; + /** The ID of the process that runs the renderer for this frame. */ + processId: number; + /** The ID of the tab in which the navigation occurs. */ + tabId: number; + /** The time when the browser was about to start the navigation, in milliseconds since the epoch */ + timeStamp: number; + url: string; + } + + export interface WebNavigationFramedCallbackDetails extends WebNavigationBaseCallbackDetails { /** - * The ID of the process runs the renderer for this tab. - * @since Chrome 22 + * A UUID of the document loaded. + * @since Chrome 106 */ - processId: number; + documentId: string; } - export interface WebNavigationFramedErrorCallbackDetails extends WebNavigationFramedCallbackDetails { + export interface WebNavigationFramedErrorCallbackDetails extends WebNavigationBaseCallbackDetails { + /** + * A UUID of the document loaded. + * @since Chrome 106 + */ + documentId: string; /** The error description. */ error: string; } - export interface WebNavigationSourceCallbackDetails extends WebNavigationUrlCallbackDetails { - /** The ID of the tab in which the navigation is triggered. */ - sourceTabId: number; - /** - * The ID of the process runs the renderer for the source tab. - * @since Chrome 22 - */ - sourceProcessId: number; + export interface WebNavigationSourceCallbackDetails { /** The ID of the frame with sourceTabId in which the navigation is triggered. 0 indicates the main frame. */ sourceFrameId: number; + /** The ID of the process that runs the renderer for the source frame. */ + sourceProcessId: number; + /** The ID of the tab in which the navigation is triggered. */ + sourceTabId: number; + /** The ID of the tab in which the url is opened */ + tabId: number; + /** The time when the browser was about to create a new view, in milliseconds since the epoch. */ + timeStamp: number; + /** The URL to be opened in the new window. */ + url: string; } - export interface WebNavigationParentedCallbackDetails extends WebNavigationFramedCallbackDetails { - /** - * ID of frame that wraps the frame. Set to -1 of no parent frame exists. - * @since Chrome 24 - */ - parentFrameId: number; - } - - export interface WebNavigationTransitionCallbackDetails extends WebNavigationFramedCallbackDetails { - /** - * Cause of the navigation. - * One of: "link", "typed", "auto_bookmark", "auto_subframe", "manual_subframe", "generated", "start_page", "form_submit", "reload", "keyword", or "keyword_generated" - */ - transitionType: string; + export interface WebNavigationTransitionCallbackDetails extends WebNavigationBaseCallbackDetails { /** - * A list of transition qualifiers. - * Each element one of: "client_redirect", "server_redirect", "forward_back", or "from_address_bar" + * A UUID of the document loaded. + * @since Chrome 106 */ - transitionQualifiers: string[]; + documentId: string; + /** Cause of the navigation. */ + transitionType: `${TransitionType}`; + /** A list of transition qualifiers.*/ + transitionQualifiers: `${TransitionQualifier}`[]; } export interface WebNavigationEventFilter { @@ -12691,89 +12745,72 @@ declare namespace chrome { url: chrome.events.UrlFilter[]; } - export interface WebNavigationEvent - extends chrome.events.Event<(details: T) => void> + interface WebNavigationEvent void> + extends Omit, "addListener"> { - addListener(callback: (details: T) => void, filters?: WebNavigationEventFilter): void; + addListener(callback: T, filters?: WebNavigationEventFilter): void; } - export interface WebNavigationFramedEvent extends WebNavigationEvent {} - - export interface WebNavigationFramedErrorEvent - extends WebNavigationEvent - {} - - export interface WebNavigationSourceEvent extends WebNavigationEvent {} - - export interface WebNavigationParentedEvent extends WebNavigationEvent {} - - export interface WebNavigationTransitionalEvent - extends WebNavigationEvent - {} - - export interface WebNavigationReplacementEvent - extends WebNavigationEvent - {} - /** * Retrieves information about the given frame. A frame refers to an