@browserless.io/browserless 2.14.0 → 2.15.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +5 -2
  2. package/build/browserless.d.ts +0 -2
  3. package/build/browsers/browsers.cdp.d.ts +0 -5
  4. package/build/browsers/browsers.playwright.d.ts +33 -37
  5. package/build/browsers/index.d.ts +1 -2
  6. package/build/config.d.ts +0 -2
  7. package/build/file-system.d.ts +0 -2
  8. package/build/hooks.d.ts +0 -1
  9. package/build/http.d.ts +0 -1
  10. package/build/limiter.d.ts +5 -0
  11. package/build/limiter.js +3 -0
  12. package/build/limiter.spec.js +1 -1
  13. package/build/metrics.d.ts +0 -1
  14. package/build/monitoring.d.ts +0 -1
  15. package/build/router.d.ts +0 -3
  16. package/build/routes/chrome/http/content.post.body.json +16 -9
  17. package/build/routes/chrome/http/pdf.post.body.json +16 -9
  18. package/build/routes/chrome/http/scrape.post.body.json +16 -9
  19. package/build/routes/chrome/http/screenshot.post.body.json +16 -9
  20. package/build/routes/chromium/http/content.post.body.json +16 -9
  21. package/build/routes/chromium/http/pdf.post.body.json +16 -9
  22. package/build/routes/chromium/http/scrape.post.body.json +16 -9
  23. package/build/routes/chromium/http/screenshot.post.body.json +16 -9
  24. package/build/routes/firefox/ws/playwright.d.ts +0 -2
  25. package/build/routes/management/http/active.get.d.ts +0 -1
  26. package/build/routes/management/http/config.get.d.ts +0 -1
  27. package/build/routes/management/http/metrics-total.get.d.ts +0 -1
  28. package/build/routes/management/http/metrics.get.d.ts +0 -1
  29. package/build/routes/management/http/pressure.get.d.ts +0 -1
  30. package/build/routes/management/http/sessions.get.d.ts +0 -1
  31. package/build/routes/management/http/static.get.d.ts +0 -1
  32. package/build/routes/webkit/ws/playwright.d.ts +0 -2
  33. package/build/server.d.ts +0 -4
  34. package/build/shared/browser.ws.d.ts +0 -2
  35. package/build/shared/chromium.playwright.ws.d.ts +0 -2
  36. package/build/shared/chromium.ws.d.ts +0 -2
  37. package/build/shared/content.http.d.ts +0 -1
  38. package/build/shared/download.http.d.ts +0 -1
  39. package/build/shared/function.http.d.ts +0 -1
  40. package/build/shared/page.ws.d.ts +0 -2
  41. package/build/shared/pdf.http.d.ts +0 -1
  42. package/build/shared/performance.http.d.ts +0 -1
  43. package/build/shared/scrape.http.d.ts +0 -1
  44. package/build/shared/screenshot.http.d.ts +0 -1
  45. package/build/token.d.ts +0 -1
  46. package/build/types.d.ts +0 -3
  47. package/build/utils.d.ts +0 -3
  48. package/build/webhooks.d.ts +0 -1
  49. package/package.json +16 -16
  50. package/src/limiter.spec.ts +1 -1
  51. package/src/limiter.ts +8 -0
  52. package/static/docs/swagger.json +74 -18
  53. package/static/docs/swagger.min.json +73 -17
  54. package/static/function/client.js +229 -94
  55. package/static/function/index.html +229 -94
@@ -16907,6 +16907,15 @@
16907
16907
  };
16908
16908
  });
16909
16909
  }
