mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #50052 [types/chrome] update: missing chrome API : chrome.search by @geewoo94
* update: chrome.search API * update: search api test * remove: dt owner
This commit is contained in:
29
types/chrome/index.d.ts
vendored
29
types/chrome/index.d.ts
vendored
@@ -5352,6 +5352,35 @@ declare namespace chrome.proxy {
|
||||
export var onProxyError: ProxyErrorEvent;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// Search
|
||||
////////////////////
|
||||
/**
|
||||
* Use the chrome.search API to search via the default provider.
|
||||
* Permissions: "search"
|
||||
*/
|
||||
|
||||
declare namespace chrome.search {
|
||||
export type Disposition = "CURRENT_TAB" | "NEW_TAB" | "NEW_WINDOW";
|
||||
|
||||
export interface QueryInfo {
|
||||
/** Location where search results should be displayed. CURRENT_TAB is the default. */
|
||||
disposition?: Disposition;
|
||||
/** Location where search results should be displayed. tabIdcannot be used with disposition. */
|
||||
tabId?: number;
|
||||
/** String to query with the default search provider. */
|
||||
text?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to query the default search provider. In case of an error, runtime.lastError will be set.
|
||||
* @param options search configuration options.
|
||||
* @param callback The callback parameter should be a function that looks like this:
|
||||
* function() => {...}
|
||||
*/
|
||||
export function query(options: QueryInfo, callback: () => void): void;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// Serial
|
||||
////////////////////
|
||||
|
||||
@@ -547,3 +547,21 @@ function testOmnibox() {
|
||||
|
||||
chrome.omnibox.onDeleteSuggestion.addListener((text: string) => {});
|
||||
}
|
||||
|
||||
function testSearch() {
|
||||
function getCallback() {}
|
||||
|
||||
const DISPOSITIONS: chrome.search.Disposition[] = [
|
||||
"CURRENT_TAB",
|
||||
"NEW_TAB",
|
||||
"NEW_WINDOW",
|
||||
];
|
||||
|
||||
DISPOSITIONS.forEach((disposition) => {
|
||||
chrome.search.query({
|
||||
disposition,
|
||||
tabId: 1,
|
||||
text: 'text'
|
||||
}, getCallback);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user