Skip to content

Commit 88f8adf

Browse files
authored
Merge branch 'master' into issue-5905-add-secure-reply-all-to-gmail-context-menu-live-test
2 parents 5fdca47 + 63269ad commit 88f8adf

File tree

4 files changed

+106
-76
lines changed

4 files changed

+106
-76
lines changed

extension/js/content_scripts/webmail/gmail/gmail-element-replacer.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,8 @@ export class GmailElementReplacer extends WebmailElementReplacer {
618618
return from ? Str.parseEmail(from) : undefined;
619619
};
620620

621-
private getLastMsgReplyParams = (convoRootEl: JQuery, replyOption?: ReplyOption): FactoryReplyParams => {
622-
return { replyMsgId: this.determineMsgId($(convoRootEl).find(this.sel.msgInner).last()), replyOption };
621+
private getLastMsgReplyParams = (convoRootEl: JQuery, replyOption?: ReplyOption, replyBoxMessageId?: string | null): FactoryReplyParams => {
622+
return { replyMsgId: replyBoxMessageId ?? this.determineMsgId($(convoRootEl).find(this.sel.msgInner).last()), replyOption };
623623
};
624624

625625
private getConvoRootEl = (anyInnerElement: HTMLElement) => {
@@ -645,9 +645,13 @@ export class GmailElementReplacer extends WebmailElementReplacer {
645645
// removing this line will cause unexpected draft creation bug reappear
646646
// https://github.com/FlowCrypt/flowcrypt-browser/issues/5616#issuecomment-1972897692
647647
this.replyOption = undefined;
648+
// Try to get message id from plain reply box
649+
// https://github.com/FlowCrypt/flowcrypt-browser/issues/5906
650+
const replyBoxMessageId = newReplyBoxes[0].closest('.gA.gt')?.previousElementSibling?.getAttribute('data-legacy-message-id');
651+
648652
// cache for subseqent loop runs
649653
const convoRootEl = this.getConvoRootEl(newReplyBoxes[0]);
650-
const replyParams = this.getLastMsgReplyParams(convoRootEl);
654+
const replyParams = this.getLastMsgReplyParams(convoRootEl, undefined, replyBoxMessageId);
651655
if (msgId) {
652656
replyParams.replyMsgId = msgId;
653657
}

package-lock.json

Lines changed: 68 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"@openpgp/web-stream-tools": "^0.1.3",
1010
"@types/chai": "4.3.19",
1111
"@types/chai-as-promised": "7.1.8",
12-
"@types/chrome": "0.0.299",
12+
"@types/chrome": "0.0.300",
1313
"@types/jquery": "3.5.32",
1414
"@types/mailparser": "3.4.5",
1515
"ava": "5.3.1",
@@ -28,14 +28,14 @@
2828
"lint-staged": "^15.4.3",
2929
"mailparser": "3.7.2",
3030
"mkdirp": "3.0.1",
31-
"openpgp": "6.0.1",
31+
"openpgp": "6.1.0",
3232
"pdfjs-dist": "4.10.38",
3333
"prettier": "^3.4.1",
3434
"puppeteer": "24.1.1",
35-
"stylelint": "16.14.0",
35+
"stylelint": "16.14.1",
3636
"stylelint-config-standard": "37.0.0",
3737
"typescript": "5.7.3",
38-
"typescript-eslint": "^8.21.0",
38+
"typescript-eslint": "^8.22.0",
3939
"undici-types": "^7.3.0",
4040
"web-ext": "8.3.0",
4141
"webpack-cli": "^6.0.1"
@@ -45,7 +45,7 @@
4545
"@types/thunderbird-webext-browser": "^127.0.0",
4646
"bootstrap": "4.6.2",
4747
"clipboard": "2.0.11",
48-
"dompurify": "3.2.3",
48+
"dompurify": "3.2.4",
4949
"filesize": "10.1.2",
5050
"iso-8859-2": "1.0.0",
5151
"jquery": "3.7.1",

test/source/tests/gmail.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,32 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test
402402
})
403403
);
404404

405+
// https://github.com/FlowCrypt/flowcrypt-browser/issues/5906
406+
test(
407+
'mail.google.com - Keep original reply message when switching to secure mode',
408+
testWithBrowser(async (t, browser) => {
409+
await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail');
410+
const gmailPage = await openGmailPage(t, browser);
411+
await gotoGmailPage(gmailPage, '/FMfcgzGqRGfPBbNLWvfPvDbxnHBwkdGf'); // plain convo
412+
await Util.sleep(30);
413+
await gmailPage.waitAndClick('[role="listitem"] .adf.ads', { delay: 1 }); // click first message of thread
414+
await Util.sleep(3);
415+
const messages = await gmailPage.target.$$('[role="listitem"] .adn.ads');
416+
const plainReplyButton = await messages[0].$('[data-tooltip="Reply"]');
417+
await Util.sleep(1);
418+
await plainReplyButton!.click();
419+
await gmailPage.waitAndClick('#switch_to_encrypted_reply'); // Switch to encrypted compose
420+
await Util.sleep(2);
421+
await gmailPage.waitAll('.reply_message');
422+
await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true, composeFrameCount: 2 });
423+
const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&skipClickPrompt=___cu_true___'], { sleep: 5 });
424+
await Util.sleep(3);
425+
await replyBox.waitAndClick('@action-expand-quoted-text');
426+
// Check if quoted message doesn't contain last message
427+
expect(await replyBox.read('@input-body')).to.not.contain(`Here's reply`);
428+
})
429+
);
430+
405431
test(
406432
'mail.google.com - switch to encrypted reply for middle message',
407433
testWithBrowser(async (t, browser) => {

0 commit comments

Comments
 (0)