16910
+ function fromAbortSignal(signal, cause) {
16911
+ return signal ? fromEvent(signal, "abort").pipe(map(() => {
16912
+ if (signal.reason instanceof Error) {
16913
+ signal.reason.cause = cause;
16914
+ throw signal.reason;
16915
+ }
16916
+ throw new Error(signal.reason, { cause });
16917
+ })) : NEVER;
16918
+ }
16910
16919
  function filterAsync(predicate) {
16911
16920
  return mergeMap((value) => {
16912
16921
  return from(Promise.resolve(predicate(value))).pipe(filter((isMatch) => {
@@ -18647,8 +18656,8 @@
18647
18656
  })(LocatorEvent || (LocatorEvent = {}));
18648
18657
  var Locator = class extends EventEmitter2 {
18649
18658
  /**
18650
- * Creates a race between multiple locators but ensures that only a single one
18651
- * acts.
18659
+ * Creates a race between multiple locators trying to locate elements in
18660
+ * parallel but ensures that only a single element receives the action.
18652
18661
  *
18653
18662
  * @public
18654
18663
  */
@@ -18680,12 +18689,7 @@
18680
18689
  retryAndRaceWithSignalAndTimer: (signal, cause) => {
18681
18690
  const candidates = [];
18682
18691
  if (signal) {
18683
- candidates.push(fromEvent(signal, "abort").pipe(map(() => {
18684
- if (signal.reason instanceof Error) {
18685
- signal.reason.cause = cause;
18686
- }
18687
- throw signal.reason;
18688
- })));
18692
+ candidates.push(fromAbortSignal(signal, cause));
18689
18693
  }
18690
18694
  candidates.push(timeout(this._timeout, cause));
18691
18695
  return pipe(retry({ delay: RETRY_DELAY }), raceWith(...candidates));
@@ -18695,26 +18699,59 @@
18695
18699
  get timeout() {
18696
18700
  return this._timeout;
18697
18701
  }
18702
+ /**
18703
+ * Creates a new locator instance by cloning the current locator and setting
18704
+ * the total timeout for the locator actions.
18705
+ *
18706
+ * Pass `0` to disable timeout.
18707
+ *
18708
+ * @defaultValue `Page.getDefaultTimeout()`
18709
+ */
18698
18710
  setTimeout(timeout2) {
18699
18711
  const locator = this._clone();
18700
18712
  locator._timeout = timeout2;
18701
18713
  return locator;
18702
18714
  }
18715
+ /**
18716
+ * Creates a new locator instance by cloning the current locator with the
18717
+ * visibility property changed to the specified value.
18718
+ */
18703
18719
  setVisibility(visibility) {
18704
18720
  const locator = this._clone();
18705
18721
  locator.visibility = visibility;
18706
18722
  return locator;
18707
18723
  }
18724
+ /**
18725
+ * Creates a new locator instance by cloning the current locator and
18726
+ * specifying whether to wait for input elements to become enabled before the
18727
+ * action. Applicable to `click` and `fill` actions.
18728
+ *
18729
+ * @defaultValue `true`
18730
+ */
18708
18731
  setWaitForEnabled(value) {
18709
18732
  const locator = this._clone();
18710
18733
  locator.#waitForEnabled = value;
18711
18734
  return locator;
18712
18735
  }
18736
+ /**
18737
+ * Creates a new locator instance by cloning the current locator and
18738
+ * specifying whether the locator should scroll the element into viewport if
18739
+ * it is not in the viewport already.
18740
+ *
18741
+ * @defaultValue `true`
18742
+ */
18713
18743
  setEnsureElementIsInTheViewport(value) {
18714
18744
  const locator = this._clone();
18715
18745
  locator.#ensureElementIsInTheViewport = value;
18716
18746
  return locator;
18717
18747
  }
18748
+ /**
18749
+ * Creates a new locator instance by cloning the current locator and
18750
+ * specifying whether the locator has to wait for the element's bounding box
18751
+ * to be same between two consecutive animation frames.
18752
+ *
18753
+ * @defaultValue `true`
18754
+ */
18718
18755
  setWaitForStableBoundingBox(value) {
18719
18756
  const locator = this._clone();
18720
18757
  locator.#waitForStableBoundingBox = value;
@@ -19021,21 +19058,30 @@
19021
19058
  mapHandle(mapper) {
19022
19059
  return new MappedLocator(this._clone(), mapper);
19023
19060
  }
19061
+ /**
19062
+ * Clicks the located element.
19063
+ */
19024
19064
  click(options) {
19025
19065
  return firstValueFrom(this.#click(options));
19026
19066
  }
19027
19067
  /**
19028
19068
  * Fills out the input identified by the locator using the provided value. The
19029
19069
  * type of the input is determined at runtime and the appropriate fill-out
19030
- * method is chosen based on the type. contenteditable, selector, inputs are
19031
- * supported.
19070
+ * method is chosen based on the type. `contenteditable`, select, textarea and
19071
+ * input elements are supported.
19032
19072
  */
19033
19073
  fill(value, options) {
19034
19074
  return firstValueFrom(this.#fill(value, options));
19035
19075
  }
19076
+ /**
19077
+ * Hovers over the located element.
19078
+ */
19036
19079
  hover(options) {
19037
19080
  return firstValueFrom(this.#hover(options));
19038
19081
  }
19082
+ /**
19083
+ * Scrolls the located element.
19084
+ */
19039
19085
  scroll(options) {
19040
19086
  return firstValueFrom(this.#scroll(options));
19041
19087
  }
@@ -19427,20 +19473,20 @@
19427
19473
  * the selector, the return value resolves to `null`.
19428
19474
  *
19429
19475
  * @param selector -
19430
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
19476
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
19431
19477
  * to query page for.
19432
19478
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
19433
19479
  * can be passed as-is and a
19434
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
19480
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
19435
19481
  * allows quering by
19436
19482
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
19437
19483
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
19438
19484
  * and
19439
19485
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
19440
19486
  * and
19441
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
19442
- * Alternatively, you can specify a selector type using a prefix
19443
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
19487
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
19488
+ * Alternatively, you can specify the selector type using a
19489
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
19444
19490
  *
19445
19491
  * @remarks
19446
19492
  *
@@ -19454,20 +19500,20 @@
19454
19500
  * match the selector, the return value resolves to `[]`.
19455
19501
  *
19456
19502
  * @param selector -
19457
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
19503
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
19458
19504
  * to query page for.
19459
19505
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
19460
19506
  * can be passed as-is and a
19461
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
19507
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
19462
19508
  * allows quering by
19463
19509
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
19464
19510
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
19465
19511
  * and
19466
19512
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
19467
19513
  * and
19468
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
19469
- * Alternatively, you can specify a selector type using a prefix
19470
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
19514
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
19515
+ * Alternatively, you can specify the selector type using a
19516
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
19471
19517
  *
19472
19518
  * @remarks
19473
19519
  *
@@ -19588,20 +19634,20 @@
19588
19634
  * ```
19589
19635
  *
19590
19636
  * @param selector -
19591
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
19637
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
19592
19638
  * to query page for.
19593
19639
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
19594
19640
  * can be passed as-is and a
19595
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
19641
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
19596
19642
  * allows quering by
19597
19643
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
19598
19644
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
19599
19645
  * and
19600
19646
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
19601
19647
  * and
19602
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
19603
- * Alternatively, you can specify a selector type using a prefix
19604
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
19648
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
19649
+ * Alternatively, you can specify the selector type using a
19650
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
19605
19651
  * @param pageFunction - the function to be evaluated in the page context.
19606
19652
  * Will be passed the result of the element matching the selector as its
19607
19653
  * first argument.
@@ -19661,20 +19707,20 @@
19661
19707
  * ```
19662
19708
  *
19663
19709
  * @param selector -
19664
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
19710
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
19665
19711
  * to query page for.
19666
19712
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
19667
19713
  * can be passed as-is and a
19668
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
19714
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
19669
19715
  * allows quering by
19670
19716
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
19671
19717
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
19672
19718
  * and
19673
19719
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
19674
19720
  * and
19675
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
19676
- * Alternatively, you can specify a selector type using a prefix
19677
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
19721
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
19722
+ * Alternatively, you can specify the selector type using a
19723
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
19678
19724
  * @param pageFunction - the function to be evaluated in the page context.
19679
19725
  * Will be passed an array of matching elements as its first argument.
19680
19726
  * @param args - any additional arguments to pass through to `pageFunction`.
@@ -19790,7 +19836,7 @@
19790
19836
  * {@link Page.setDefaultTimeout} method.
19791
19837
  */
19792
19838
  waitForRequest(urlOrPredicate, options = {}) {
19793
- const { timeout: ms = this._timeoutSettings.timeout() } = options;
19839
+ const { timeout: ms = this._timeoutSettings.timeout(), signal } = options;
19794
19840
  if (typeof urlOrPredicate === "string") {
19795
19841
  const url = urlOrPredicate;
19796
19842
  urlOrPredicate = (request) => {
@@ -19801,7 +19847,7 @@
19801
19847
  this,
19802
19848
  "request"
19803
19849
  /* PageEvent.Request */
19804
- ).pipe(filterAsync(urlOrPredicate), raceWith(timeout(ms), fromEmitterEvent(
19850
+ ).pipe(filterAsync(urlOrPredicate), raceWith(timeout(ms), fromAbortSignal(signal), fromEmitterEvent(
19805
19851
  this,
19806
19852
  "close"
19807
19853
  /* PageEvent.Close */
@@ -19838,7 +19884,7 @@
19838
19884
  * the {@link Page.setDefaultTimeout} method.
19839
19885
  */
19840
19886
  waitForResponse(urlOrPredicate, options = {}) {
19841
- const { timeout: ms = this._timeoutSettings.timeout() } = options;
19887
+ const { timeout: ms = this._timeoutSettings.timeout(), signal } = options;
19842
19888
  if (typeof urlOrPredicate === "string") {
19843
19889
  const url = urlOrPredicate;
19844
19890
  urlOrPredicate = (response) => {
@@ -19849,7 +19895,7 @@
19849
19895
  this,
19850
19896
  "response"
19851
19897
  /* PageEvent.Response */
19852
- ).pipe(filterAsync(urlOrPredicate), raceWith(timeout(ms), fromEmitterEvent(
19898
+ ).pipe(filterAsync(urlOrPredicate), raceWith(timeout(ms), fromAbortSignal(signal), fromEmitterEvent(
19853
19899
  this,
19854
19900
  "close"
19855
19901
  /* PageEvent.Close */
@@ -19871,14 +19917,14 @@
19871
19917
  * @internal
19872
19918
  */
19873
19919
  waitForNetworkIdle$(options = {}) {
19874
- const { timeout: ms = this._timeoutSettings.timeout(), idleTime = NETWORK_IDLE_TIME, concurrency = 0 } = options;
19920
+ const { timeout: ms = this._timeoutSettings.timeout(), idleTime = NETWORK_IDLE_TIME, concurrency = 0, signal } = options;
19875
19921
  return this.#inflight$.pipe(switchMap((inflight) => {
19876
19922
  if (inflight > concurrency) {
19877
19923
  return EMPTY;
19878
19924
  }
19879
19925
  return timer(idleTime);
19880
19926
  }), map(() => {
19881
- }), raceWith(timeout(ms), fromEmitterEvent(
19927
+ }), raceWith(timeout(ms), fromAbortSignal(signal), fromEmitterEvent(
19882
19928
  this,
19883
19929
  "close"
19884
19930
  /* PageEvent.Close */
@@ -19898,7 +19944,7 @@
19898
19944
  * ```
19899
19945
  */
19900
19946
  async waitForFrame(urlOrPredicate, options = {}) {
19901
- const { timeout: ms = this.getDefaultTimeout() } = options;
19947
+ const { timeout: ms = this.getDefaultTimeout(), signal } = options;
19902
19948
  if (isString3(urlOrPredicate)) {
19903
19949
  urlOrPredicate = (frame) => {
19904
19950
  return urlOrPredicate === frame.url();
@@ -19912,7 +19958,7 @@
19912
19958
  this,
19913
19959
  "framenavigated"
19914
19960
  /* PageEvent.FrameNavigated */
19915
- ), from(this.frames())).pipe(filterAsync(urlOrPredicate), first(), raceWith(timeout(ms), fromEmitterEvent(
19961
+ ), from(this.frames())).pipe(filterAsync(urlOrPredicate), first(), raceWith(timeout(ms), fromAbortSignal(signal), fromEmitterEvent(
19916
19962
  this,
19917
19963
  "close"
19918
19964
  /* PageEvent.Close */
@@ -20233,14 +20279,7 @@
20233
20279
  ...scrollDimensions
20234
20280
  });
20235
20281
  stack.defer(async () => {
20236
- if (viewport) {
20237
- await this.setViewport(viewport).catch(debugError);
20238
- } else {
20239
- await this.setViewport({
20240
- width: 0,
20241
- height: 0
20242
- }).catch(debugError);
20243
- }
20282
+ await this.setViewport(viewport).catch(debugError);
20244
20283
  });
20245
20284
  }
20246
20285
  } else {
@@ -20576,7 +20615,7 @@
20576
20615
  #args;
20577
20616
  #stackTraceLocations;
20578
20617
  /**
20579
- * @public
20618
+ * @internal
20580
20619
  */
20581
20620
  constructor(type, text, args, stackTraceLocations) {
20582
20621
  this.#type = type;
@@ -21228,6 +21267,9 @@
21228
21267
  var Coverage = class {
21229
21268
  #jsCoverage;
21230
21269
  #cssCoverage;
21270
+ /**
21271
+ * @internal
21272
+ */
21231
21273
  constructor(client) {
21232
21274
  this.#jsCoverage = new JSCoverage(client);
21233
21275
  this.#cssCoverage = new CSSCoverage(client);
@@ -21295,6 +21337,9 @@
21295
21337
  #resetOnNavigation = false;
21296
21338
  #reportAnonymousScripts = false;
21297
21339
  #includeRawScriptCoverage = false;
21340
+ /**
21341
+ * @internal
21342
+ */
21298
21343
  constructor(client) {
21299
21344
  this.#client = client;
21300
21345
  }
@@ -21711,6 +21756,12 @@
21711
21756
  _private_setJavaScriptEnabled_decorators = [invokeAtMostOnceForArguments];
21712
21757
  __esDecorate4(this, _private_applyViewport_descriptor = { value: __setFunctionName2(async function(client, viewportState) {
21713
21758
  if (!viewportState.viewport) {
21759
+ await Promise.all([
21760
+ client.send("Emulation.clearDeviceMetricsOverride"),
21761
+ client.send("Emulation.setTouchEmulationEnabled", {
21762
+ enabled: false
21763
+ })
21764
+ ]).catch(debugError);
21714
21765
  return;
21715
21766
  }
21716
21767
  const { viewport } = viewportState;
@@ -21889,12 +21940,18 @@
21889
21940
  return this.#javascriptEnabledState.state.javaScriptEnabled;
21890
21941
  }
21891
21942
  async emulateViewport(viewport) {
21892
- await this.#viewportState.setState({
21943
+ const currentState = this.#viewportState.state;
21944
+ if (!viewport && !currentState.active) {
21945
+ return false;
21946
+ }
21947
+ await this.#viewportState.setState(viewport ? {
21893
21948
  viewport,
21894
21949
  active: true
21950
+ } : {
21951
+ active: false
21895
21952
  });
21896
- const mobile = viewport.isMobile || false;
21897
- const hasTouch = viewport.hasTouch || false;
21953
+ const mobile = viewport?.isMobile || false;
21954
+ const hasTouch = viewport?.hasTouch || false;
21898
21955
  const reloadNeeded = this.#emulatingMobile !== mobile || this.#hasTouch !== hasTouch;
21899
21956
  this.#emulatingMobile = mobile;
21900
21957
  this.#hasTouch = hasTouch;
@@ -23001,10 +23058,11 @@
23001
23058
  };
23002
23059
  function parsePSelectors(selector) {
23003
23060
  let isPureCSS = true;
23061
+ let hasAria = false;
23004
23062
  let hasPseudoClasses = false;
23005
23063
  const tokens = tokenize(selector);
23006
23064
  if (tokens.length === 0) {
23007
- return [[], isPureCSS, hasPseudoClasses];
23065
+ return [[], isPureCSS, hasPseudoClasses, false];
23008
23066
  }
23009
23067
  let compoundSelector = [];
23010
23068
  let complexSelector = [compoundSelector];
@@ -23051,8 +23109,12 @@
23051
23109
  compoundSelector.push(stringify(storage));
23052
23110
  storage.splice(0);
23053
23111
  }
23112
+ const name2 = token.name.slice(3);
23113
+ if (name2 === "aria") {
23114
+ hasAria = true;
23115
+ }
23054
23116
  compoundSelector.push({
23055
- name: token.name.slice(3),
23117
+ name: name2,
23056
23118
  value: unquote(token.argument ?? "")
23057
23119
  });
23058
23120
  continue;
@@ -23074,7 +23136,7 @@
23074
23136
  if (storage.length) {
23075
23137
  compoundSelector.push(stringify(storage));
23076
23138
  }
23077
- return [selectors, isPureCSS, hasPseudoClasses];
23139
+ return [selectors, isPureCSS, hasPseudoClasses, hasAria];
23078
23140
  }
23079
23141
 
23080
23142
  // node_modules/puppeteer-core/lib/esm/puppeteer/common/TextQueryHandler.js
@@ -23123,7 +23185,7 @@
23123
23185
  selector = selector.slice(prefix.length);
23124
23186
  return {
23125
23187
  updatedSelector: selector,
23126
- selectorHasPseudoClasses: false,
23188
+ polling: name2 === "aria" ? "raf" : "mutation",
23127
23189
  QueryHandler: QueryHandler2
23128
23190
  };
23129
23191
  }
@@ -23131,23 +23193,23 @@
23131
23193
  }
23132
23194
  }
23133
23195
  try {
23134
- const [pSelector, isPureCSS, hasPseudoClasses] = parsePSelectors(selector);
23196
+ const [pSelector, isPureCSS, hasPseudoClasses, hasAria] = parsePSelectors(selector);
23135
23197
  if (isPureCSS) {
23136
23198
  return {
23137
23199
  updatedSelector: selector,
23138
- selectorHasPseudoClasses: hasPseudoClasses,
23200
+ polling: hasPseudoClasses ? "raf" : "mutation",
23139
23201
  QueryHandler: CSSQueryHandler
23140
23202
  };
23141
23203
  }
23142
23204
  return {
23143
23205
  updatedSelector: JSON.stringify(pSelector),
23144
- selectorHasPseudoClasses: hasPseudoClasses,
23206
+ polling: hasAria ? "raf" : "mutation",
23145
23207
  QueryHandler: PQueryHandler
23146
23208
  };
23147
23209
  } catch {
23148
23210
  return {
23149
23211
  updatedSelector: selector,
23150
- selectorHasPseudoClasses: false,
23212
+ polling: "mutation",
23151
23213
  QueryHandler: CSSQueryHandler
23152
23214
  };
23153
23215
  }
@@ -23404,7 +23466,7 @@
23404
23466
  * Behaves identically to {@link Page.evaluateHandle} except it's run within
23405
23467
  * the context of this frame.
23406
23468
  *
23407
- * @see {@link Page.evaluateHandle} for details.
23469
+ * See {@link Page.evaluateHandle} for details.
23408
23470
  */
23409
23471
  async evaluateHandle(pageFunction, ...args) {
23410
23472
  pageFunction = withSourcePuppeteerURLIfNone(this.evaluateHandle.name, pageFunction);
@@ -23414,7 +23476,7 @@
23414
23476
  * Behaves identically to {@link Page.evaluate} except it's run within
23415
23477
  * the context of this frame.
23416
23478
  *
23417
- * @see {@link Page.evaluate} for details.
23479
+ * See {@link Page.evaluate} for details.
23418
23480
  */
23419
23481
  async evaluate(pageFunction, ...args) {
23420
23482
  pageFunction = withSourcePuppeteerURLIfNone(this.evaluate.name, pageFunction);
@@ -23434,20 +23496,20 @@
23434
23496
  * Queries the frame for an element matching the given selector.
23435
23497
  *
23436
23498
  * @param selector -
23437
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
23499
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
23438
23500
  * to query page for.
23439
23501
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
23440
23502
  * can be passed as-is and a
23441
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
23503
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
23442
23504
  * allows quering by
23443
23505
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
23444
23506
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
23445
23507
  * and
23446
23508
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
23447
23509
  * and
23448
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
23449
- * Alternatively, you can specify a selector type using a prefix
23450
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
23510
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
23511
+ * Alternatively, you can specify the selector type using a
23512
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
23451
23513
  *
23452
23514
  * @returns A {@link ElementHandle | element handle} to the first element
23453
23515
  * matching the given selector. Otherwise, `null`.
@@ -23460,20 +23522,20 @@
23460
23522
  * Queries the frame for all elements matching the given selector.
23461
23523
  *
23462
23524
  * @param selector -
23463
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
23525
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
23464
23526
  * to query page for.
23465
23527
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
23466
23528
  * can be passed as-is and a
23467
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
23529
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
23468
23530
  * allows quering by
23469
23531
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
23470
23532
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
23471
23533
  * and
23472
23534
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
23473
23535
  * and
23474
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
23475
- * Alternatively, you can specify a selector type using a prefix
23476
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
23536
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
23537
+ * Alternatively, you can specify the selector type using a
23538
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
23477
23539
  *
23478
23540
  * @returns An array of {@link ElementHandle | element handles} that point to
23479
23541
  * elements matching the given selector.
@@ -23496,20 +23558,20 @@
23496
23558
  * ```
23497
23559
  *
23498
23560
  * @param selector -
23499
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
23561
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
23500
23562
  * to query page for.
23501
23563
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
23502
23564
  * can be passed as-is and a
23503
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
23565
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
23504
23566
  * allows quering by
23505
23567
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
23506
23568
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
23507
23569
  * and
23508
23570
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
23509
23571
  * and
23510
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
23511
- * Alternatively, you can specify a selector type using a prefix
23512
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
23572
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
23573
+ * Alternatively, you can specify the selector type using a
23574
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
23513
23575
  * @param pageFunction - The function to be evaluated in the frame's context.
23514
23576
  * The first element matching the selector will be passed to the function as
23515
23577
  * its first argument.
@@ -23535,20 +23597,20 @@
23535
23597
  * ```
23536
23598
  *
23537
23599
  * @param selector -
23538
- * {@link https://pptr.dev/guides/page-interactions#query-selectors | selector}
23600
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
23539
23601
  * to query page for.
23540
23602
  * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
23541
23603
  * can be passed as-is and a
23542
- * {@link https://pptr.dev/guides/page-interactions#p-selectors | Puppeteer-specific seletor syntax}
23604
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
23543
23605
  * allows quering by
23544
23606
  * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
23545
23607
  * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
23546
23608
  * and
23547
23609
  * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
23548
23610
  * and
23549
- * {@link https://pptr.dev/guides/page-interactions#-and--combinators | combining these queries across shadow roots}.
23550
- * Alternatively, you can specify a selector type using a prefix
23551
- * {@link https://pptr.dev/guides/page-interactions#built-in-selectors | prefix}.
23611
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
23612
+ * Alternatively, you can specify the selector type using a
23613
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
23552
23614
  * @param pageFunction - The function to be evaluated in the frame's context.
23553
23615
  * An array of elements matching the given selector will be passed to the
23554
23616
  * function as its first argument.
@@ -23596,9 +23658,9 @@
23596
23658
  * @throws Throws if an element matching the given selector doesn't appear.
23597
23659
  */
23598
23660
  async waitForSelector(selector, options = {}) {
23599
- const { updatedSelector, QueryHandler: QueryHandler2, selectorHasPseudoClasses } = getQueryHandlerAndSelector(selector);
23661
+ const { updatedSelector, QueryHandler: QueryHandler2, polling } = getQueryHandlerAndSelector(selector);
23600
23662
  return await QueryHandler2.waitFor(this, updatedSelector, {
23601
- polling: selectorHasPseudoClasses ? "raf" : void 0,
23663
+ polling,
23602
23664
  ...options
23603
23665
  });
23604
23666
  }
@@ -24472,7 +24534,21 @@
24472
24534
  /**
24473
24535
  * Queries the current element for an element matching the given selector.
24474
24536
  *
24475
- * @param selector - The selector to query for.
24537
+ * @param selector -
24538
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
24539
+ * to query page for.
24540
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
24541
+ * can be passed as-is and a
24542
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
24543
+ * allows quering by
24544
+ * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
24545
+ * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
24546
+ * and
24547
+ * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
24548
+ * and
24549
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
24550
+ * Alternatively, you can specify the selector type using a
24551
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
24476
24552
  * @returns A {@link ElementHandle | element handle} to the first element
24477
24553
  * matching the given selector. Otherwise, `null`.
24478
24554
  */
@@ -24483,7 +24559,21 @@
24483
24559
  /**
24484
24560
  * Queries the current element for all elements matching the given selector.
24485
24561
  *
24486
- * @param selector - The selector to query for.
24562
+ * @param selector -
24563
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
24564
+ * to query page for.
24565
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
24566
+ * can be passed as-is and a
24567
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
24568
+ * allows quering by
24569
+ * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
24570
+ * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
24571
+ * and
24572
+ * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
24573
+ * and
24574
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
24575
+ * Alternatively, you can specify the selector type using a
24576
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
24487
24577
  * @returns An array of {@link ElementHandle | element handles} that point to
24488
24578
  * elements matching the given selector.
24489
24579
  */
@@ -24529,7 +24619,21 @@
24529
24619
  * );
24530
24620
  * ```
24531
24621
  *
24532
- * @param selector - The selector to query for.
24622
+ * @param selector -
24623
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
24624
+ * to query page for.
24625
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
24626
+ * can be passed as-is and a
24627
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
24628
+ * allows quering by
24629
+ * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
24630
+ * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
24631
+ * and
24632
+ * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
24633
+ * and
24634
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
24635
+ * Alternatively, you can specify the selector type using a
24636
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
24533
24637
  * @param pageFunction - The function to be evaluated in this element's page's
24534
24638
  * context. The first element matching the selector will be passed in as the
24535
24639
  * first argument.
@@ -24578,7 +24682,21 @@
24578
24682
  * ).toEqual(['Hello!', 'Hi!']);
24579
24683
  * ```
24580
24684
  *
24581
- * @param selector - The selector to query for.
24685
+ * @param selector -
24686
+ * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
24687
+ * to query page for.
24688
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
24689
+ * can be passed as-is and a
24690
+ * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
24691
+ * allows quering by
24692
+ * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
24693
+ * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
24694
+ * and
24695
+ * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
24696
+ * and
24697
+ * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
24698
+ * Alternatively, you can specify the selector type using a
24699
+ * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
24582
24700
  * @param pageFunction - The function to be evaluated in the element's page's
24583
24701
  * context. An array of elements matching the given selector will be passed to
24584
24702
  * the function as its first argument.
@@ -24645,9 +24763,9 @@
24645
24763
  * @throws Throws if an element matching the given selector doesn't appear.
24646
24764
  */
24647
24765
  async waitForSelector(selector, options = {}) {
24648
- const { updatedSelector, QueryHandler: QueryHandler2, selectorHasPseudoClasses } = getQueryHandlerAndSelector(selector);
24766
+ const { updatedSelector, QueryHandler: QueryHandler2, polling } = getQueryHandlerAndSelector(selector);
24649
24767
  return await QueryHandler2.waitFor(this, updatedSelector, {
24650
- polling: selectorHasPseudoClasses ? "raf" : void 0,
24768
+ polling,
24651
24769
  ...options
24652
24770
  });
24653
24771
  }
@@ -24659,15 +24777,32 @@
24659
24777
  }), visibility);
24660
24778
  }
24661
24779
  /**
24662
- * Checks if an element is visible using the same mechanism as
24663
- * {@link ElementHandle.waitForSelector}.
24780
+ * An element is considered to be visible if all of the following is
24781
+ * true:
24782
+ *
24783
+ * - the element has
24784
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | computed styles}.
24785
+ *
24786
+ * - the element has a non-empty
24787
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect | bounding client rect}.
24788
+ *
24789
+ * - the element's {@link https://developer.mozilla.org/en-US/docs/Web/CSS/visibility | visibility}
24790
+ * is not `hidden` or `collapse`.
24664
24791
  */
24665
24792
  async isVisible() {
24666
24793
  return await this.#checkVisibility(true);
24667
24794
  }
24668
24795
  /**
24669
- * Checks if an element is hidden using the same mechanism as
24670
- * {@link ElementHandle.waitForSelector}.
24796
+ * An element is considered to be hidden if at least one of the following is true:
24797
+ *
24798
+ * - the element has no
24799
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | computed styles}.
24800
+ *
24801
+ * - the element has an empty
24802
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect | bounding client rect}.
24803
+ *
24804
+ * - the element's {@link https://developer.mozilla.org/en-US/docs/Web/CSS/visibility | visibility}
24805
+ * is `hidden` or `collapse`.
24671
24806
  */
24672
24807
  async isHidden() {
24673
24808
  return await this.#checkVisibility(false);
@@ -26791,7 +26926,7 @@ ${sourceUrlComment}
26791
26926
  async #waitForExecutionContext() {
26792
26927
  const result = await firstValueFrom(fromEmitterEvent(this.#emitter, "context").pipe(raceWith(fromEmitterEvent(this.#emitter, "disposed").pipe(map(() => {
26793
26928
  throw new Error("Execution context was destroyed");
26794
- })))));
26929
+ })), timeout(this.timeoutSettings.timeout()))));
26795
26930
  return result;
26796
26931
  }
26797
26932
  async evaluateHandle(pageFunction, ...args) {
@@ -28975,7 +29110,7 @@ ${sourceUrlComment}
28975
29110
  }
28976
29111
  if (contextPayload.auxData && contextPayload.auxData["isDefault"]) {
28977
29112
  world = frame.worlds[MAIN_WORLD];
28978
- } else if (contextPayload.name === UTILITY_WORLD_NAME && !frame.worlds[PUPPETEER_WORLD].hasContext()) {
29113
+ } else if (contextPayload.name === UTILITY_WORLD_NAME) {
28979
29114
  world = frame.worlds[PUPPETEER_WORLD];
28980
29115
  }
28981
29116
  }