@@ -11,13 +11,68 @@ browser.test;
1111browser . manifest ;
1212// @ts -expect-error
1313browser . _manifest ;
14+ // @ts -expect-error
15+ browser . trialML ;
1416
1517// browser.runtime
1618const port = browser . runtime . connect ( ) ;
1719// @ts -expect-error
1820port . postMessage ( ) ;
1921port . postMessage ( { test : "ok" } ) ;
2022
23+ {
24+ const manifest = browser . runtime . getManifest ( ) ;
25+
26+ // WebExtensionManifest
27+ const background = manifest . background ;
28+ if ( background ) {
29+ background . preferred_environment = [ "service_worker" , "document" ] ;
30+ }
31+ manifest . options_page ; // $ExpectType string | undefined
32+ manifest . content_scripts ?. every ( item => {
33+ item . match_origin_as_fallback ; // $ExpectType boolean | undefined
34+ item . world ; // $ExpectType ExecutionWorld | undefined
35+ } ) ;
36+ manifest . optional_host_permissions ; // $ExpectType string[] | undefined
37+ // @ts -expect-error
38+ manifest . telemetry ;
39+ // @ts -expect-error
40+ manifest . chrome_settings_overrides ?. search_provider . params ;
41+
42+ // ManifestBase
43+ manifest . manifest_version ; // $ExpectType number
44+ manifest . applications ?. gecko ?. admin_install_only ; // $ExpectType boolean | undefined
45+ manifest . applications ?. gecko ?. data_collection_permissions ?. required ; // $ExpectType DataCollectionPermission[] | undefined
46+ manifest . developer ?. name ; // $ExpectType string | undefined
47+ }
48+
49+ browser . runtime . getContexts ( {
50+ contextIds : [ "contextId" ] ,
51+ contextTypes : [ "BACKGROUND" , "POPUP" , "SIDE_PANEL" , "TAB" ] ,
52+ documentIds : [ "documentId" ] ,
53+ documentOrigins : [ "documentOrigin" ] ,
54+ documentUrls : [ "documentUrl" ] ,
55+ frameIds : [ 0 ] ,
56+ tabIds : [ 0 ] ,
57+ windowIds : [ browser . windows . WINDOW_ID_CURRENT ] ,
58+ incognito : true ,
59+ } ) . then ( ctxs => {
60+ ctxs . every ( ctx => {
61+ ctx . contextId ; // $ExpectType string
62+ ctx . contextType = "BACKGROUND" ;
63+ ctx . contextType = "POPUP" ;
64+ ctx . contextType = "SIDE_PANEL" ;
65+ ctx . contextType = "TAB" ;
66+ ctx . documentId ; // $ExpectType string | undefined
67+ ctx . documentOrigin ; // $ExpectType string | undefined
68+ ctx . documentUrl ; // $ExpectType string | undefined
69+ ctx . incognito ; // $ExpectType boolean
70+ ctx . frameId ; // $ExpectType number
71+ ctx . tabId ; // $ExpectType number
72+ ctx . windowId ; // $ExpectType number
73+ } ) ;
74+ } ) ;
75+
2176port . onDisconnect . addListener ( p => {
2277 if ( p . error ) {
2378 console . log ( `Disconnected due to an error: ${ p . error . message } ` ) ;
@@ -47,6 +102,8 @@ browser.menus.onClicked.addListener(info => {
47102 console . log ( info . bookmarkId . toString ( ) ) ;
48103} ) ;
49104
105+ browser . menus . create ( { contexts : [ "page_action" , "browser_action" , "action" ] } ) ;
106+
50107browser . proxy . onError . addListener ( error => {
51108 console . error ( `Proxy error: ${ error . message } ` ) ;
52109} ) ;
@@ -109,6 +166,54 @@ browser.tabs.captureVisibleTab(15);
109166browser . tabs . captureVisibleTab ( 15 , { format : "png" } ) ;
110167browser . tabs . captureVisibleTab ( { format : "png" } ) ;
111168
169+ browser . tabs . onUpdated . addListener (
170+ ( tabId , changeInfo , tab ) => {
171+ console . log ( tabId , changeInfo . title , tab . groupId ) ;
172+ } ,
173+ { properties : [ "groupId" ] , cookieStoreId : "storeId" } ,
174+ ) ;
175+ browser . tabGroups . onCreated ;
176+ browser . tabGroups . onMoved ;
177+ browser . tabGroups . onRemoved . addListener ( ( group , removeInfo ) => {
178+ group ; // $ExpectType TabGroup
179+ removeInfo . isWindowClosing ; // $ExpectType boolean
180+ } ) ;
181+ browser . tabGroups . onUpdated ;
182+
183+ // tabs in tabGroups
184+ browser . tabs . query ( {
185+ currentWindow : true ,
186+ groupId : browser . tabGroups . TAB_GROUP_ID_NONE ,
187+ } ) ;
188+ browser . tabs . group ( {
189+ tabIds : [ 0 ] ,
190+ groupId : undefined ,
191+ createProperties : { windowId : browser . windows . WINDOW_ID_CURRENT } ,
192+ } ) ;
193+ browser . tabGroups . get ( 0 ) . then ( group => {
194+ group . collapsed ; // $ExpectType boolean
195+ group . color ; // $ExpectType Color
196+ group . id ; // $ExpectType number
197+ group . title ; // $ExpectType string | undefined
198+ group . windowId ; // $ExpectType number
199+ } ) ;
200+ browser . tabGroups . update ( 0 , {
201+ collapsed : true ,
202+ color : "red" ,
203+ title : "title" ,
204+ } ) ;
205+ browser . tabGroups . query ( {
206+ collapsed : false ,
207+ color : "blue" ,
208+ title : "title" ,
209+ windowId : browser . windows . WINDOW_ID_CURRENT ,
210+ } ) ;
211+ browser . tabGroups . move ( 0 , {
212+ index : - 1 ,
213+ windowId : browser . windows . WINDOW_ID_CURRENT ,
214+ } ) ;
215+ browser . tabs . ungroup ( 0 ) ;
216+
112217/* Test SteamFilter */
113218const filter = browser . webRequest . filterResponseData ( "1234" ) ;
114219filter . onerror = ( ) => console . log ( filter . error ) ;
@@ -122,9 +227,103 @@ filter.close();
122227filter . disconnect ( ) ;
123228console . log ( filter . status ) ;
124229
230+ // @ts -expect-error
231+ browser . webRequest . onBeforeRequest . addListener ( ( ) => { } , { urls : [ "url" ] , types : [ "object_subrequest" ] } , [ ] ) ;
232+ browser . webRequest . onBeforeRequest . addListener (
233+ details => {
234+ const urlClassification = details . urlClassification ;
235+ if ( urlClassification ) {
236+ urlClassification . firstParty = urlClassification . thirdParty = [
237+ "any_social_tracking" ,
238+ "consentmanager" ,
239+ "antifraud" ,
240+ ] ;
241+ }
242+ } ,
243+ { urls : [ "url" ] , types : [ "json" ] } ,
244+ [ "blocking" , "requestBody" ] ,
245+ ) ;
246+ browser . webRequest . onAuthRequired . addListener (
247+ ( details , asyncCallback ) => {
248+ details . urlClassification ; // $ExpectType UrlClassification | undefined
249+ asyncCallback ?.( { cancel : true } ) ;
250+ } ,
251+ { urls : [ "url" ] } ,
252+ [ "responseHeaders" , "blocking" , "asyncBlocking" ] ,
253+ ) ;
254+
255+ browser . storage . sync . QUOTA_BYTES ;
256+ browser . storage . sync . QUOTA_BYTES_PER_ITEM ;
257+ browser . storage . sync . MAX_ITEMS ;
258+ browser . storage . sync . MAX_WRITE_OPERATIONS_PER_HOUR ;
259+ browser . storage . sync . MAX_WRITE_OPERATIONS_PER_MINUTE ;
260+ browser . storage . sync . MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE ;
261+ browser . storage . sync . getKeys ( ) . then ( keys => {
262+ keys ; // $ExpectType string[]
263+ } ) ;
264+ browser . storage . local . QUOTA_BYTES ;
265+ browser . storage . local . getKeys ( ) . then ( keys => {
266+ keys ; // $ExpectType string[]
267+ } ) ;
268+ browser . storage . managed . QUOTA_BYTES ;
269+ browser . storage . managed . getKeys ( ) . then ( keys => {
270+ keys ; // $ExpectType string[]
271+ } ) ;
272+ browser . storage . session . QUOTA_BYTES ;
125273browser . storage . session . get ( "sessionObject" ) ;
274+ browser . storage . session . getKeys ( ) . then ( keys => {
275+ keys ; // $ExpectType string[]
276+ } ) ;
126277browser . storage . session . set ( { "sessionObject" : "value" } ) ;
127278
279+ browser . browserAction . setTitle ( { title : "actionTitle" } ) ;
280+ browser . browserAction . setIcon ( { imageData : undefined , path : undefined } ) ;
281+ browser . browserAction . setPopup ( { popup : ".html" } ) ;
282+ browser . browserAction . setBadgeText ( { text : "badgeText" } ) ;
283+ browser . browserAction . setBadgeBackgroundColor ( { color : [ 0 , 0 , 0 , 0 ] } ) ;
284+ browser . browserAction . setBadgeTextColor ( { color : [ 0 , 0 , 0 , 0 ] } ) ;
285+ browser . browserAction . onUserSettingsChanged . addListener ( change => change . isOnToolbar === true ) ;
286+
287+ browser . contentScripts . register ( { matches : [ "<all_urls>" ] , matchOriginAsFallback : true , world : "MAIN" } ) ;
288+ browser . contentScripts . register ( { matches : [ "<all_urls>" ] , world : "ISOLATED" } ) ;
289+
290+ browser . contextualIdentities . move ( "storeId" , 0 ) ;
291+
292+ browser . cookies . get ( { url : "url" , name : "name" } ) . then ( cookies => cookies ?. partitionKey ?. hasCrossSiteAncestor === true ) ;
293+
294+ browser . declarativeNetRequest . updateDynamicRules ( {
295+ addRules : [ { id : 0 , condition : { resourceTypes : [ "json" ] } , action : { type : "allow" } } ] ,
296+ } ) ;
297+ browser . declarativeNetRequest . getDynamicRules ( { ruleIds : [ 0 ] } ) ;
298+ browser . declarativeNetRequest . getSessionRules ( { ruleIds : [ 0 ] } ) ;
299+ browser . declarativeNetRequest . updateStaticRules ( { rulesetId : "rulesetId" } ) ;
300+ browser . declarativeNetRequest . getDisabledRuleIds ( { rulesetId : "rulesetId" } ) ;
301+ browser . declarativeNetRequest . MAX_NUMBER_OF_STATIC_RULESETS ;
302+ browser . declarativeNetRequest . MAX_NUMBER_OF_DYNAMIC_RULES ;
303+ browser . declarativeNetRequest . MAX_NUMBER_OF_SESSION_RULES ;
304+
305+ browser . geckoProfiler . start ( {
306+ bufferSize : 0 ,
307+ interval : 0 ,
308+ features : [ "cpufreq" , "bandwidth" , "memory" , "tracing" , "sandbox" , "flows" ] ,
309+ } ) ;
310+
311+ browser . i18n . getPreferredSystemLanguages ( ) . then ( languageCodes => {
312+ languageCodes ; // $ExpectType string[]
313+ } ) ;
314+
315+ browser . management . getSelf ( ) . then ( extensionInfo => {
316+ extensionInfo ; // $ExpectType ExtensionInfo
317+ extensionInfo . installType = "admin" ;
318+ } ) ;
319+
320+ browser . permissions . getAll ( ) . then ( anyPermissions => {
321+ anyPermissions . data_collection ; // $ExpectType OptionalDataCollectionPermission[] | undefined
322+ } ) ;
323+ browser . permissions . onAdded . addListener ( permissions => {
324+ permissions . data_collection ; // $ExpectType OptionalDataCollectionPermission[] | undefined
325+ } ) ;
326+
128327browser . scripting . executeScript ( {
129328 target : { tabId : 1 } ,
130329 func : ( ) => { } ,
@@ -142,3 +341,72 @@ browser.scripting.executeScript({
142341 args : [ 0 , "" , false , [ ] , { } ] ,
143342 func : ( _n : number , _s : string , _b : boolean , _a : [ ] , _o : { } ) => { } ,
144343} ) ;
344+ browser . scripting . executeScript ( { target : { tabId : 0 } , world : "MAIN" } ) ;
345+ browser . scripting . registerContentScripts ( [ { id : "scriptId" , matchOriginAsFallback : true , world : "MAIN" } ] ) ;
346+ browser . scripting . updateContentScripts ( [ { id : "scriptId" , persistAcrossSessions : true , world : "MAIN" } ] ) ;
347+
348+ // @ts -expect-error
349+ browser . telemetry . submitEncryptedPing ;
350+
351+ // MV2
352+ browser . userScripts . register ( { js : [ { file : ".js" } , { code : "document;" } ] , matches : [ "<all_urls>" ] } ) . then (
353+ legacyRegisteredUserScript => {
354+ legacyRegisteredUserScript . unregister ( ) ;
355+ } ,
356+ ) ;
357+ // MV3
358+ browser . userScripts . register ( [ { id : "scriptId" , js : [ { file : ".js" } , { code : "document;" } ] , world : "MAIN" } ] ) ;
359+ browser . userScripts . register ( [ { id : "scriptId" , js : [ { file : ".js" } , { code : "document;" } ] , world : "USER_SCRIPT" } ] ) ;
360+
361+ browser . userScripts . update ( [ { id : "scriptId" } ] ) ;
362+ browser . userScripts . unregister ( { ids : [ "scriptId" ] } ) ;
363+ browser . userScripts . getScripts ( { ids : [ "scriptId" ] } ) . then ( scripts => {
364+ scripts . every ( script => {
365+ script . id = "scriptId" ;
366+ script . js = [ { file : ".js" } , { code : "document;" } ] ;
367+ script . world = "MAIN" ;
368+ } ) ;
369+ } ) ;
370+ browser . userScripts . configureWorld ( { worldId : "worldId" , csp : "policy" , messaging : true } ) ;
371+ browser . userScripts . resetWorldConfiguration ( "worldId" ) ;
372+ browser . userScripts . getWorldConfigurations ( ) . then ( propertiesArray => {
373+ propertiesArray . every ( properties => {
374+ properties . worldId = "worldId" ;
375+ properties . csp = "policy" ;
376+ properties . messaging = true ;
377+ } ) ;
378+ } ) ;
379+
380+ browser . commands . openShortcutSettings ( ) ;
381+ browser . commands . onCommand . addListener ( ( command , tab ) => {
382+ command ; // $ExpectType string
383+ tab . active ; // $ExpectType boolean
384+ } ) ;
385+
386+ browser . windows . getAll ( { populate : true , windowTypes : [ "normal" , "popup" , "panel" , "app" , "devtools" ] } ) ;
387+
388+ browser . runtime . onMessage . addListener ( ( message , sender , sendResponse ) => {
389+ sender . userScriptWorldId ; // $ExpectType string | undefined
390+ return true ;
391+ } ) ;
392+ browser . runtime . onPerformanceWarning . addListener ( details => {
393+ details . category = "content_script" ;
394+ details . severity = "low" ;
395+ details . severity = "medium" ;
396+ details . severity = "high" ;
397+ details . tabId = 0 ;
398+ details . description ; // $ExpectType string
399+ } ) ;
400+
401+ browser . runtime . onUserScriptConnect . addListener ( port => {
402+ port . disconnect ( ) ;
403+ } ) ;
404+ browser . runtime . onUserScriptMessage . addListener ( ( message , sender , sendResponse ) => {
405+ sender . userScriptWorldId ; // $ExpectType string | undefined
406+ return true ;
407+ } ) ;
408+
409+ browser . browserSettings . verticalTabs . get ( { incognito : true } ) ;
410+
411+ browser . alarms . create ( { when : 42 , delayInMinutes : 4 } ) ;
412+ browser . alarms . create ( "alarmName" , { periodInMinutes : 2 } ) ;
0 commit comments