@browserless.io/browserless 2.14.0 → 2.16.0-beta-1

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +5 -2
  2. package/README.md +7 -6
  3. package/build/browserless.d.ts +0 -2
  4. package/build/browsers/browsers.cdp.d.ts +1 -6
  5. package/build/browsers/browsers.cdp.js +12 -10
  6. package/build/browsers/browsers.playwright.d.ts +33 -37
  7. package/build/browsers/index.d.ts +1 -2
  8. package/build/browsers/index.js +1 -1
  9. package/build/config.d.ts +0 -2
  10. package/build/file-system.d.ts +0 -2
  11. package/build/hooks.d.ts +0 -1
  12. package/build/http.d.ts +0 -1
  13. package/build/limiter.d.ts +5 -0
  14. package/build/limiter.js +3 -0
  15. package/build/limiter.spec.js +20 -1
  16. package/build/metrics.d.ts +0 -1
  17. package/build/monitoring.d.ts +0 -1
  18. package/build/router.d.ts +0 -3
  19. package/build/routes/chrome/http/content.post.body.json +16 -9
  20. package/build/routes/chrome/http/pdf.post.body.json +16 -9
  21. package/build/routes/chrome/http/scrape.post.body.json +16 -9
  22. package/build/routes/chrome/http/screenshot.post.body.json +16 -9
  23. package/build/routes/chromium/http/content.post.body.json +16 -9
  24. package/build/routes/chromium/http/pdf.post.body.json +16 -9
  25. package/build/routes/chromium/http/scrape.post.body.json +16 -9
  26. package/build/routes/chromium/http/screenshot.post.body.json +16 -9
  27. package/build/routes/firefox/ws/playwright.d.ts +0 -2
  28. package/build/routes/management/http/active.get.d.ts +0 -1
  29. package/build/routes/management/http/config.get.d.ts +0 -1
  30. package/build/routes/management/http/metrics-total.get.d.ts +0 -1
  31. package/build/routes/management/http/metrics.get.d.ts +0 -1
  32. package/build/routes/management/http/pressure.get.d.ts +0 -1
  33. package/build/routes/management/http/sessions.get.d.ts +0 -1
  34. package/build/routes/management/http/static.get.d.ts +0 -1
  35. package/build/routes/webkit/ws/playwright.d.ts +0 -2
  36. package/build/server.d.ts +0 -4
  37. package/build/shared/browser.ws.d.ts +0 -2
  38. package/build/shared/chromium.playwright.ws.d.ts +0 -2
  39. package/build/shared/chromium.ws.d.ts +0 -2
  40. package/build/shared/content.http.d.ts +0 -1
  41. package/build/shared/download.http.d.ts +0 -1
  42. package/build/shared/function.http.d.ts +0 -1
  43. package/build/shared/page.ws.d.ts +0 -2
  44. package/build/shared/pdf.http.d.ts +0 -1
  45. package/build/shared/performance.http.d.ts +0 -1
  46. package/build/shared/scrape.http.d.ts +0 -1
  47. package/build/shared/screenshot.http.d.ts +0 -1
  48. package/build/token.d.ts +0 -1
  49. package/build/types.d.ts +0 -3
  50. package/build/utils.d.ts +1 -3
  51. package/build/utils.js +5 -1
  52. package/build/webhooks.d.ts +0 -1
  53. package/package.json +17 -17
  54. package/scripts/build-schemas.js +7 -3
  55. package/src/browsers/browsers.cdp.ts +25 -18
  56. package/src/browsers/browsers.playwright.ts +12 -5
  57. package/src/browsers/index.ts +1 -1
  58. package/src/limiter.spec.ts +28 -1
  59. package/src/limiter.ts +8 -0
  60. package/src/utils.ts +8 -2
  61. package/static/docs/swagger.json +74 -18
  62. package/static/docs/swagger.min.json +73 -17
  63. package/static/function/client.js +229 -94
  64. package/static/function/index.html +229 -94
@@ -16915,6 +16915,15 @@
16915
16915
  };
16916
16916
  });
16917
16917
  }
