3 * Copyright 2024 Google Inc.
4 * SPDX-License-Identifier: Apache-2.0
9 } from 'puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js';
11 globalThis
.testConnect
= async url
=> {
12 const tab
= await chrome
.tabs
.create({
16 // Wait for the new tab to load before connecting.
17 await
new Promise(resolve
=> {
18 function listener(tabId
, changeInfo
) {
19 if (tabId
=== tab
.id
&& changeInfo
.status
=== 'complete') {
20 chrome
.tabs
.onUpdated
.removeListener(listener
);
24 chrome
.tabs
.onUpdated
.addListener(listener
);
27 const browser
= await
connect({
28 transport
: await ExtensionTransport
.connectTab(tab
.id
),
30 const [page
] = await browser
.pages();
31 const title
= await page
.evaluate(() => {
32 return document
.title
;
34 const frame
= await page
.waitForFrame(frame
=> {
35 return frame
.url().endsWith('iframe.html');
37 const frameTitle
= await frame
.evaluate(() => {
38 return document
.title
;
40 await page
.waitForNetworkIdle();
41 return title
+ '|' + frameTitle
;