diff --git a/.github/workflows/update-browser-pins.yml b/.github/workflows/update-browser-pins.yml index 6ad0b493f3e..de92985cf7d 100644 --- a/.github/workflows/update-browser-pins.yml +++ b/.github/workflows/update-browser-pins.yml @@ -32,7 +32,7 @@ jobs: node tools/update_chrome_revision.mjs - name: Create Pull Request if: ${{ steps.update.outputs.commit }} - uses: peter-evans/create-pull-request@70a41aba780001da0a30141984ae2a0c95d8704e # v6.0.2 + uses: peter-evans/create-pull-request@c55203cfde3e5c11a452d352b4393e68b85b4533 # v6.0.3 with: token: ${{ secrets.BROWSER_AUTOMATION_BOT_TOKEN }} branch: browser-automation-bot/update-browser-version-chrome @@ -64,7 +64,7 @@ jobs: node packages/browsers/tools/updateVersions.mjs - name: Create Pull Request if: ${{ steps.update.outputs.commit }} - uses: peter-evans/create-pull-request@70a41aba780001da0a30141984ae2a0c95d8704e # v6.0.2 + uses: peter-evans/create-pull-request@c55203cfde3e5c11a452d352b4393e68b85b4533 # v6.0.3 with: token: ${{ secrets.BROWSER_AUTOMATION_BOT_TOKEN }} branch: browser-automation-bot/update-browser-version-firefox diff --git a/packages/puppeteer-core/src/api/ElementHandle.ts b/packages/puppeteer-core/src/api/ElementHandle.ts index 84e61f33c12..70ce46d0b8e 100644 --- a/packages/puppeteer-core/src/api/ElementHandle.ts +++ b/packages/puppeteer-core/src/api/ElementHandle.ts @@ -145,6 +145,13 @@ export abstract class ElementHandle< */ declare [_isElementHandle]: boolean; + /** + * @internal + * Cached isolatedHandle to prevent + * trying to adopt it multiple times + */ + isolatedHandle?: typeof this; + /** * A given method will have it's `this` replaced with an isolated version of * `this` when decorated with this decorator. @@ -163,7 +170,14 @@ export abstract class ElementHandle< if (this.realm === this.frame.isolatedRealm()) { return await target.call(this, ...args); } - using adoptedThis = await this.frame.isolatedRealm().adoptHandle(this); + let adoptedThis: This; + if (this['isolatedHandle']) { + adoptedThis = this['isolatedHandle']; + } else { + this['isolatedHandle'] = adoptedThis = await this.frame + .isolatedRealm() + .adoptHandle(this); + } const result = await target.call(adoptedThis, ...args); // If the function returns `adoptedThis`, then we return `this`. if (result === adoptedThis) {