Skip to content

Commit 162fd26

Browse files
authored
🤖 Merge PR DefinitelyTyped#71963 updated types for webextension-polyfill by @Lusito
1 parent 6ca7ec0 commit 162fd26

22 files changed

+348
-81
lines changed

types/webextension-polyfill/index.d.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import { TabGroups as ImportedTabGroups } from "./namespaces/tabGroups";
5353
import { Tabs as ImportedTabs } from "./namespaces/tabs";
5454
import { Theme as ImportedTheme } from "./namespaces/theme";
5555
import { TopSites as ImportedTopSites } from "./namespaces/topSites";
56+
import { Trial as ImportedTrial } from "./namespaces/trial";
5657
import { Types as ImportedTypes } from "./namespaces/types";
5758
import { UserScripts as ImportedUserScripts } from "./namespaces/userScripts";
5859
import { WebNavigation as ImportedWebNavigation } from "./namespaces/webNavigation";
@@ -389,13 +390,18 @@ declare namespace Browser {
389390
*/
390391
const topSites: TopSites.Static;
391392

393+
/**
394+
* Permissions: "trialML"
395+
*/
396+
const trial: Trial.Static;
397+
392398
/**
393399
* Contains types used by other schemas.
394400
*/
395401
const types: Types.Static;
396402

397403
/**
398-
* Permissions: "manifest:user_scripts"
404+
* Permissions: "manifest:user_scripts", "userScripts"
399405
*/
400406
const userScripts: UserScripts.Static;
401407

@@ -751,13 +757,18 @@ declare namespace Browser {
751757
*/
752758
topSites: TopSites.Static;
753759

760+
/**
761+
* Permissions: "trialML"
762+
*/
763+
trial: Trial.Static;
764+
754765
/**
755766
* Contains types used by other schemas.
756767
*/
757768
types: Types.Static;
758769

759770
/**
760-
* Permissions: "manifest:user_scripts"
771+
* Permissions: "manifest:user_scripts", "userScripts"
761772
*/
762773
userScripts: UserScripts.Static;
763774

@@ -835,6 +846,7 @@ declare namespace Browser {
835846
export import Tabs = ImportedTabs;
836847
export import Theme = ImportedTheme;
837848
export import TopSites = ImportedTopSites;
849+
export import Trial = ImportedTrial;
838850
export import Types = ImportedTypes;
839851
export import UserScripts = ImportedUserScripts;
840852
export import WebNavigation = ImportedWebNavigation;

types/webextension-polyfill/namespaces/action.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ export namespace Action {
196196
/**
197197
* Sets the text color for the badge.
198198
*/
199-
setBadgeTextColor(details: SetBadgeTextColorDetailsType): void;
199+
setBadgeTextColor(details: SetBadgeTextColorDetailsType): Promise<void>;
200200

201201
/**
202202
* Gets the text color of the browser action badge.
203203
*/
204-
getBadgeTextColor(details: Details): void;
204+
getBadgeTextColor(details: Details): Promise<ColorArray>;
205205

206206
/**
207207
* Enables the browser action for a tab. By default, browser actions are enabled.

types/webextension-polyfill/namespaces/captivePortal.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export namespace CaptivePortal {
2727
/**
2828
* Returns the current portal state, one of `unknown`, `not_captive`, `unlocked_portal`, `locked_portal`.
2929
*/
30-
getState(): void;
30+
getState(): Promise<"unknown" | "not_captive" | "unlocked_portal" | "locked_portal">;
3131

3232
/**
3333
* Returns the time difference between NOW and the last time a request was completed in milliseconds.
3434
*/
35-
getLastChecked(): void;
35+
getLastChecked(): Promise<number>;
3636

3737
/**
3838
* Fired when the captive portal state changes.

types/webextension-polyfill/namespaces/commands.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ export namespace Commands {
8989
*/
9090
getAll(): Promise<Command[]>;
9191

92+
/**
93+
* Open extension shortcuts configuration page.
94+
*/
95+
openShortcutSettings(): void;
96+
9297
/**
9398
* Fired when a registered command is activated using a keyboard shortcut.
9499
*

types/webextension-polyfill/namespaces/contextualIdentities.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export namespace ContextualIdentities {
154154
* @param cookieStoreIds The ID or list of IDs of the contextual identity cookie stores.
155155
* @param position The position the contextual identity should move to.
156156
*/
157-
move(cookieStoreIds: string | string[], position: number): void;
157+
move(cookieStoreIds: string | string[], position: number): Promise<void>;
158158

159159
/**
160160
* Deletes a contextual identity by its cookie Store ID.

types/webextension-polyfill/namespaces/cookies.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ export namespace Cookies {
2424
* Optional.
2525
*/
2626
topLevelSite?: string;
27+
28+
/**
29+
* Whether or not the cookie is in a third-party context, respecting ancestor chains.
30+
* Optional.
31+
*/
32+
hasCrossSiteAncestor?: boolean;
2733
}
2834

2935
/**

types/webextension-polyfill/namespaces/declarativeNetRequest.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export namespace DeclarativeNetRequest {
2929
| "imageset"
3030
| "web_manifest"
3131
| "speculative"
32+
| "json"
3233
| "other";
3334

3435
/**

types/webextension-polyfill/namespaces/devtools_panels.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export namespace DevtoolsPanels {
8080
*
8181
* @param path Relative path of an extension page to display within the sidebar.
8282
*/
83-
setPage(path: Manifest.ExtensionURL): void;
83+
setPage(path: Manifest.ExtensionURL): Promise<void>;
8484

8585
/**
8686
* Fired when the sidebar pane becomes visible as a result of user switching to the panel that hosts it.

types/webextension-polyfill/namespaces/geckoProfiler.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ export namespace GeckoProfiler {
3434
| "responsiveness"
3535
| "cpufreq"
3636
| "bandwidth"
37-
| "memory";
37+
| "memory"
38+
| "tracing"
39+
| "sandbox"
40+
| "flows";
3841

3942
type supports = "windowLength";
4043

types/webextension-polyfill/namespaces/manifest.d.ts

Lines changed: 26 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export namespace Manifest {
2626
*/
2727
browser_specific_settings?: BrowserSpecificSettings;
2828

29+
/**
30+
* Name must be at least 2, at should be at most 75 characters
31+
*/
2932
name: string;
3033

3134
/**
@@ -97,10 +100,7 @@ export namespace Manifest {
97100
/**
98101
* Optional.
99102
*/
100-
background?:
101-
| WebExtensionManifestBackgroundC1Type
102-
| WebExtensionManifestBackgroundC2Type
103-
| WebExtensionManifestBackgroundC3Type;
103+
background?: WebExtensionManifestBackgroundType;
104104

105105
/**
106106
* Alias property for options_ui.page, ignored when options_ui.page is set. When using this property the options page is
@@ -279,6 +279,8 @@ export namespace Manifest {
279279
size: number;
280280
}
281281

282+
type OptionalOnlyPermission = "trialML" | "userScripts";
283+
282284
type OptionalPermissionNoPrompt =
283285
| "idle"
284286
| "cookies"
@@ -320,7 +322,7 @@ export namespace Manifest {
320322
| "webNavigation"
321323
| "identity.email";
322324

323-
type OptionalPermissionOrOrigin = OptionalPermission | MatchPattern;
325+
type OptionalPermissionOrOrigin = OptionalPermission | OptionalOnlyPermission | MatchPattern;
324326

325327
type PermissionPrivileged = "mozillaAddons" | "activityLog" | "networkStatus" | "normandyAddonStudy";
326328

@@ -673,40 +675,44 @@ export namespace Manifest {
673675
*/
674676
type WebExtensionManifestIncognitoEnum = "not_allowed" | "spanning" | "split";
675677

676-
interface WebExtensionManifestBackgroundC1Type {
677-
page: ExtensionURL;
678+
/**
679+
* Only supported for page/scripts; not for service_worker yet, see bug 1775574
680+
*/
681+
type WebExtensionManifestBackgroundTypeEnum = "module" | "classic";
678682

683+
type WebExtensionManifestBackgroundPreferredEnvironmentItemEnum = "service_worker" | "document";
684+
685+
interface WebExtensionManifestBackgroundType {
679686
/**
680687
* Optional.
681688
*/
682-
persistent?: boolean;
683-
}
689+
service_worker?: ExtensionURL;
684690

685-
type WebExtensionManifestBackgroundC2TypeEnum = "module" | "classic";
691+
/**
692+
* Optional.
693+
*/
694+
page?: ExtensionURL;
686695

687-
interface WebExtensionManifestBackgroundC2Type {
688-
scripts: ExtensionURL[];
696+
/**
697+
* Optional.
698+
*/
699+
scripts?: ExtensionURL[];
689700

690701
/**
702+
* Only supported for page/scripts; not for service_worker yet, see bug 1775574
691703
* Optional.
692704
*/
693-
type?: WebExtensionManifestBackgroundC2TypeEnum;
705+
type?: WebExtensionManifestBackgroundTypeEnum;
694706

695707
/**
696708
* Optional.
697709
*/
698710
persistent?: boolean;
699-
}
700-
701-
interface WebExtensionManifestBackgroundC3Type {
702-
service_worker: ExtensionURL;
703711

704712
/**
705-
* Even though Manifest V3, does not support multiple background scripts, you can optionally declare the service worker as
706-
* an ES Module by specifying "type": "module", which allows you to import further code.
707713
* Optional.
708714
*/
709-
type?: "module";
715+
preferred_environment?: WebExtensionManifestBackgroundPreferredEnvironmentItemEnum[];
710716
}
711717

712718
interface WebExtensionManifestOptionsUiType {
@@ -761,37 +767,6 @@ export namespace Manifest {
761767
extension_ids?: Array<ExtensionID | "*">;
762768
}
763769

764-
interface WebExtensionManifestChromeSettingsOverridesSearchProviderParamsItemType {
765-
/**
766-
* A url parameter name
767-
*/
768-
name: string;
769-
770-
/**
771-
* The type of param can be either "purpose" or "pref".
772-
* Optional.
773-
*/
774-
condition?: "purpose" | "pref";
775-
776-
/**
777-
* The preference to retrieve the value from.
778-
* Optional.
779-
*/
780-
pref?: string;
781-
782-
/**
783-
* The context that initiates a search, required if condition is "purpose".
784-
* Optional.
785-
*/
786-
purpose?: "contextmenu" | "searchbar" | "homepage" | "keyword" | "newtab";
787-
788-
/**
789-
* A url parameter value.
790-
* Optional.
791-
*/
792-
value?: string;
793-
}
794-
795770
interface WebExtensionManifestChromeSettingsOverridesSearchProviderType {
796771
name: string;
797772

@@ -847,13 +822,6 @@ export namespace Manifest {
847822
* Optional.
848823
*/
849824
is_default?: boolean;
850-
851-
/**
852-
* A list of optional search url parameters. This allows the additon of search url parameters based on how the search is
853-
* performed in Firefox.
854-
* Optional.
855-
*/
856-
params?: WebExtensionManifestChromeSettingsOverridesSearchProviderParamsItemType[];
857825
}
858826

859827
interface WebExtensionManifestChromeSettingsOverridesType {

0 commit comments

Comments
 (0)