🤖 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:
Geewoo94
2020-12-12 01:13:16 +09:00
committed by GitHub
parent 3274739136
commit 59b7135266
2 changed files with 47 additions and 0 deletions

View File

@@ -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
////////////////////

View File

@@ -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);
});
}