本文整理汇总了TypeScript中chrome-remote-interface.Close函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Close函数的具体用法?TypeScript Close怎么用?TypeScript Close使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Close函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: create
export async function create(html: string, options?: CreateOptions): Promise<CreateResult> {
const myOptions = Object.assign({}, options);
let chrome: LaunchedChrome;
myOptions._canceled = false;
if (myOptions.timeout >= 0) {
setTimeout(() => {
myOptions._canceled = true;
}, myOptions.timeout);
}
await throwIfCanceled(myOptions);
if (!myOptions.host && !myOptions.port) {
await throwIfCanceled(myOptions);
chrome = await launchChrome(myOptions);
}
try {
const tab = await CDP.New(myOptions);
try {
return await generate(html, myOptions, tab);
} finally {
await CDP.Close({ ...myOptions, id: tab.id });
}
} finally {
if (chrome) {
await chrome.kill();
}
}
}
示例2: close
async close(): Promise<void> {
const { client } = await this.runtimeClientPromise
if (this.options.cdp.closeTab) {
CDP.Close({ id: client.target.id })
}
await client.close()
}
示例3: close
async close(): Promise<void> {
const { client } = await this.runtimeClientPromise
if (this.options.cdp.closeTab) {
await CDP.Close({ id: client.target.id })
}
if (this.chromeInstance) {
this.chromeInstance.kill()
}
await client.close()
}