brave-real-puppeteer-core 24.20.0 → 24.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/advanced-stealth.js +1 -1
- package/lib/cjs/puppeteer/api/Browser.d.ts +1 -1
- package/lib/cjs/puppeteer/api/Dialog.d.ts +8 -10
- package/lib/cjs/puppeteer/api/Dialog.d.ts.map +1 -1
- package/lib/cjs/puppeteer/api/Dialog.js +8 -10
- package/lib/cjs/puppeteer/api/Dialog.js.map +1 -1
- package/lib/cjs/puppeteer/api/ElementHandle.d.ts +28 -30
- package/lib/cjs/puppeteer/api/ElementHandle.d.ts.map +1 -1
- package/lib/cjs/puppeteer/api/ElementHandle.js +27 -29
- package/lib/cjs/puppeteer/api/ElementHandle.js.map +1 -1
- package/lib/cjs/puppeteer/api/Frame.d.ts +34 -38
- package/lib/cjs/puppeteer/api/Frame.d.ts.map +1 -1
- package/lib/cjs/puppeteer/api/Frame.js +34 -38
- package/lib/cjs/puppeteer/api/Frame.js.map +1 -1
- package/lib/cjs/puppeteer/api/HTTPRequest.d.ts +8 -1
- package/lib/cjs/puppeteer/api/HTTPRequest.d.ts.map +1 -1
- package/lib/cjs/puppeteer/api/HTTPRequest.js +12 -14
- package/lib/cjs/puppeteer/api/HTTPRequest.js.map +1 -1
- package/lib/cjs/puppeteer/api/Page.d.ts +103 -109
- package/lib/cjs/puppeteer/api/Page.d.ts.map +1 -1
- package/lib/cjs/puppeteer/api/Page.js +35 -41
- package/lib/cjs/puppeteer/api/Page.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/Browser.d.ts.map +1 -1
- package/lib/cjs/puppeteer/bidi/Browser.js +5 -3
- package/lib/cjs/puppeteer/bidi/Browser.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/Frame.d.ts.map +1 -1
- package/lib/cjs/puppeteer/bidi/Frame.js +1 -1
- package/lib/cjs/puppeteer/bidi/Frame.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/HTTPRequest.d.ts +4 -2
- package/lib/cjs/puppeteer/bidi/HTTPRequest.d.ts.map +1 -1
- package/lib/cjs/puppeteer/bidi/HTTPRequest.js +14 -5
- package/lib/cjs/puppeteer/bidi/HTTPRequest.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/Page.d.ts +6 -1
- package/lib/cjs/puppeteer/bidi/Page.d.ts.map +1 -1
- package/lib/cjs/puppeteer/bidi/Page.js +42 -14
- package/lib/cjs/puppeteer/bidi/Page.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/core/Browser.d.ts.map +1 -1
- package/lib/cjs/puppeteer/bidi/core/Browser.js +24 -2
- package/lib/cjs/puppeteer/bidi/core/Browser.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
- package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js +1 -3
- package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/core/Realm.d.ts +2 -2
- package/lib/cjs/puppeteer/cdp/Accessibility.js +0 -20
- package/lib/cjs/puppeteer/cdp/Accessibility.js.map +1 -1
- package/lib/cjs/puppeteer/cdp/HTTPRequest.d.ts +1 -0
- package/lib/cjs/puppeteer/cdp/HTTPRequest.d.ts.map +1 -1
- package/lib/cjs/puppeteer/cdp/HTTPRequest.js +3 -0
- package/lib/cjs/puppeteer/cdp/HTTPRequest.js.map +1 -1
- package/lib/cjs/puppeteer/cdp/NetworkManager.d.ts +1 -1
- package/lib/cjs/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
- package/lib/cjs/puppeteer/cdp/NetworkManager.js +8 -2
- package/lib/cjs/puppeteer/cdp/NetworkManager.js.map +1 -1
- package/lib/cjs/puppeteer/cdp/Page.d.ts +5 -1
- package/lib/cjs/puppeteer/cdp/Page.d.ts.map +1 -1
- package/lib/cjs/puppeteer/cdp/Page.js +8 -2
- package/lib/cjs/puppeteer/cdp/Page.js.map +1 -1
- package/lib/cjs/puppeteer/cdp/PredefinedNetworkConditions.d.ts +13 -22
- package/lib/cjs/puppeteer/cdp/PredefinedNetworkConditions.d.ts.map +1 -1
- package/lib/cjs/puppeteer/cdp/PredefinedNetworkConditions.js +13 -22
- package/lib/cjs/puppeteer/cdp/PredefinedNetworkConditions.js.map +1 -1
- package/lib/cjs/puppeteer/common/Device.d.ts +6 -8
- package/lib/cjs/puppeteer/common/Device.d.ts.map +1 -1
- package/lib/cjs/puppeteer/common/Device.js +6 -8
- package/lib/cjs/puppeteer/common/Device.js.map +1 -1
- package/lib/cjs/puppeteer/generated/injected.d.ts +1 -1
- package/lib/cjs/puppeteer/generated/injected.js +1 -1
- package/lib/cjs/puppeteer/generated/version.d.ts +1 -1
- package/lib/cjs/puppeteer/generated/version.js +1 -1
- package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
- package/lib/cjs/puppeteer/node/BrowserLauncher.d.ts +1 -1
- package/lib/cjs/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
- package/lib/cjs/puppeteer/node/BrowserLauncher.js +12 -4
- package/lib/cjs/puppeteer/node/BrowserLauncher.js.map +1 -1
- package/lib/cjs/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
- package/lib/cjs/puppeteer/node/ChromeLauncher.js +1 -0
- package/lib/cjs/puppeteer/node/ChromeLauncher.js.map +1 -1
- package/lib/cjs/puppeteer/node/PipeTransport.d.ts.map +1 -1
- package/lib/cjs/puppeteer/node/PipeTransport.js +15 -16
- package/lib/cjs/puppeteer/node/PipeTransport.js.map +1 -1
- package/lib/cjs/puppeteer/node/PuppeteerNode.d.ts +5 -7
- package/lib/cjs/puppeteer/node/PuppeteerNode.d.ts.map +1 -1
- package/lib/cjs/puppeteer/node/PuppeteerNode.js +5 -7
- package/lib/cjs/puppeteer/node/PuppeteerNode.js.map +1 -1
- package/lib/cjs/puppeteer/revisions.d.ts +3 -3
- package/lib/cjs/puppeteer/revisions.js +3 -3
- package/lib/cjs/puppeteer/util/Function.d.ts.map +1 -1
- package/lib/cjs/puppeteer/util/Function.js +16 -25
- package/lib/cjs/puppeteer/util/Function.js.map +1 -1
- package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
- package/lib/es5-iife/puppeteer-core-browser.d.ts +201 -227
- package/lib/es5-iife/puppeteer-core-browser.js +176 -218
- package/lib/esm/puppeteer/api/Browser.d.ts +1 -1
- package/lib/esm/puppeteer/api/Dialog.d.ts +8 -10
- package/lib/esm/puppeteer/api/Dialog.d.ts.map +1 -1
- package/lib/esm/puppeteer/api/Dialog.js +8 -10
- package/lib/esm/puppeteer/api/Dialog.js.map +1 -1
- package/lib/esm/puppeteer/api/ElementHandle.d.ts +28 -30
- package/lib/esm/puppeteer/api/ElementHandle.d.ts.map +1 -1
- package/lib/esm/puppeteer/api/ElementHandle.js +27 -29
- package/lib/esm/puppeteer/api/ElementHandle.js.map +1 -1
- package/lib/esm/puppeteer/api/Frame.d.ts +34 -38
- package/lib/esm/puppeteer/api/Frame.d.ts.map +1 -1
- package/lib/esm/puppeteer/api/Frame.js +34 -38
- package/lib/esm/puppeteer/api/Frame.js.map +1 -1
- package/lib/esm/puppeteer/api/HTTPRequest.d.ts +8 -1
- package/lib/esm/puppeteer/api/HTTPRequest.d.ts.map +1 -1
- package/lib/esm/puppeteer/api/HTTPRequest.js +12 -14
- package/lib/esm/puppeteer/api/HTTPRequest.js.map +1 -1
- package/lib/esm/puppeteer/api/Page.d.ts +103 -109
- package/lib/esm/puppeteer/api/Page.d.ts.map +1 -1
- package/lib/esm/puppeteer/api/Page.js +35 -41
- package/lib/esm/puppeteer/api/Page.js.map +1 -1
- package/lib/esm/puppeteer/bidi/Browser.d.ts.map +1 -1
- package/lib/esm/puppeteer/bidi/Browser.js +5 -3
- package/lib/esm/puppeteer/bidi/Browser.js.map +1 -1
- package/lib/esm/puppeteer/bidi/Frame.d.ts.map +1 -1
- package/lib/esm/puppeteer/bidi/Frame.js +1 -1
- package/lib/esm/puppeteer/bidi/Frame.js.map +1 -1
- package/lib/esm/puppeteer/bidi/HTTPRequest.d.ts +4 -2
- package/lib/esm/puppeteer/bidi/HTTPRequest.d.ts.map +1 -1
- package/lib/esm/puppeteer/bidi/HTTPRequest.js +15 -6
- package/lib/esm/puppeteer/bidi/HTTPRequest.js.map +1 -1
- package/lib/esm/puppeteer/bidi/Page.d.ts +6 -1
- package/lib/esm/puppeteer/bidi/Page.d.ts.map +1 -1
- package/lib/esm/puppeteer/bidi/Page.js +42 -14
- package/lib/esm/puppeteer/bidi/Page.js.map +1 -1
- package/lib/esm/puppeteer/bidi/core/Browser.d.ts.map +1 -1
- package/lib/esm/puppeteer/bidi/core/Browser.js +24 -2
- package/lib/esm/puppeteer/bidi/core/Browser.js.map +1 -1
- package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
- package/lib/esm/puppeteer/bidi/core/BrowsingContext.js +1 -3
- package/lib/esm/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
- package/lib/esm/puppeteer/cdp/Accessibility.js +0 -20
- package/lib/esm/puppeteer/cdp/Accessibility.js.map +1 -1
- package/lib/esm/puppeteer/cdp/HTTPRequest.d.ts +1 -0
- package/lib/esm/puppeteer/cdp/HTTPRequest.d.ts.map +1 -1
- package/lib/esm/puppeteer/cdp/HTTPRequest.js +3 -0
- package/lib/esm/puppeteer/cdp/HTTPRequest.js.map +1 -1
- package/lib/esm/puppeteer/cdp/NetworkManager.d.ts +1 -1
- package/lib/esm/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
- package/lib/esm/puppeteer/cdp/NetworkManager.js +8 -2
- package/lib/esm/puppeteer/cdp/NetworkManager.js.map +1 -1
- package/lib/esm/puppeteer/cdp/Page.d.ts +5 -1
- package/lib/esm/puppeteer/cdp/Page.d.ts.map +1 -1
- package/lib/esm/puppeteer/cdp/Page.js +8 -2
- package/lib/esm/puppeteer/cdp/Page.js.map +1 -1
- package/lib/esm/puppeteer/cdp/PredefinedNetworkConditions.d.ts +13 -22
- package/lib/esm/puppeteer/cdp/PredefinedNetworkConditions.d.ts.map +1 -1
- package/lib/esm/puppeteer/cdp/PredefinedNetworkConditions.js +13 -22
- package/lib/esm/puppeteer/cdp/PredefinedNetworkConditions.js.map +1 -1
- package/lib/esm/puppeteer/common/Device.d.ts +6 -8
- package/lib/esm/puppeteer/common/Device.d.ts.map +1 -1
- package/lib/esm/puppeteer/common/Device.js +6 -8
- package/lib/esm/puppeteer/common/Device.js.map +1 -1
- package/lib/esm/puppeteer/generated/injected.d.ts +1 -1
- package/lib/esm/puppeteer/generated/injected.js +1 -1
- package/lib/esm/puppeteer/generated/version.d.ts +1 -1
- package/lib/esm/puppeteer/generated/version.js +1 -1
- package/lib/esm/puppeteer/node/BrowserLauncher.d.ts +1 -1
- package/lib/esm/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
- package/lib/esm/puppeteer/node/BrowserLauncher.js +12 -4
- package/lib/esm/puppeteer/node/BrowserLauncher.js.map +1 -1
- package/lib/esm/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
- package/lib/esm/puppeteer/node/ChromeLauncher.js +1 -0
- package/lib/esm/puppeteer/node/ChromeLauncher.js.map +1 -1
- package/lib/esm/puppeteer/node/PipeTransport.d.ts.map +1 -1
- package/lib/esm/puppeteer/node/PipeTransport.js +15 -16
- package/lib/esm/puppeteer/node/PipeTransport.js.map +1 -1
- package/lib/esm/puppeteer/node/PuppeteerNode.d.ts +5 -7
- package/lib/esm/puppeteer/node/PuppeteerNode.d.ts.map +1 -1
- package/lib/esm/puppeteer/node/PuppeteerNode.js +5 -7
- package/lib/esm/puppeteer/node/PuppeteerNode.js.map +1 -1
- package/lib/esm/puppeteer/revisions.d.ts +3 -3
- package/lib/esm/puppeteer/revisions.js +3 -3
- package/lib/esm/puppeteer/util/Function.d.ts.map +1 -1
- package/lib/esm/puppeteer/util/Function.js +16 -25
- package/lib/esm/puppeteer/util/Function.js.map +1 -1
- package/lib/types.d.ts +201 -227
- package/package.json +16 -16
- package/src/api/Browser.ts +1 -1
- package/src/api/Dialog.ts +8 -10
- package/src/api/ElementHandle.ts +27 -29
- package/src/api/Frame.ts +34 -38
- package/src/api/HTTPRequest.ts +17 -14
- package/src/api/Page.ts +105 -110
- package/src/bidi/Browser.ts +5 -3
- package/src/bidi/Frame.ts +5 -1
- package/src/bidi/HTTPRequest.ts +28 -3
- package/src/bidi/Page.ts +66 -15
- package/src/bidi/core/Browser.ts +28 -2
- package/src/bidi/core/BrowsingContext.ts +0 -1
- package/src/cdp/Accessibility.ts +1 -21
- package/src/cdp/HTTPRequest.ts +4 -0
- package/src/cdp/NetworkManager.ts +8 -1
- package/src/cdp/Page.ts +21 -5
- package/src/cdp/PredefinedNetworkConditions.ts +13 -22
- package/src/common/Device.ts +6 -8
- package/src/generated/injected.ts +1 -1
- package/src/generated/version.ts +1 -1
- package/src/node/BrowserLauncher.ts +19 -4
- package/src/node/ChromeLauncher.ts +1 -0
- package/src/node/PipeTransport.ts +15 -17
- package/src/node/PuppeteerNode.ts +5 -7
- package/src/revisions.ts +3 -3
- package/src/util/Function.ts +22 -30
package/src/api/Page.ts
CHANGED
|
@@ -650,13 +650,11 @@ export function setDefaultScreenshotOptions(options: ScreenshotOptions): void {
|
|
|
650
650
|
* ```ts
|
|
651
651
|
* import puppeteer from 'puppeteer';
|
|
652
652
|
*
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
* await browser.close();
|
|
659
|
-
* })();
|
|
653
|
+
* const browser = await puppeteer.launch();
|
|
654
|
+
* const page = await browser.newPage();
|
|
655
|
+
* await page.goto('https://example.com');
|
|
656
|
+
* await page.screenshot({path: 'screenshot.png'});
|
|
657
|
+
* await browser.close();
|
|
660
658
|
* ```
|
|
661
659
|
*
|
|
662
660
|
* The Page class extends from Puppeteer's {@link EventEmitter} class and will
|
|
@@ -949,21 +947,19 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
|
|
949
947
|
*
|
|
950
948
|
* ```ts
|
|
951
949
|
* import puppeteer from 'puppeteer';
|
|
952
|
-
*
|
|
953
|
-
*
|
|
954
|
-
*
|
|
955
|
-
*
|
|
956
|
-
*
|
|
957
|
-
*
|
|
958
|
-
*
|
|
959
|
-
*
|
|
960
|
-
* )
|
|
961
|
-
*
|
|
962
|
-
*
|
|
963
|
-
*
|
|
964
|
-
*
|
|
965
|
-
* await browser.close();
|
|
966
|
-
* })();
|
|
950
|
+
* const browser = await puppeteer.launch();
|
|
951
|
+
* const page = await browser.newPage();
|
|
952
|
+
* await page.setRequestInterception(true);
|
|
953
|
+
* page.on('request', interceptedRequest => {
|
|
954
|
+
* if (
|
|
955
|
+
* interceptedRequest.url().endsWith('.png') ||
|
|
956
|
+
* interceptedRequest.url().endsWith('.jpg')
|
|
957
|
+
* )
|
|
958
|
+
* interceptedRequest.abort();
|
|
959
|
+
* else interceptedRequest.continue();
|
|
960
|
+
* });
|
|
961
|
+
* await page.goto('https://example.com');
|
|
962
|
+
* await browser.close();
|
|
967
963
|
* ```
|
|
968
964
|
*
|
|
969
965
|
* @param value - Whether to enable request interception.
|
|
@@ -1010,14 +1006,12 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
|
|
1010
1006
|
* import {PredefinedNetworkConditions} from 'puppeteer';
|
|
1011
1007
|
* const slow3G = PredefinedNetworkConditions['Slow 3G'];
|
|
1012
1008
|
*
|
|
1013
|
-
*
|
|
1014
|
-
*
|
|
1015
|
-
*
|
|
1016
|
-
*
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
* await browser.close();
|
|
1020
|
-
* })();
|
|
1009
|
+
* const browser = await puppeteer.launch();
|
|
1010
|
+
* const page = await browser.newPage();
|
|
1011
|
+
* await page.emulateNetworkConditions(slow3G);
|
|
1012
|
+
* await page.goto('https://www.google.com');
|
|
1013
|
+
* // other actions...
|
|
1014
|
+
* await browser.close();
|
|
1021
1015
|
* ```
|
|
1022
1016
|
*
|
|
1023
1017
|
* @param networkConditions - Passing `null` disables network condition
|
|
@@ -1552,21 +1546,19 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
|
|
1552
1546
|
* import puppeteer from 'puppeteer';
|
|
1553
1547
|
* import crypto from 'crypto';
|
|
1554
1548
|
*
|
|
1555
|
-
*
|
|
1556
|
-
*
|
|
1557
|
-
*
|
|
1558
|
-
*
|
|
1559
|
-
*
|
|
1560
|
-
*
|
|
1561
|
-
*
|
|
1562
|
-
*
|
|
1563
|
-
*
|
|
1564
|
-
*
|
|
1565
|
-
*
|
|
1566
|
-
*
|
|
1567
|
-
*
|
|
1568
|
-
* await browser.close();
|
|
1569
|
-
* })();
|
|
1549
|
+
* const browser = await puppeteer.launch();
|
|
1550
|
+
* const page = await browser.newPage();
|
|
1551
|
+
* page.on('console', msg => console.log(msg.text()));
|
|
1552
|
+
* await page.exposeFunction('md5', text =>
|
|
1553
|
+
* crypto.createHash('md5').update(text).digest('hex'),
|
|
1554
|
+
* );
|
|
1555
|
+
* await page.evaluate(async () => {
|
|
1556
|
+
* // use window.md5 to compute hashes
|
|
1557
|
+
* const myString = 'PUPPETEER';
|
|
1558
|
+
* const myHash = await window.md5(myString);
|
|
1559
|
+
* console.log(`md5 of ${myString} is ${myHash}`);
|
|
1560
|
+
* });
|
|
1561
|
+
* await browser.close();
|
|
1570
1562
|
* ```
|
|
1571
1563
|
*
|
|
1572
1564
|
* @example
|
|
@@ -1576,25 +1568,23 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
|
|
1576
1568
|
* import puppeteer from 'puppeteer';
|
|
1577
1569
|
* import fs from 'node:fs';
|
|
1578
1570
|
*
|
|
1579
|
-
*
|
|
1580
|
-
*
|
|
1581
|
-
*
|
|
1582
|
-
*
|
|
1583
|
-
*
|
|
1584
|
-
*
|
|
1585
|
-
*
|
|
1586
|
-
*
|
|
1587
|
-
* else resolve(text);
|
|
1588
|
-
* });
|
|
1571
|
+
* const browser = await puppeteer.launch();
|
|
1572
|
+
* const page = await browser.newPage();
|
|
1573
|
+
* page.on('console', msg => console.log(msg.text()));
|
|
1574
|
+
* await page.exposeFunction('readfile', async filePath => {
|
|
1575
|
+
* return new Promise((resolve, reject) => {
|
|
1576
|
+
* fs.readFile(filePath, 'utf8', (err, text) => {
|
|
1577
|
+
* if (err) reject(err);
|
|
1578
|
+
* else resolve(text);
|
|
1589
1579
|
* });
|
|
1590
1580
|
* });
|
|
1591
|
-
*
|
|
1592
|
-
*
|
|
1593
|
-
*
|
|
1594
|
-
*
|
|
1595
|
-
*
|
|
1596
|
-
*
|
|
1597
|
-
*
|
|
1581
|
+
* });
|
|
1582
|
+
* await page.evaluate(async () => {
|
|
1583
|
+
* // use window.readfile to read contents of a file
|
|
1584
|
+
* const content = await window.readfile('/etc/hosts');
|
|
1585
|
+
* console.log(content);
|
|
1586
|
+
* });
|
|
1587
|
+
* await browser.close();
|
|
1598
1588
|
* ```
|
|
1599
1589
|
*
|
|
1600
1590
|
* @param name - Name of the function on the window object
|
|
@@ -1655,12 +1645,23 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
|
|
1655
1645
|
* @param userAgentData - Specific user agent client hint data to use in this
|
|
1656
1646
|
* page
|
|
1657
1647
|
* @returns Promise which resolves when the user agent is set.
|
|
1648
|
+
* @deprecated Use {@link Page.(setUserAgent:2) } instead.
|
|
1658
1649
|
*/
|
|
1659
1650
|
abstract setUserAgent(
|
|
1660
1651
|
userAgent: string,
|
|
1661
1652
|
userAgentMetadata?: Protocol.Emulation.UserAgentMetadata,
|
|
1662
1653
|
): Promise<void>;
|
|
1663
1654
|
|
|
1655
|
+
/**
|
|
1656
|
+
* @param options - Object containing user agent and optional user agent metadata
|
|
1657
|
+
* @returns Promise which resolves when the user agent is set.
|
|
1658
|
+
*/
|
|
1659
|
+
abstract setUserAgent(options: {
|
|
1660
|
+
userAgent?: string;
|
|
1661
|
+
userAgentMetadata?: Protocol.Emulation.UserAgentMetadata;
|
|
1662
|
+
platform?: string;
|
|
1663
|
+
}): Promise<void>;
|
|
1664
|
+
|
|
1664
1665
|
/**
|
|
1665
1666
|
* Object containing metrics as key/value pairs.
|
|
1666
1667
|
*
|
|
@@ -2014,7 +2015,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
|
|
2014
2015
|
*
|
|
2015
2016
|
* @remarks
|
|
2016
2017
|
* This method is a shortcut for calling two methods:
|
|
2017
|
-
* {@link Page.setUserAgent} and {@link Page.setViewport}.
|
|
2018
|
+
* {@link Page.(setUserAgent:2) } and {@link Page.setViewport}.
|
|
2018
2019
|
*
|
|
2019
2020
|
* This method will resize the page. A lot of websites don't expect phones to
|
|
2020
2021
|
* change size, so you should emulate before navigating to the page.
|
|
@@ -2025,19 +2026,17 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
|
|
2025
2026
|
* import {KnownDevices} from 'puppeteer';
|
|
2026
2027
|
* const iPhone = KnownDevices['iPhone 15 Pro'];
|
|
2027
2028
|
*
|
|
2028
|
-
*
|
|
2029
|
-
*
|
|
2030
|
-
*
|
|
2031
|
-
*
|
|
2032
|
-
*
|
|
2033
|
-
*
|
|
2034
|
-
* await browser.close();
|
|
2035
|
-
* })();
|
|
2029
|
+
* const browser = await puppeteer.launch();
|
|
2030
|
+
* const page = await browser.newPage();
|
|
2031
|
+
* await page.emulate(iPhone);
|
|
2032
|
+
* await page.goto('https://www.google.com');
|
|
2033
|
+
* // other actions...
|
|
2034
|
+
* await browser.close();
|
|
2036
2035
|
* ```
|
|
2037
2036
|
*/
|
|
2038
2037
|
async emulate(device: Device): Promise<void> {
|
|
2039
2038
|
await Promise.all([
|
|
2040
|
-
this.setUserAgent(device.userAgent),
|
|
2039
|
+
this.setUserAgent({userAgent: device.userAgent}),
|
|
2041
2040
|
this.setViewport(device.viewport),
|
|
2042
2041
|
]);
|
|
2043
2042
|
}
|
|
@@ -2196,25 +2195,23 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
|
|
2196
2195
|
* ```ts
|
|
2197
2196
|
* import puppeteer from 'puppeteer';
|
|
2198
2197
|
*
|
|
2199
|
-
*
|
|
2200
|
-
*
|
|
2201
|
-
*
|
|
2202
|
-
* await page.goto('https://v8.dev/blog/10-years');
|
|
2198
|
+
* const browser = await puppeteer.launch();
|
|
2199
|
+
* const page = await browser.newPage();
|
|
2200
|
+
* await page.goto('https://v8.dev/blog/10-years');
|
|
2203
2201
|
*
|
|
2204
|
-
*
|
|
2205
|
-
*
|
|
2202
|
+
* await page.emulateVisionDeficiency('achromatopsia');
|
|
2203
|
+
* await page.screenshot({path: 'achromatopsia.png'});
|
|
2206
2204
|
*
|
|
2207
|
-
*
|
|
2208
|
-
*
|
|
2205
|
+
* await page.emulateVisionDeficiency('deuteranopia');
|
|
2206
|
+
* await page.screenshot({path: 'deuteranopia.png'});
|
|
2209
2207
|
*
|
|
2210
|
-
*
|
|
2211
|
-
*
|
|
2208
|
+
* await page.emulateVisionDeficiency('blurredVision');
|
|
2209
|
+
* await page.screenshot({path: 'blurred-vision.png'});
|
|
2212
2210
|
*
|
|
2213
|
-
*
|
|
2214
|
-
*
|
|
2211
|
+
* await page.emulateVisionDeficiency('reducedContrast');
|
|
2212
|
+
* await page.screenshot({path: 'reduced-contrast.png'});
|
|
2215
2213
|
*
|
|
2216
|
-
*
|
|
2217
|
-
* })();
|
|
2214
|
+
* await browser.close();
|
|
2218
2215
|
* ```
|
|
2219
2216
|
*
|
|
2220
2217
|
* @param type - the type of deficiency to simulate, or `'none'` to reset.
|
|
@@ -2983,22 +2980,21 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
|
|
2983
2980
|
*
|
|
2984
2981
|
* ```ts
|
|
2985
2982
|
* import puppeteer from 'puppeteer';
|
|
2986
|
-
*
|
|
2987
|
-
*
|
|
2988
|
-
*
|
|
2989
|
-
*
|
|
2990
|
-
*
|
|
2991
|
-
*
|
|
2992
|
-
*
|
|
2993
|
-
*
|
|
2994
|
-
*
|
|
2995
|
-
*
|
|
2996
|
-
*
|
|
2997
|
-
*
|
|
2998
|
-
*
|
|
2999
|
-
*
|
|
3000
|
-
*
|
|
3001
|
-
* })();
|
|
2983
|
+
*
|
|
2984
|
+
* const browser = await puppeteer.launch();
|
|
2985
|
+
* const page = await browser.newPage();
|
|
2986
|
+
* let currentURL;
|
|
2987
|
+
* page
|
|
2988
|
+
* .waitForSelector('img')
|
|
2989
|
+
* .then(() => console.log('First URL with image: ' + currentURL));
|
|
2990
|
+
* for (currentURL of [
|
|
2991
|
+
* 'https://example.com',
|
|
2992
|
+
* 'https://google.com',
|
|
2993
|
+
* 'https://bbc.com',
|
|
2994
|
+
* ]) {
|
|
2995
|
+
* await page.goto(currentURL);
|
|
2996
|
+
* }
|
|
2997
|
+
* await browser.close();
|
|
3002
2998
|
* ```
|
|
3003
2999
|
*
|
|
3004
3000
|
* @param selector -
|
|
@@ -3052,14 +3048,13 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
|
|
3052
3048
|
*
|
|
3053
3049
|
* ```ts
|
|
3054
3050
|
* import puppeteer from 'puppeteer';
|
|
3055
|
-
*
|
|
3056
|
-
*
|
|
3057
|
-
*
|
|
3058
|
-
*
|
|
3059
|
-
*
|
|
3060
|
-
*
|
|
3061
|
-
*
|
|
3062
|
-
* })();
|
|
3051
|
+
*
|
|
3052
|
+
* const browser = await puppeteer.launch();
|
|
3053
|
+
* const page = await browser.newPage();
|
|
3054
|
+
* const watchDog = page.waitForFunction('window.innerWidth < 100');
|
|
3055
|
+
* await page.setViewport({width: 50, height: 50});
|
|
3056
|
+
* await watchDog;
|
|
3057
|
+
* await browser.close();
|
|
3063
3058
|
* ```
|
|
3064
3059
|
*
|
|
3065
3060
|
* @example
|
package/src/bidi/Browser.ts
CHANGED
|
@@ -92,10 +92,12 @@ export class BidiBrowser extends Browser {
|
|
|
92
92
|
},
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
+
// Subscribe to all WebDriver BiDi events. Also subscribe to CDP events if CDP
|
|
96
|
+
// connection is available.
|
|
95
97
|
await session.subscribe(
|
|
96
|
-
(
|
|
97
|
-
? BidiBrowser.subscribeModules
|
|
98
|
-
:
|
|
98
|
+
(opts.cdpConnection
|
|
99
|
+
? [...BidiBrowser.subscribeModules, ...BidiBrowser.subscribeCdpEvents]
|
|
100
|
+
: BidiBrowser.subscribeModules
|
|
99
101
|
).filter(module => {
|
|
100
102
|
if (!opts.networkEnabled) {
|
|
101
103
|
return (
|
package/src/bidi/Frame.ts
CHANGED
|
@@ -136,7 +136,11 @@ export class BidiFrame extends Frame {
|
|
|
136
136
|
});
|
|
137
137
|
|
|
138
138
|
this.browsingContext.on('request', ({request}) => {
|
|
139
|
-
const httpRequest = BidiHTTPRequest.from(
|
|
139
|
+
const httpRequest = BidiHTTPRequest.from(
|
|
140
|
+
request,
|
|
141
|
+
this,
|
|
142
|
+
this.page().isNetworkInterceptionEnabled,
|
|
143
|
+
);
|
|
140
144
|
request.once('success', () => {
|
|
141
145
|
this.page().trustedEmitter.emit(PageEvent.RequestFinished, httpRequest);
|
|
142
146
|
});
|
package/src/bidi/HTTPRequest.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type * as Bidi from 'webdriver-bidi-protocol';
|
|
|
9
9
|
import type {CDPSession} from '../api/CDPSession.js';
|
|
10
10
|
import type {
|
|
11
11
|
ContinueRequestOverrides,
|
|
12
|
+
InterceptResolutionState,
|
|
12
13
|
ResponseForRequest,
|
|
13
14
|
} from '../api/HTTPRequest.js';
|
|
14
15
|
import {
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
STATUS_TEXTS,
|
|
17
18
|
type ResourceType,
|
|
18
19
|
handleError,
|
|
20
|
+
InterceptResolutionAction,
|
|
19
21
|
} from '../api/HTTPRequest.js';
|
|
20
22
|
import {PageEvent} from '../api/Page.js';
|
|
21
23
|
import {UnsupportedOperation} from '../common/Errors.js';
|
|
@@ -34,9 +36,15 @@ export class BidiHTTPRequest extends HTTPRequest {
|
|
|
34
36
|
static from(
|
|
35
37
|
bidiRequest: Request,
|
|
36
38
|
frame: BidiFrame,
|
|
39
|
+
isNetworkInterceptionEnabled: boolean,
|
|
37
40
|
redirect?: BidiHTTPRequest,
|
|
38
41
|
): BidiHTTPRequest {
|
|
39
|
-
const request = new BidiHTTPRequest(
|
|
42
|
+
const request = new BidiHTTPRequest(
|
|
43
|
+
bidiRequest,
|
|
44
|
+
frame,
|
|
45
|
+
isNetworkInterceptionEnabled,
|
|
46
|
+
redirect,
|
|
47
|
+
);
|
|
40
48
|
request.#initialize();
|
|
41
49
|
return request;
|
|
42
50
|
}
|
|
@@ -50,12 +58,13 @@ export class BidiHTTPRequest extends HTTPRequest {
|
|
|
50
58
|
private constructor(
|
|
51
59
|
request: Request,
|
|
52
60
|
frame: BidiFrame,
|
|
61
|
+
isNetworkInterceptionEnabled: boolean,
|
|
53
62
|
redirect?: BidiHTTPRequest,
|
|
54
63
|
) {
|
|
55
64
|
super();
|
|
56
65
|
requests.set(request, this);
|
|
57
66
|
|
|
58
|
-
this.interception.enabled =
|
|
67
|
+
this.interception.enabled = isNetworkInterceptionEnabled;
|
|
59
68
|
|
|
60
69
|
this.#request = request;
|
|
61
70
|
this.#frame = frame;
|
|
@@ -69,7 +78,12 @@ export class BidiHTTPRequest extends HTTPRequest {
|
|
|
69
78
|
|
|
70
79
|
#initialize() {
|
|
71
80
|
this.#request.on('redirect', request => {
|
|
72
|
-
const httpRequest = BidiHTTPRequest.from(
|
|
81
|
+
const httpRequest = BidiHTTPRequest.from(
|
|
82
|
+
request,
|
|
83
|
+
this.#frame,
|
|
84
|
+
this.interception.enabled,
|
|
85
|
+
this,
|
|
86
|
+
);
|
|
73
87
|
this.#redirectChain.push(this);
|
|
74
88
|
|
|
75
89
|
request.once('success', () => {
|
|
@@ -108,6 +122,17 @@ export class BidiHTTPRequest extends HTTPRequest {
|
|
|
108
122
|
}
|
|
109
123
|
}
|
|
110
124
|
|
|
125
|
+
protected canBeIntercepted(): boolean {
|
|
126
|
+
return this.#request.isBlocked;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
override interceptResolutionState(): InterceptResolutionState {
|
|
130
|
+
if (!this.#request.isBlocked) {
|
|
131
|
+
return {action: InterceptResolutionAction.Disabled};
|
|
132
|
+
}
|
|
133
|
+
return super.interceptResolutionState();
|
|
134
|
+
}
|
|
135
|
+
|
|
111
136
|
override url(): string {
|
|
112
137
|
return this.#request.url;
|
|
113
138
|
}
|
package/src/bidi/Page.ts
CHANGED
|
@@ -141,20 +141,45 @@ export class BidiPage extends Page {
|
|
|
141
141
|
#userAgentInterception?: string;
|
|
142
142
|
#userAgentPreloadScript?: string;
|
|
143
143
|
override async setUserAgent(
|
|
144
|
-
|
|
144
|
+
userAgentOrOptions:
|
|
145
|
+
| string
|
|
146
|
+
| {
|
|
147
|
+
userAgent?: string;
|
|
148
|
+
userAgentMetadata?: Protocol.Emulation.UserAgentMetadata;
|
|
149
|
+
platform?: string;
|
|
150
|
+
},
|
|
145
151
|
userAgentMetadata?: Protocol.Emulation.UserAgentMetadata,
|
|
146
152
|
): Promise<void> {
|
|
147
|
-
|
|
153
|
+
let userAgent: string;
|
|
154
|
+
let metadata: Protocol.Emulation.UserAgentMetadata | undefined;
|
|
155
|
+
let platform: string | undefined;
|
|
156
|
+
|
|
157
|
+
if (typeof userAgentOrOptions === 'string') {
|
|
158
|
+
userAgent = userAgentOrOptions;
|
|
159
|
+
metadata = userAgentMetadata;
|
|
160
|
+
} else {
|
|
161
|
+
userAgent =
|
|
162
|
+
userAgentOrOptions.userAgent ??
|
|
163
|
+
(await this.#browserContext.browser().userAgent());
|
|
164
|
+
metadata = userAgentOrOptions.userAgentMetadata;
|
|
165
|
+
platform = userAgentOrOptions.platform;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (
|
|
169
|
+
!this.#browserContext.browser().cdpSupported &&
|
|
170
|
+
(metadata || platform)
|
|
171
|
+
) {
|
|
148
172
|
throw new UnsupportedOperation(
|
|
149
|
-
'Current Browser does not support `userAgentMetadata`',
|
|
173
|
+
'Current Browser does not support `userAgentMetadata` or `platform`',
|
|
150
174
|
);
|
|
151
175
|
} else if (
|
|
152
176
|
this.#browserContext.browser().cdpSupported &&
|
|
153
|
-
|
|
177
|
+
(metadata || platform)
|
|
154
178
|
) {
|
|
155
179
|
return await this._client().send('Network.setUserAgentOverride', {
|
|
156
180
|
userAgent: userAgent,
|
|
157
|
-
userAgentMetadata:
|
|
181
|
+
userAgentMetadata: metadata,
|
|
182
|
+
platform: platform,
|
|
158
183
|
});
|
|
159
184
|
}
|
|
160
185
|
const enable = userAgent !== '';
|
|
@@ -172,11 +197,20 @@ export class BidiPage extends Page {
|
|
|
172
197
|
enable,
|
|
173
198
|
);
|
|
174
199
|
|
|
175
|
-
const
|
|
200
|
+
const overrideNavigatorProperties = (
|
|
201
|
+
userAgent: string,
|
|
202
|
+
platform: string | undefined,
|
|
203
|
+
) => {
|
|
176
204
|
Object.defineProperty(navigator, 'userAgent', {
|
|
177
205
|
value: userAgent,
|
|
178
206
|
configurable: true,
|
|
179
207
|
});
|
|
208
|
+
if (platform) {
|
|
209
|
+
Object.defineProperty(navigator, 'platform', {
|
|
210
|
+
value: platform,
|
|
211
|
+
configurable: true,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
180
214
|
};
|
|
181
215
|
|
|
182
216
|
const frames = [this.#frame];
|
|
@@ -191,19 +225,27 @@ export class BidiPage extends Page {
|
|
|
191
225
|
}
|
|
192
226
|
const [evaluateToken] = await Promise.all([
|
|
193
227
|
enable
|
|
194
|
-
? this.evaluateOnNewDocument(
|
|
228
|
+
? this.evaluateOnNewDocument(
|
|
229
|
+
overrideNavigatorProperties,
|
|
230
|
+
userAgent,
|
|
231
|
+
platform || undefined,
|
|
232
|
+
)
|
|
195
233
|
: undefined,
|
|
196
234
|
// When we disable the UserAgent we want to
|
|
197
235
|
// evaluate the original value in all Browsing Contexts
|
|
198
236
|
...frames.map(frame => {
|
|
199
|
-
return frame.evaluate(
|
|
237
|
+
return frame.evaluate(
|
|
238
|
+
overrideNavigatorProperties,
|
|
239
|
+
userAgent,
|
|
240
|
+
platform || undefined,
|
|
241
|
+
);
|
|
200
242
|
}),
|
|
201
243
|
]);
|
|
202
244
|
this.#userAgentPreloadScript = evaluateToken?.identifier;
|
|
203
245
|
}
|
|
204
246
|
|
|
205
247
|
override async setBypassCSP(enabled: boolean): Promise<void> {
|
|
206
|
-
// TODO: handle CDP-specific cases such as
|
|
248
|
+
// TODO: handle CDP-specific cases such as MPArch.
|
|
207
249
|
await this._client().send('Page.setBypassCSP', {enabled});
|
|
208
250
|
}
|
|
209
251
|
|
|
@@ -584,7 +626,7 @@ export class BidiPage extends Page {
|
|
|
584
626
|
);
|
|
585
627
|
return;
|
|
586
628
|
}
|
|
587
|
-
// TODO: handle CDP-specific cases such as
|
|
629
|
+
// TODO: handle CDP-specific cases such as MPArch.
|
|
588
630
|
await this._client().send('Network.setCacheDisabled', {
|
|
589
631
|
cacheDisabled: !enabled,
|
|
590
632
|
});
|
|
@@ -669,11 +711,20 @@ export class BidiPage extends Page {
|
|
|
669
711
|
return [...this.#workers];
|
|
670
712
|
}
|
|
671
713
|
|
|
672
|
-
|
|
714
|
+
get isNetworkInterceptionEnabled(): boolean {
|
|
715
|
+
return (
|
|
716
|
+
Boolean(this.#requestInterception) ||
|
|
717
|
+
Boolean(this.#extraHeadersInterception) ||
|
|
718
|
+
Boolean(this.#authInterception) ||
|
|
719
|
+
Boolean(this.#userAgentInterception)
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
#requestInterception?: string;
|
|
673
724
|
override async setRequestInterception(enable: boolean): Promise<void> {
|
|
674
|
-
this.#
|
|
725
|
+
this.#requestInterception = await this.#toggleInterception(
|
|
675
726
|
[Bidi.Network.InterceptPhase.BeforeRequestSent],
|
|
676
|
-
this.#
|
|
727
|
+
this.#requestInterception,
|
|
677
728
|
enable,
|
|
678
729
|
);
|
|
679
730
|
}
|
|
@@ -1012,7 +1063,7 @@ export function bidiToPuppeteerCookie(
|
|
|
1012
1063
|
): Cookie {
|
|
1013
1064
|
const partitionKey = bidiCookie[CDP_SPECIFIC_PREFIX + 'partitionKey'];
|
|
1014
1065
|
|
|
1015
|
-
function
|
|
1066
|
+
function getPartitionKey(): {partitionKey?: Cookie['partitionKey']} {
|
|
1016
1067
|
if (typeof partitionKey === 'string') {
|
|
1017
1068
|
return {partitionKey};
|
|
1018
1069
|
}
|
|
@@ -1054,7 +1105,7 @@ export function bidiToPuppeteerCookie(
|
|
|
1054
1105
|
'partitionKeyOpaque',
|
|
1055
1106
|
'priority',
|
|
1056
1107
|
),
|
|
1057
|
-
...
|
|
1108
|
+
...getPartitionKey(),
|
|
1058
1109
|
};
|
|
1059
1110
|
}
|
|
1060
1111
|
|
package/src/bidi/core/Browser.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import type * as Bidi from 'webdriver-bidi-protocol';
|
|
8
8
|
|
|
9
9
|
import type {BrowserContextOptions} from '../../api/Browser.js';
|
|
10
|
+
import {UnsupportedOperation} from '../../common/Errors.js';
|
|
10
11
|
import {EventEmitter} from '../../common/EventEmitter.js';
|
|
11
12
|
import {inertIfDisposed, throwIfDisposed} from '../../util/decorators.js';
|
|
12
13
|
import {DisposableStack, disposeSymbol} from '../../util/disposable.js';
|
|
@@ -232,11 +233,36 @@ export class Browser extends EventEmitter<{
|
|
|
232
233
|
noProxy: options.proxyBypassList,
|
|
233
234
|
};
|
|
234
235
|
const {
|
|
235
|
-
result: {userContext
|
|
236
|
+
result: {userContext},
|
|
236
237
|
} = await this.session.send('browser.createUserContext', {
|
|
237
238
|
proxy: proxyConfig,
|
|
238
239
|
});
|
|
239
|
-
|
|
240
|
+
if (options.downloadBehavior?.policy === 'allowAndName') {
|
|
241
|
+
throw new UnsupportedOperation(
|
|
242
|
+
'`allowAndName` is not supported in WebDriver BiDi',
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
if (options.downloadBehavior?.policy === 'allow') {
|
|
246
|
+
if (options.downloadBehavior.downloadPath === undefined) {
|
|
247
|
+
throw new UnsupportedOperation(
|
|
248
|
+
'`downloadPath` is required in `allow` download behavior',
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
await this.session.send('browser.setDownloadBehavior', {
|
|
252
|
+
downloadBehavior: {
|
|
253
|
+
type: 'allowed',
|
|
254
|
+
destinationFolder: options.downloadBehavior.downloadPath,
|
|
255
|
+
},
|
|
256
|
+
userContexts: [userContext],
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
if (options.downloadBehavior?.policy === 'deny') {
|
|
260
|
+
await this.session.send('browser.setDownloadBehavior', {
|
|
261
|
+
downloadBehavior: {type: 'denied'},
|
|
262
|
+
userContexts: [userContext],
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
return this.#createUserContext(userContext);
|
|
240
266
|
}
|
|
241
267
|
|
|
242
268
|
@throwIfDisposed<Browser>(browser => {
|
|
@@ -713,7 +713,6 @@ export class BrowsingContext extends EventEmitter<{
|
|
|
713
713
|
|
|
714
714
|
async setJavaScriptEnabled(enabled: boolean): Promise<void> {
|
|
715
715
|
await this.userContext.browser.session.send(
|
|
716
|
-
// @ts-expect-error missing types
|
|
717
716
|
'emulation.setScriptingEnabled',
|
|
718
717
|
{
|
|
719
718
|
// Enabled `null` means `default`, `false` means `disabled`.
|
package/src/cdp/Accessibility.ts
CHANGED
|
@@ -319,7 +319,6 @@ class AXNode {
|
|
|
319
319
|
#name: string;
|
|
320
320
|
#role: string;
|
|
321
321
|
#ignored: boolean;
|
|
322
|
-
#cachedHasFocusableChild?: boolean;
|
|
323
322
|
#realm: Realm;
|
|
324
323
|
|
|
325
324
|
constructor(realm: Realm, payload: Protocol.Accessibility.AXNode) {
|
|
@@ -362,19 +361,6 @@ class AXNode {
|
|
|
362
361
|
);
|
|
363
362
|
}
|
|
364
363
|
|
|
365
|
-
#hasFocusableChild(): boolean {
|
|
366
|
-
if (this.#cachedHasFocusableChild === undefined) {
|
|
367
|
-
this.#cachedHasFocusableChild = false;
|
|
368
|
-
for (const child of this.children) {
|
|
369
|
-
if (child.#focusable || child.#hasFocusableChild()) {
|
|
370
|
-
this.#cachedHasFocusableChild = true;
|
|
371
|
-
break;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
return this.#cachedHasFocusableChild;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
364
|
public find(predicate: (x: AXNode) => boolean): AXNode | null {
|
|
379
365
|
if (predicate(this)) {
|
|
380
366
|
return this;
|
|
@@ -420,16 +406,10 @@ class AXNode {
|
|
|
420
406
|
break;
|
|
421
407
|
}
|
|
422
408
|
|
|
423
|
-
// Here and below: Android heuristics
|
|
424
|
-
if (this.#hasFocusableChild()) {
|
|
425
|
-
return false;
|
|
426
|
-
}
|
|
427
|
-
if (this.#focusable && this.#name && this.#name !== 'Document') {
|
|
428
|
-
return true;
|
|
429
|
-
}
|
|
430
409
|
if (this.#role === 'heading' && this.#name) {
|
|
431
410
|
return true;
|
|
432
411
|
}
|
|
412
|
+
|
|
433
413
|
return false;
|
|
434
414
|
}
|
|
435
415
|
|