16918
+ function fromAbortSignal(signal, cause) {
16919
+ return signal ? fromEvent(signal, "abort").pipe(map(() => {
16920
+ if (signal.reason instanceof Error) {
16921
+ signal.reason.cause = cause;
16922
+ throw signal.reason;
16923
+ }
16924
+ throw new Error(signal.reason, { cause });
16925
+ })) : NEVER;
16926
+ }
16918
16927
  function filterAsync(predicate) {
16919
16928
  return mergeMap((value) => {
16920
16929
  return from(Promise.resolve(predicate(value))).pipe(filter((isMatch) => {
@@ -18655,8 +18664,8 @@
18655
18664
  })(LocatorEvent || (LocatorEvent = {}));
18656
18665
  var Locator = class extends EventEmitter2 {
18657
18666
  /**
18658
- * Creates a race between multiple locators but ensures that only a single one
18659
- * acts.
18667
+ * Creates a race between multiple locators trying to locate elements in
18668
+ * parallel but ensures that only a single element receives the action.
18660
18669
  *
18661
18670
  * @public
18662
18671
  */
@@ -18688,12 +18697,7 @@
18688
18697
  retryAndRaceWithSignalAndTimer: (signal, cause) => {
18689
18698
  const candidates = [];
18690
18699
  if (signal) {
18691
- candidates.push(fromEvent(signal, "abort").pipe(map(() => {
18692
- if (signal.reason instanceof Error) {
18693
- signal.reason.cause = cause;
18694
- }
18695
- throw signal.reason;
18696
- })));
18700
+ candidates.push(fromAbortSignal(signal, cause));
18697
18701
  }
18698
18702
  candidates.push(timeout(this._timeout, cause));
18699
18703
  return pipe(retry({ delay: RETRY_DELAY }), raceWith(...candidates));
@@ -18703,26 +18707,59 @@
18703
18707
  get timeout() {
18704
18708
  return this._timeout;
18705
18709
  }
18710
+ /**
18711
+ * Creates a new locator instance by cloning the current locator and setting
18712
+ * the total timeout for the locator actions.
18713
+ *
18714
+ * Pass `0` to disable timeout.
18715
+ *
18716
+ * @defaultValue `Page.getDefaultTimeout()`
18717
+ */
18706
18718
  setTimeout(timeout2) {
18707
18719
  const locator = this._clone();
18708
18720
  locator._timeout = timeout2;
18709
18721
  return locator;
18710
18722
  }
18723
+ /**
18724
+ * Creates a new locator instance by cloning the current locator with the
18725
+ * visibility property changed to the specified value.
18726
+ */
18711
18727
  setVisibility(visibility) {
18712
18728
  const locator = this._clone();
18713
18729
  locator.visibility = visibility;
18714
18730
  return locator;
18715
18731
  }
18732
+ /**
18733
+ * Creates a new locator instance by cloning the current locator and
18734
+ * specifying whether to wait for input elements to become enabled before the
18735
+ * action. Applicable to `click` and `fill` actions.
18736
+ *
18737
+ * @defaultValue `true`
18738
+ */
18716
18739
  setWaitForEnabled(value) {
18717
18740
  const locator = this._clone();
18718
18741
  locator.#waitForEnabled = value;
18719
18742
  return locator;
18720
18743
  }
18744
+ /**
18745
+ * Creates a new locator instance by cloning the current locator and
18746
+ * specifying whether the locator should scroll the element into viewport if
18747
+ * it is not in the viewport already.
18748
+ *
18749
+ * @defaultValue `true`
18750
+ */
18721
18751
  setEnsureElementIsInTheViewport(value) {
18722
18752
  const locator = this._clone();
18723
18753
  locator.#ensureElementIsInTheViewport = value;
18724
18754
  return locator;
18725
18755
  }
18756
+ /**
18757
+ * Creates a new locator instance by cloning the current locator and
18758
+ * specifying whether the locator has to wait for the element's bounding box
18759
+ * to be same between two consecutive animation frames.
18760
+ *
18761
+ * @defaultValue `true`
18762
+ */
18726
18763
  setWaitForStableBoundingBox(value) {
18727
18764
  const locator = this._clone();
18728
18765
  locator.#waitForStableBoundingBox = value;
@@ -19029,21 +19066,30 @@
19029
19066
  mapHandle(mapper) {
19030
19067
  return new MappedLocator(this._clone(), mapper);
19031
19068
  }
19069
+ /**
19070
+ * Clicks the located element.
19071
+ */
19032
19072
  click(options) {
19033
19073
  return firstValueFrom(this.#click(options));
19034
19074
  }
19035
19075
  /**
19036
19076
  * Fills out the input identified by the locator using the provided value. The
19037
19077
  * type of the input is determined at runtime and the appropriate fill-out
19038
- * method is chosen based on the type. contenteditable, selector, inputs are
19039
- * supported.
19078
+ * method is chosen based on the type. `contenteditable`, select, textarea and
19079
+ * input elements are supported.
19040
19080
  */
19041
19081
  fill(value, options) {
19042
19082
  return firstValueFrom(this.#fill(value, options));
19043
19083
  }
19084
+ /**
19085
+ * Hovers over the located element.
19086
+ */
19044
19087
  hover(options) {
19045
19088
  return firstValueFrom(this.#hover(options));
19046
19089
  }
19090
+ /**
19091
+ * Scrolls the located element.
19092
+ */
19047
19093
  scroll(options) {
19048
19094
  return firstValueFrom(this.#scroll(options));
19049
19095
  }
@@ -19435,20 +19481,20 @@
19435
19481
  * the selector, the return value resolves to `null`.
19436
19482
  *
19437
19483
  * @param selector -
19438
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
19484
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
19439
19485
  * to query page for.
19440
19486
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
19441
19487
  * can be passed as-is and a
19442
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
19488
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
19443
19489
  * allows quering by
19444
19490
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
19445
19491
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
19446
19492
  * and
19447
19493
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
19448
19494
  * and
19449
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
19450
- * Alternatively, you can specify a selector type using a prefix
19451
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
19495
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
19496
+ * Alternatively, you can specify the selector type using a
19497
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
19452
19498
  *
19453
19499
  * @remarks
19454
19500
  *
@@ -19462,20 +19508,20 @@
19462
19508
  * match the selector, the return value resolves to `[]`.
19463
19509
  *
19464
19510
  * @param selector -
19465
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
19511
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
19466
19512
  * to query page for.
19467
19513
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
19468
19514
  * can be passed as-is and a
19469
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
19515
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
19470
19516
  * allows quering by
19471
19517
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
19472
19518
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
19473
19519
  * and
19474
19520
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
19475
19521
  * and
19476
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
19477
- * Alternatively, you can specify a selector type using a prefix
19478
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
19522
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
19523
+ * Alternatively, you can specify the selector type using a
19524
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
19479
19525
  *
19480
19526
  * @remarks
19481
19527
  *
@@ -19596,20 +19642,20 @@
19596
19642
  * ```
19597
19643
  *
19598
19644
  * @param selector -
19599
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
19645
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
19600
19646
  * to query page for.
19601
19647
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
19602
19648
  * can be passed as-is and a
19603
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
19649
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
19604
19650
  * allows quering by
19605
19651
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
19606
19652
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
19607
19653
  * and
19608
19654
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
19609
19655
  * and
19610
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
19611
- * Alternatively, you can specify a selector type using a prefix
19612
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
19656
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
19657
+ * Alternatively, you can specify the selector type using a
19658
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
19613
19659
  * @param pageFunction - the function to be evaluated in the page context.
19614
19660
  * Will be passed the result of the element matching the selector as its
19615
19661
  * first argument.
@@ -19669,20 +19715,20 @@
19669
19715
  * ```
19670
19716
  *
19671
19717
  * @param selector -
19672
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
19718
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
19673
19719
  * to query page for.
19674
19720
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
19675
19721
  * can be passed as-is and a
19676
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
19722
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
19677
19723
  * allows quering by
19678
19724
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
19679
19725
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
19680
19726
  * and
19681
19727
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
19682
19728
  * and
19683
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
19684
- * Alternatively, you can specify a selector type using a prefix
19685
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
19729
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
19730
+ * Alternatively, you can specify the selector type using a
19731
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
19686
19732
  * @param pageFunction - the function to be evaluated in the page context.
19687
19733
  * Will be passed an array of matching elements as its first argument.
19688
19734
  * @param args - any additional arguments to pass through to `pageFunction`.
@@ -19798,7 +19844,7 @@
19798
19844
  * {@link Page.setDefaultTimeout} method.
19799
19845
  */
19800
19846
  waitForRequest(urlOrPredicate, options = {}) {
19801
- const { timeout: ms = this._timeoutSettings.timeout() } = options;
19847
+ const { timeout: ms = this._timeoutSettings.timeout(), signal } = options;
19802
19848
  if (typeof urlOrPredicate === "string") {
19803
19849
  const url = urlOrPredicate;
19804
19850
  urlOrPredicate = (request) => {
@@ -19809,7 +19855,7 @@
19809
19855
  this,
19810
19856
  "request"
19811
19857
  /* PageEvent.Request */
19812
- ).pipe(filterAsync(urlOrPredicate), raceWith(timeout(ms), fromEmitterEvent(
19858
+ ).pipe(filterAsync(urlOrPredicate), raceWith(timeout(ms), fromAbortSignal(signal), fromEmitterEvent(
19813
19859
  this,
19814
19860
  "close"
19815
19861
  /* PageEvent.Close */
@@ -19846,7 +19892,7 @@
19846
19892
  * the {@link Page.setDefaultTimeout} method.
19847
19893
  */
19848
19894
  waitForResponse(urlOrPredicate, options = {}) {
19849
- const { timeout: ms = this._timeoutSettings.timeout() } = options;
19895
+ const { timeout: ms = this._timeoutSettings.timeout(), signal } = options;
19850
19896
  if (typeof urlOrPredicate === "string") {
19851
19897
  const url = urlOrPredicate;
19852
19898
  urlOrPredicate = (response) => {
@@ -19857,7 +19903,7 @@
19857
19903
  this,
19858
19904
  "response"
19859
19905
  /* PageEvent.Response */
19860
- ).pipe(filterAsync(urlOrPredicate), raceWith(timeout(ms), fromEmitterEvent(
19906
+ ).pipe(filterAsync(urlOrPredicate), raceWith(timeout(ms), fromAbortSignal(signal), fromEmitterEvent(
19861
19907
  this,
19862
19908
  "close"
19863
19909
  /* PageEvent.Close */
@@ -19879,14 +19925,14 @@
19879
19925
  * @internal
19880
19926
  */
19881
19927
  waitForNetworkIdle$(options = {}) {
19882
- const { timeout: ms = this._timeoutSettings.timeout(), idleTime = NETWORK_IDLE_TIME, concurrency = 0 } = options;
19928
+ const { timeout: ms = this._timeoutSettings.timeout(), idleTime = NETWORK_IDLE_TIME, concurrency = 0, signal } = options;
19883
19929
  return this.#inflight$.pipe(switchMap((inflight) => {
19884
19930
  if (inflight > concurrency) {
19885
19931
  return EMPTY;
19886
19932
  }
19887
19933
  return timer(idleTime);
19888
19934
  }), map(() => {
19889
- }), raceWith(timeout(ms), fromEmitterEvent(
19935
+ }), raceWith(timeout(ms), fromAbortSignal(signal), fromEmitterEvent(
19890
19936
  this,
19891
19937
  "close"
19892
19938
  /* PageEvent.Close */
@@ -19906,7 +19952,7 @@
19906
19952
  * ```
19907
19953
  */
19908
19954
  async waitForFrame(urlOrPredicate, options = {}) {
19909
- const { timeout: ms = this.getDefaultTimeout() } = options;
19955
+ const { timeout: ms = this.getDefaultTimeout(), signal } = options;
19910
19956
  if (isString3(urlOrPredicate)) {
19911
19957
  urlOrPredicate = (frame) => {
19912
19958
  return urlOrPredicate === frame.url();
@@ -19920,7 +19966,7 @@
19920
19966
  this,
19921
19967
  "framenavigated"
19922
19968
  /* PageEvent.FrameNavigated */
19923
- ), from(this.frames())).pipe(filterAsync(urlOrPredicate), first(), raceWith(timeout(ms), fromEmitterEvent(
19969
+ ), from(this.frames())).pipe(filterAsync(urlOrPredicate), first(), raceWith(timeout(ms), fromAbortSignal(signal), fromEmitterEvent(
19924
19970
  this,
19925
19971
  "close"
19926
19972
  /* PageEvent.Close */
@@ -20241,14 +20287,7 @@
20241
20287
  ...scrollDimensions
20242
20288
  });
20243
20289
  stack.defer(async () => {
20244
- if (viewport) {
20245
- await this.setViewport(viewport).catch(debugError);
20246
- } else {
20247
- await this.setViewport({
20248
- width: 0,
20249
- height: 0
20250
- }).catch(debugError);
20251
- }
20290
+ await this.setViewport(viewport).catch(debugError);
20252
20291
  });
20253
20292
  }
20254
20293
  } else {
@@ -20584,7 +20623,7 @@
20584
20623
  #args;
20585
20624
  #stackTraceLocations;
20586
20625
  /**
20587
- * @public
20626
+ * @internal
20588
20627
  */
20589
20628
  constructor(type, text, args, stackTraceLocations) {
20590
20629
  this.#type = type;
@@ -21236,6 +21275,9 @@
21236
21275
  var Coverage = class {
21237
21276
  #jsCoverage;
21238
21277
  #cssCoverage;
21278
+ /**
21279
+ * @internal
21280
+ */
21239
21281
  constructor(client) {
21240
21282
  this.#jsCoverage = new JSCoverage(client);
21241
21283
  this.#cssCoverage = new CSSCoverage(client);
@@ -21303,6 +21345,9 @@
21303
21345
  #resetOnNavigation = false;
21304
21346
  #reportAnonymousScripts = false;
21305
21347
  #includeRawScriptCoverage = false;
21348
+ /**
21349
+ * @internal
21350
+ */
21306
21351
  constructor(client) {
21307
21352
  this.#client = client;
21308
21353
  }
@@ -21719,6 +21764,12 @@
21719
21764
  _private_setJavaScriptEnabled_decorators = [invokeAtMostOnceForArguments];
21720
21765
  __esDecorate4(this, _private_applyViewport_descriptor = { value: __setFunctionName2(async function(client, viewportState) {
21721
21766
  if (!viewportState.viewport) {
21767
+ await Promise.all([
21768
+ client.send("Emulation.clearDeviceMetricsOverride"),
21769
+ client.send("Emulation.setTouchEmulationEnabled", {
21770
+ enabled: false
21771
+ })
21772
+ ]).catch(debugError);
21722
21773
  return;
21723
21774
  }
21724
21775
  const { viewport } = viewportState;
@@ -21897,12 +21948,18 @@
21897
21948
  return this.#javascriptEnabledState.state.javaScriptEnabled;
21898
21949
  }
21899
21950
  async emulateViewport(viewport) {
21900
- await this.#viewportState.setState({
21951
+ const currentState = this.#viewportState.state;
21952
+ if (!viewport && !currentState.active) {
21953
+ return false;
21954
+ }
21955
+ await this.#viewportState.setState(viewport ? {
21901
21956
  viewport,
21902
21957
  active: true
21958
+ } : {
21959
+ active: false
21903
21960
  });
21904
- const mobile = viewport.isMobile || false;
21905
- const hasTouch = viewport.hasTouch || false;
21961
+ const mobile = viewport?.isMobile || false;
21962
+ const hasTouch = viewport?.hasTouch || false;
21906
21963
  const reloadNeeded = this.#emulatingMobile !== mobile || this.#hasTouch !== hasTouch;
21907
21964
  this.#emulatingMobile = mobile;
21908
21965
  this.#hasTouch = hasTouch;
@@ -23009,10 +23066,11 @@
23009
23066
  };
23010
23067
  function parsePSelectors(selector) {
23011
23068
  let isPureCSS = true;
23069
+ let hasAria = false;
23012
23070
  let hasPseudoClasses = false;
23013
23071
  const tokens = tokenize(selector);
23014
23072
  if (tokens.length === 0) {
23015
- return [[], isPureCSS, hasPseudoClasses];
23073
+ return [[], isPureCSS, hasPseudoClasses, false];
23016
23074
  }
23017
23075
  let compoundSelector = [];
23018
23076
  let complexSelector = [compoundSelector];
@@ -23059,8 +23117,12 @@
23059
23117
  compoundSelector.push(stringify(storage));
23060
23118
  storage.splice(0);
23061
23119
  }
23120
+ const name2 = token.name.slice(3);
23121
+ if (name2 === "aria") {
23122
+ hasAria = true;
23123
+ }
23062
23124
  compoundSelector.push({
23063
- name: token.name.slice(3),
23125
+ name: name2,
23064
23126
  value: unquote(token.argument ?? "")
23065
23127
  });
23066
23128
  continue;
@@ -23082,7 +23144,7 @@
23082
23144
  if (storage.length) {
23083
23145
  compoundSelector.push(stringify(storage));
23084
23146
  }
23085
- return [selectors, isPureCSS, hasPseudoClasses];
23147
+ return [selectors, isPureCSS, hasPseudoClasses, hasAria];
23086
23148
  }
23087
23149
 
23088
23150
  // node_modules/puppeteer-core/lib/esm/puppeteer/common/TextQueryHandler.js
@@ -23131,7 +23193,7 @@
23131
23193
  selector = selector.slice(prefix.length);
23132
23194
  return {
23133
23195
  updatedSelector: selector,
23134
- selectorHasPseudoClasses: false,
23196
+ polling: name2 === "aria" ? "raf" : "mutation",
23135
23197
  QueryHandler: QueryHandler2
23136
23198
  };
23137
23199
  }
@@ -23139,23 +23201,23 @@
23139
23201
  }
23140
23202
  }
23141
23203
  try {
23142
- const [pSelector, isPureCSS, hasPseudoClasses] = parsePSelectors(selector);
23204
+ const [pSelector, isPureCSS, hasPseudoClasses, hasAria] = parsePSelectors(selector);
23143
23205
  if (isPureCSS) {
23144
23206
  return {
23145
23207
  updatedSelector: selector,
23146
- selectorHasPseudoClasses: hasPseudoClasses,
23208
+ polling: hasPseudoClasses ? "raf" : "mutation",
23147
23209
  QueryHandler: CSSQueryHandler
23148
23210
  };
23149
23211
  }
23150
23212
  return {
23151
23213
  updatedSelector: JSON.stringify(pSelector),
23152
- selectorHasPseudoClasses: hasPseudoClasses,
23214
+ polling: hasAria ? "raf" : "mutation",
23153
23215
  QueryHandler: PQueryHandler
23154
23216
  };
23155
23217
  } catch {
23156
23218
  return {
23157
23219
  updatedSelector: selector,
23158
- selectorHasPseudoClasses: false,
23220
+ polling: "mutation",
23159
23221
  QueryHandler: CSSQueryHandler
23160
23222
  };
23161
23223
  }
@@ -23412,7 +23474,7 @@
23412
23474
  * Behaves identically to {@link Page.evaluateHandle} except it's run within
23413
23475
  * the context of this frame.
23414
23476
  *
23415
- * @see {@link Page.evaluateHandle} for details.
23477
+ * See {@link Page.evaluateHandle} for details.
23416
23478
  */
23417
23479
  async evaluateHandle(pageFunction, ...args) {
23418
23480
  pageFunction = withSourcePuppeteerURLIfNone(this.evaluateHandle.name, pageFunction);
@@ -23422,7 +23484,7 @@
23422
23484
  * Behaves identically to {@link Page.evaluate} except it's run within
23423
23485
  * the context of this frame.
23424
23486
  *
23425
- * @see {@link Page.evaluate} for details.
23487
+ * See {@link Page.evaluate} for details.
23426
23488
  */
23427
23489
  async evaluate(pageFunction, ...args) {
23428
23490
  pageFunction = withSourcePuppeteerURLIfNone(this.evaluate.name, pageFunction);
@@ -23442,20 +23504,20 @@
23442
23504
  * Queries the frame for an element matching the given selector.
23443
23505
  *
23444
23506
  * @param selector -
23445
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
23507
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
23446
23508
  * to query page for.
23447
23509
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
23448
23510
  * can be passed as-is and a
23449
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
23511
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
23450
23512
  * allows quering by
23451
23513
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
23452
23514
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
23453
23515
  * and
23454
23516
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
23455
23517
  * and
23456
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
23457
- * Alternatively, you can specify a selector type using a prefix
23458
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
23518
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
23519
+ * Alternatively, you can specify the selector type using a
23520
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
23459
23521
  *
23460
23522
  * @returns A {@link ElementHandle | element handle} to the first element
23461
23523
  * matching the given selector. Otherwise, `null`.
@@ -23468,20 +23530,20 @@
23468
23530
  * Queries the frame for all elements matching the given selector.
23469
23531
  *
23470
23532
  * @param selector -
23471
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
23533
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
23472
23534
  * to query page for.
23473
23535
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
23474
23536
  * can be passed as-is and a
23475
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
23537
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
23476
23538
  * allows quering by
23477
23539
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
23478
23540
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
23479
23541
  * and
23480
23542
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
23481
23543
  * and
23482
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
23483
- * Alternatively, you can specify a selector type using a prefix
23484
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
23544
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
23545
+ * Alternatively, you can specify the selector type using a
23546
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
23485
23547
  *
23486
23548
  * @returns An array of {@link ElementHandle | element handles} that point to
23487
23549
  * elements matching the given selector.
@@ -23504,20 +23566,20 @@
23504
23566
  * ```
23505
23567
  *
23506
23568
  * @param selector -
23507
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
23569
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
23508
23570
  * to query page for.
23509
23571
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
23510
23572
  * can be passed as-is and a
23511
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
23573
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
23512
23574
  * allows quering by
23513
23575
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
23514
23576
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
23515
23577
  * and
23516
23578
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
23517
23579
  * and
23518
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
23519
- * Alternatively, you can specify a selector type using a prefix
23520
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
23580
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
23581
+ * Alternatively, you can specify the selector type using a
23582
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
23521
23583
  * @param pageFunction - The function to be evaluated in the frame's context.
23522
23584
  * The first element matching the selector will be passed to the function as
23523
23585
  * its first argument.
@@ -23543,20 +23605,20 @@
23543
23605
  * ```
23544
23606
  *
23545
23607
  * @param selector -
23546
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
23608
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
23547
23609
  * to query page for.
23548
23610
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
23549
23611
  * can be passed as-is and a
23550
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
23612
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
23551
23613
  * allows quering by
23552
23614
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
23553
23615
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
23554
23616
  * and
23555
23617
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
23556
23618
  * and
23557
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
23558
- * Alternatively, you can specify a selector type using a prefix
23559
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
23619
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
23620
+ * Alternatively, you can specify the selector type using a
23621
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
23560
23622
  * @param pageFunction - The function to be evaluated in the frame's context.
23561
23623
  * An array of elements matching the given selector will be passed to the
23562
23624
  * function as its first argument.
@@ -23604,9 +23666,9 @@
23604
23666
  * @throws Throws if an element matching the given selector doesn't appear.
23605
23667
  */
23606
23668
  async waitForSelector(selector, options = {}) {
23607
- const { updatedSelector, QueryHandler: QueryHandler2, selectorHasPseudoClasses } = getQueryHandlerAndSelector(selector);
23669
+ const { updatedSelector, QueryHandler: QueryHandler2, polling } = getQueryHandlerAndSelector(selector);
23608
23670
  return await QueryHandler2.waitFor(this, updatedSelector, {
23609
- polling: selectorHasPseudoClasses ? "raf" : void 0,
23671
+ polling,
23610
23672
  ...options
23611
23673
  });
23612
23674
  }
@@ -24480,7 +24542,21 @@
24480
24542
  /**
24481
24543
  * Queries the current element for an element matching the given selector.
24482
24544
  *
24483
- * @param selector - The selector to query for.
24545
+ * @param selector -
24546
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
24547
+ * to query page for.
24548
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
24549
+ * can be passed as-is and a
24550
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
24551
+ * allows quering by
24552
+ * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
24553
+ * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
24554
+ * and
24555
+ * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
24556
+ * and
24557
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
24558
+ * Alternatively, you can specify the selector type using a
24559
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
24484
24560
  * @returns A {@link ElementHandle | element handle} to the first element
24485
24561
  * matching the given selector. Otherwise, `null`.
24486
24562
  */
@@ -24491,7 +24567,21 @@
24491
24567
  /**
24492
24568
  * Queries the current element for all elements matching the given selector.
24493
24569
  *
24494
- * @param selector - The selector to query for.
24570
+ * @param selector -
24571
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
24572
+ * to query page for.
24573
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
24574
+ * can be passed as-is and a
24575
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
24576
+ * allows quering by
24577
+ * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
24578
+ * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
24579
+ * and
24580
+ * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
24581
+ * and
24582
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
24583
+ * Alternatively, you can specify the selector type using a
24584
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
24495
24585
  * @returns An array of {@link ElementHandle | element handles} that point to
24496
24586
  * elements matching the given selector.
24497
24587
  */
@@ -24537,7 +24627,21 @@
24537
24627
  * );
24538
24628
  * ```
24539
24629
  *
24540
- * @param selector - The selector to query for.
24630
+ * @param selector -
24631
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
24632
+ * to query page for.
24633
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
24634
+ * can be passed as-is and a
24635
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
24636
+ * allows quering by
24637
+ * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
24638
+ * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
24639
+ * and
24640
+ * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
24641
+ * and
24642
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
24643
+ * Alternatively, you can specify the selector type using a
24644
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
24541
24645
  * @param pageFunction - The function to be evaluated in this element's page's
24542
24646
  * context. The first element matching the selector will be passed in as the
24543
24647
  * first argument.
@@ -24586,7 +24690,21 @@
24586
24690
  * ).toEqual(['Hello!', 'Hi!']);
24587
24691
  * ```
24588
24692
  *
24589
- * @param selector - The selector to query for.
24693
+ * @param selector -
24694
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
24695
+ * to query page for.
24696
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
24697
+ * can be passed as-is and a
24698
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
24699
+ * allows quering by
24700
+ * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
24701
+ * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
24702
+ * and
24703
+ * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
24704
+ * and
24705
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
24706
+ * Alternatively, you can specify the selector type using a
24707
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
24590
24708
  * @param pageFunction - The function to be evaluated in the element's page's
24591
24709
  * context. An array of elements matching the given selector will be passed to
24592
24710
  * the function as its first argument.
@@ -24653,9 +24771,9 @@
24653
24771
  * @throws Throws if an element matching the given selector doesn't appear.
24654
24772
  */
24655
24773
  async waitForSelector(selector, options = {}) {
24656
- const { updatedSelector, QueryHandler: QueryHandler2, selectorHasPseudoClasses } = getQueryHandlerAndSelector(selector);
24774
+ const { updatedSelector, QueryHandler: QueryHandler2, polling } = getQueryHandlerAndSelector(selector);
24657
24775
  return await QueryHandler2.waitFor(this, updatedSelector, {
24658
- polling: selectorHasPseudoClasses ? "raf" : void 0,
24776
+ polling,
24659
24777
  ...options
24660
24778
  });
24661
24779
  }
@@ -24667,15 +24785,32 @@
24667
24785
  }), visibility);
24668
24786
  }
24669
24787
  /**
24670
- * Checks if an element is visible using the same mechanism as
24671
- * {@link ElementHandle.waitForSelector}.
24788
+ * An element is considered to be visible if all of the following is
24789
+ * true:
24790
+ *
24791
+ * - the element has
24792
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | computed styles}.
24793
+ *
24794
+ * - the element has a non-empty
24795
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect | bounding client rect}.
24796
+ *
24797
+ * - the element's {@link https://developer.mozilla.org/en-US/docs/Web/CSS/visibility | visibility}
24798
+ * is not `hidden` or `collapse`.
24672
24799
  */
24673
24800
  async isVisible() {
24674
24801
  return await this.#checkVisibility(true);
24675
24802
  }
24676
24803
  /**
24677
- * Checks if an element is hidden using the same mechanism as
24678
- * {@link ElementHandle.waitForSelector}.
24804
+ * An element is considered to be hidden if at least one of the following is true:
24805
+ *
24806
+ * - the element has no
24807
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | computed styles}.
24808
+ *
24809
+ * - the element has an empty
24810
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect | bounding client rect}.
24811
+ *
24812
+ * - the element's {@link https://developer.mozilla.org/en-US/docs/Web/CSS/visibility | visibility}
24813
+ * is `hidden` or `collapse`.
24679
24814
  */
24680
24815
  async isHidden() {
24681
24816
  return await this.#checkVisibility(false);
@@ -26799,7 +26934,7 @@ ${sourceUrlComment}
26799
26934
  async #waitForExecutionContext() {
26800
26935
  const result = await firstValueFrom(fromEmitterEvent(this.#emitter, "context").pipe(raceWith(fromEmitterEvent(this.#emitter, "disposed").pipe(map(() => {
26801
26936
  throw new Error("Execution context was destroyed");
26802
- })))));
26937
+ })), timeout(this.timeoutSettings.timeout()))));
26803
26938
  return result;
26804
26939
  }
26805
26940
  async evaluateHandle(pageFunction, ...args) {
@@ -28983,7 +29118,7 @@ ${sourceUrlComment}
28983
29118
  }
28984
29119
  if (contextPayload.auxData && contextPayload.auxData["isDefault"]) {
28985
29120
  world = frame.worlds[MAIN_WORLD];
28986
- } else if (contextPayload.name === UTILITY_WORLD_NAME && !frame.worlds[PUPPETEER_WORLD].hasContext()) {
29121
+ } else if (contextPayload.name === UTILITY_WORLD_NAME) {
28987
29122
  world = frame.worlds[PUPPETEER_WORLD];
28988
29123
  }
28989
29124
  }