mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(performance): cache isolatedHandle (#12150)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
parent
3b70667a47
commit
9a17ec3b2a
4
.github/workflows/update-browser-pins.yml
vendored
4
.github/workflows/update-browser-pins.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
|||||||
node tools/update_chrome_revision.mjs
|
node tools/update_chrome_revision.mjs
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
if: ${{ steps.update.outputs.commit }}
|
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:
|
with:
|
||||||
token: ${{ secrets.BROWSER_AUTOMATION_BOT_TOKEN }}
|
token: ${{ secrets.BROWSER_AUTOMATION_BOT_TOKEN }}
|
||||||
branch: browser-automation-bot/update-browser-version-chrome
|
branch: browser-automation-bot/update-browser-version-chrome
|
||||||
@ -64,7 +64,7 @@ jobs:
|
|||||||
node packages/browsers/tools/updateVersions.mjs
|
node packages/browsers/tools/updateVersions.mjs
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
if: ${{ steps.update.outputs.commit }}
|
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:
|
with:
|
||||||
token: ${{ secrets.BROWSER_AUTOMATION_BOT_TOKEN }}
|
token: ${{ secrets.BROWSER_AUTOMATION_BOT_TOKEN }}
|
||||||
branch: browser-automation-bot/update-browser-version-firefox
|
branch: browser-automation-bot/update-browser-version-firefox
|
||||||
|
@ -145,6 +145,13 @@ export abstract class ElementHandle<
|
|||||||
*/
|
*/
|
||||||
declare [_isElementHandle]: boolean;
|
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
|
* A given method will have it's `this` replaced with an isolated version of
|
||||||
* `this` when decorated with this decorator.
|
* `this` when decorated with this decorator.
|
||||||
@ -163,7 +170,14 @@ export abstract class ElementHandle<
|
|||||||
if (this.realm === this.frame.isolatedRealm()) {
|
if (this.realm === this.frame.isolatedRealm()) {
|
||||||
return await target.call(this, ...args);
|
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);
|
const result = await target.call(adoptedThis, ...args);
|
||||||
// If the function returns `adoptedThis`, then we return `this`.
|
// If the function returns `adoptedThis`, then we return `this`.
|
||||||
if (result === adoptedThis) {
|
if (result === adoptedThis) {
|
||||||
|
Loading…
Reference in New Issue
Block a user