Home Reference Source Test Repository
public class | source

Tabs

Utility for tabs.

See:

Test:

Static Method Summary

Static Public Methods
public static

getActiveTab(): Promise.<chrome~Tab | null>

Get an active tab with Promise.

public static

getTab(tabId: number): Promise.<chrome~Tab | null>

Get a tab instance specified by tab ID with Promise.

public static

withActiveTab(fn: function(tab: chrome~Tab): void)

Call a function with an active tab instance.

public static

withTab(tabId: number, fn: function(tab: chrome~Tab): void)

Call a function with a tab instance specified by tab ID.

Static Public Methods

public static getActiveTab(): Promise.<chrome~Tab | null> source

Get an active tab with Promise.

Return:

Promise.<chrome~Tab | null>

Promise of active tab instance. If there is no active tab, it resolves to null.

Test:

public static getTab(tabId: number): Promise.<chrome~Tab | null> source

Get a tab instance specified by tab ID with Promise.

Params:

NameTypeAttributeDescription
tabId number

Tab ID.

Return:

Promise.<chrome~Tab | null>

Promise of tab instance. If there is no tab for tab ID, it resolves to null.

Test:

public static withActiveTab(fn: function(tab: chrome~Tab): void) source

Call a function with an active tab instance.

Note: fn is never called when there is no active tab.

Params:

NameTypeAttributeDescription
fn function(tab: chrome~Tab): void

Callback function.

Test:

public static withTab(tabId: number, fn: function(tab: chrome~Tab): void) source

Call a function with a tab instance specified by tab ID.

Note: fn is never called when there is no tab for tab ID.

Params:

NameTypeAttributeDescription
tabId number

Tab ID.

fn function(tab: chrome~Tab): void

Callback function.

Test: