Skip to content

Commit 1d069fa

Browse files
dbajpeyigithub-actions[bot]
authored andcommitted
Release build 11.38.0 [ci release]
1 parent e44e153 commit 1d069fa

File tree

6 files changed

+125
-45
lines changed

6 files changed

+125
-45
lines changed

CHANGELOG.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
- Trim links and include images (#2011)
2-
- Using gated logger for console.warn (#2013)
1+
- [Google import] Add resilience to download data (#2001)

build/android/autofillImport.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9456,20 +9456,35 @@
94569456
}
94579457
/** Bookmark import code */
94589458
async downloadData() {
9459-
await new Promise((resolve) => setTimeout(resolve, 1e3));
9460-
const userId = document.querySelector(this.bookmarkImportSelectorSettings.userIdLink)?.getAttribute("href")?.split("&user=")[1];
9461-
await this.runWithRetry(() => document.querySelector(`a[href="./manage/archive/${__privateGet(this, _exportId)}"]`), 15, 2e3, "linear");
9462-
if (userId != null && __privateGet(this, _exportId) != null) {
9463-
const downloadURL = `${TAKEOUT_DOWNLOAD_URL_BASE}?j=${__privateGet(this, _exportId)}&i=0&user=${userId}`;
9464-
window.location.href = downloadURL;
9465-
} else {
9459+
const downloadRetryLimit = this.getFeatureSetting("downloadRetryLimit") ?? Infinity;
9460+
const downloadRetryInterval = this.getFeatureSetting("downloadRetryInterval") ?? 1e3;
9461+
const userIdElement = await this.runWithRetry(
9462+
() => document.querySelector(this.bookmarkImportSelectorSettings.userIdLink),
9463+
downloadRetryLimit,
9464+
downloadRetryInterval,
9465+
"linear"
9466+
);
9467+
const userIdLink = userIdElement?.getAttribute("href");
9468+
const userId = userIdLink ? new URL(userIdLink, window.location.origin).searchParams.get("user") : null;
9469+
if (!userId || !__privateGet(this, _exportId)) {
94669470
this.postBookmarkImportMessage("actionCompleted", {
94679471
result: new ErrorResponse({
94689472
actionID: "download-data",
9469-
message: "No user id or export id found"
9473+
message: "User id or export id not found"
94709474
})
94719475
});
9476+
return;
94729477
}
9478+
await this.runWithRetry(
9479+
() => document.querySelector(`a[href="./manage/archive/${__privateGet(this, _exportId)}"]`),
9480+
downloadRetryLimit,
9481+
downloadRetryInterval,
9482+
"linear"
9483+
);
9484+
const downloadURL = `${TAKEOUT_DOWNLOAD_URL_BASE}?j=${__privateGet(this, _exportId)}&i=0&user=${userId}`;
9485+
const downloadNavigationDelayMs = this.getFeatureSetting("downloadNavigationDelayMs") ?? 2e3;
9486+
await new Promise((resolve) => setTimeout(resolve, downloadNavigationDelayMs));
9487+
window.location.href = downloadURL;
94739488
}
94749489
/**
94759490
* Here we ignore the action and return a default retry config

build/integration/contentScope.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21507,20 +21507,35 @@ ${truncatedWarning}
2150721507
}
2150821508
/** Bookmark import code */
2150921509
async downloadData() {
21510-
await new Promise((resolve) => setTimeout(resolve, 1e3));
21511-
const userId = document.querySelector(this.bookmarkImportSelectorSettings.userIdLink)?.getAttribute("href")?.split("&user=")[1];
21512-
await this.runWithRetry(() => document.querySelector(`a[href="./manage/archive/${__privateGet(this, _exportId)}"]`), 15, 2e3, "linear");
21513-
if (userId != null && __privateGet(this, _exportId) != null) {
21514-
const downloadURL = `${TAKEOUT_DOWNLOAD_URL_BASE}?j=${__privateGet(this, _exportId)}&i=0&user=${userId}`;
21515-
window.location.href = downloadURL;
21516-
} else {
21510+
const downloadRetryLimit = this.getFeatureSetting("downloadRetryLimit") ?? Infinity;
21511+
const downloadRetryInterval = this.getFeatureSetting("downloadRetryInterval") ?? 1e3;
21512+
const userIdElement = await this.runWithRetry(
21513+
() => document.querySelector(this.bookmarkImportSelectorSettings.userIdLink),
21514+
downloadRetryLimit,
21515+
downloadRetryInterval,
21516+
"linear"
21517+
);
21518+
const userIdLink = userIdElement?.getAttribute("href");
21519+
const userId = userIdLink ? new URL(userIdLink, window.location.origin).searchParams.get("user") : null;
21520+
if (!userId || !__privateGet(this, _exportId)) {
2151721521
this.postBookmarkImportMessage("actionCompleted", {
2151821522
result: new ErrorResponse({
2151921523
actionID: "download-data",
21520-
message: "No user id or export id found"
21524+
message: "User id or export id not found"
2152121525
})
2152221526
});
21527+
return;
2152321528
}
21529+
await this.runWithRetry(
21530+
() => document.querySelector(`a[href="./manage/archive/${__privateGet(this, _exportId)}"]`),
21531+
downloadRetryLimit,
21532+
downloadRetryInterval,
21533+
"linear"
21534+
);
21535+
const downloadURL = `${TAKEOUT_DOWNLOAD_URL_BASE}?j=${__privateGet(this, _exportId)}&i=0&user=${userId}`;
21536+
const downloadNavigationDelayMs = this.getFeatureSetting("downloadNavigationDelayMs") ?? 2e3;
21537+
await new Promise((resolve) => setTimeout(resolve, downloadNavigationDelayMs));
21538+
window.location.href = downloadURL;
2152421539
}
2152521540
/**
2152621541
* Here we ignore the action and return a default retry config

injected/integration-test/extension/contentScope.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21507,20 +21507,35 @@ ${truncatedWarning}
2150721507
}
2150821508
/** Bookmark import code */
2150921509
async downloadData() {
21510-
await new Promise((resolve) => setTimeout(resolve, 1e3));
21511-
const userId = document.querySelector(this.bookmarkImportSelectorSettings.userIdLink)?.getAttribute("href")?.split("&user=")[1];
21512-
await this.runWithRetry(() => document.querySelector(`a[href="./manage/archive/${__privateGet(this, _exportId)}"]`), 15, 2e3, "linear");
21513-
if (userId != null && __privateGet(this, _exportId) != null) {
21514-
const downloadURL = `${TAKEOUT_DOWNLOAD_URL_BASE}?j=${__privateGet(this, _exportId)}&i=0&user=${userId}`;
21515-
window.location.href = downloadURL;
21516-
} else {
21510+
const downloadRetryLimit = this.getFeatureSetting("downloadRetryLimit") ?? Infinity;
21511+
const downloadRetryInterval = this.getFeatureSetting("downloadRetryInterval") ?? 1e3;
21512+
const userIdElement = await this.runWithRetry(
21513+
() => document.querySelector(this.bookmarkImportSelectorSettings.userIdLink),
21514+
downloadRetryLimit,
21515+
downloadRetryInterval,
21516+
"linear"
21517+
);
21518+
const userIdLink = userIdElement?.getAttribute("href");
21519+
const userId = userIdLink ? new URL(userIdLink, window.location.origin).searchParams.get("user") : null;
21520+
if (!userId || !__privateGet(this, _exportId)) {
2151721521
this.postBookmarkImportMessage("actionCompleted", {
2151821522
result: new ErrorResponse({
2151921523
actionID: "download-data",
21520-
message: "No user id or export id found"
21524+
message: "User id or export id not found"
2152121525
})
2152221526
});
21527+
return;
2152321528
}
21529+
await this.runWithRetry(
21530+
() => document.querySelector(`a[href="./manage/archive/${__privateGet(this, _exportId)}"]`),
21531+
downloadRetryLimit,
21532+
downloadRetryInterval,
21533+
"linear"
21534+
);
21535+
const downloadURL = `${TAKEOUT_DOWNLOAD_URL_BASE}?j=${__privateGet(this, _exportId)}&i=0&user=${userId}`;
21536+
const downloadNavigationDelayMs = this.getFeatureSetting("downloadNavigationDelayMs") ?? 2e3;
21537+
await new Promise((resolve) => setTimeout(resolve, downloadNavigationDelayMs));
21538+
window.location.href = downloadURL;
2152421539
}
2152521540
/**
2152621541
* Here we ignore the action and return a default retry config

injected/integration-test/test-pages/build/contentScope.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21507,20 +21507,35 @@ ${truncatedWarning}
2150721507
}
2150821508
/** Bookmark import code */
2150921509
async downloadData() {
21510-
await new Promise((resolve) => setTimeout(resolve, 1e3));
21511-
const userId = document.querySelector(this.bookmarkImportSelectorSettings.userIdLink)?.getAttribute("href")?.split("&user=")[1];
21512-
await this.runWithRetry(() => document.querySelector(`a[href="./manage/archive/${__privateGet(this, _exportId)}"]`), 15, 2e3, "linear");
21513-
if (userId != null && __privateGet(this, _exportId) != null) {
21514-
const downloadURL = `${TAKEOUT_DOWNLOAD_URL_BASE}?j=${__privateGet(this, _exportId)}&i=0&user=${userId}`;
21515-
window.location.href = downloadURL;
21516-
} else {
21510+
const downloadRetryLimit = this.getFeatureSetting("downloadRetryLimit") ?? Infinity;
21511+
const downloadRetryInterval = this.getFeatureSetting("downloadRetryInterval") ?? 1e3;
21512+
const userIdElement = await this.runWithRetry(
21513+
() => document.querySelector(this.bookmarkImportSelectorSettings.userIdLink),
21514+
downloadRetryLimit,
21515+
downloadRetryInterval,
21516+
"linear"
21517+
);
21518+
const userIdLink = userIdElement?.getAttribute("href");
21519+
const userId = userIdLink ? new URL(userIdLink, window.location.origin).searchParams.get("user") : null;
21520+
if (!userId || !__privateGet(this, _exportId)) {
2151721521
this.postBookmarkImportMessage("actionCompleted", {
2151821522
result: new ErrorResponse({
2151921523
actionID: "download-data",
21520-
message: "No user id or export id found"
21524+
message: "User id or export id not found"
2152121525
})
2152221526
});
21527+
return;
2152321528
}
21529+
await this.runWithRetry(
21530+
() => document.querySelector(`a[href="./manage/archive/${__privateGet(this, _exportId)}"]`),
21531+
downloadRetryLimit,
21532+
downloadRetryInterval,
21533+
"linear"
21534+
);
21535+
const downloadURL = `${TAKEOUT_DOWNLOAD_URL_BASE}?j=${__privateGet(this, _exportId)}&i=0&user=${userId}`;
21536+
const downloadNavigationDelayMs = this.getFeatureSetting("downloadNavigationDelayMs") ?? 2e3;
21537+
await new Promise((resolve) => setTimeout(resolve, downloadNavigationDelayMs));
21538+
window.location.href = downloadURL;
2152421539
}
2152521540
/**
2152621541
* Here we ignore the action and return a default retry config

injected/src/features/autofill-import.js

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -590,23 +590,44 @@ export default class AutofillImport extends ActionExecutorBase {
590590

591591
/** Bookmark import code */
592592
async downloadData() {
593-
// sleep for a second, sometimes download link is not yet available
594-
await new Promise((resolve) => setTimeout(resolve, 1000));
595-
596-
const userId = document.querySelector(this.bookmarkImportSelectorSettings.userIdLink)?.getAttribute('href')?.split('&user=')[1];
597-
await this.runWithRetry(() => document.querySelector(`a[href="./manage/archive/${this.#exportId}"]`), 15, 2000, 'linear');
598-
if (userId != null && this.#exportId != null) {
599-
const downloadURL = `${TAKEOUT_DOWNLOAD_URL_BASE}?j=${this.#exportId}&i=0&user=${userId}`;
600-
window.location.href = downloadURL;
601-
} else {
602-
// If there's no user id or export id, we post an action failed message
593+
// Run with retry forever until the download link is available,
594+
// Android is the one that timesout anyway and closes the whole tab if this doesn't complete
595+
const downloadRetryLimit = this.getFeatureSetting('downloadRetryLimit') ?? Infinity;
596+
const downloadRetryInterval = this.getFeatureSetting('downloadRetryInterval') ?? 1000;
597+
598+
const userIdElement = await this.runWithRetry(
599+
() => document.querySelector(this.bookmarkImportSelectorSettings.userIdLink),
600+
downloadRetryLimit,
601+
downloadRetryInterval,
602+
'linear',
603+
);
604+
const userIdLink = userIdElement?.getAttribute('href');
605+
const userId = userIdLink ? new URL(userIdLink, window.location.origin).searchParams.get('user') : null;
606+
607+
if (!userId || !this.#exportId) {
603608
this.postBookmarkImportMessage('actionCompleted', {
604609
result: new ErrorResponse({
605610
actionID: 'download-data',
606-
message: 'No user id or export id found',
611+
message: 'User id or export id not found',
607612
}),
608613
});
614+
return;
609615
}
616+
617+
await this.runWithRetry(
618+
() => document.querySelector(`a[href="./manage/archive/${this.#exportId}"]`),
619+
downloadRetryLimit,
620+
downloadRetryInterval,
621+
'linear',
622+
);
623+
624+
const downloadURL = `${TAKEOUT_DOWNLOAD_URL_BASE}?j=${this.#exportId}&i=0&user=${userId}`;
625+
626+
// Sleep before downloading to ensure the download link is available
627+
const downloadNavigationDelayMs = this.getFeatureSetting('downloadNavigationDelayMs') ?? 2000;
628+
await new Promise((resolve) => setTimeout(resolve, downloadNavigationDelayMs));
629+
630+
window.location.href = downloadURL;
610631
}
611632

612633
/**

0 commit comments

Comments
 (0)