implement mochitests for openpgp message compose
Categories
(MailNews Core :: Security: OpenPGP, enhancement)
Tracking
(thunderbird_esr78 wontfix)
Tracking | Status | |
---|---|---|
thunderbird_esr78 | --- | wontfix |
People
(Reporter: mkmelin, Assigned: lasana)
References
Details
Attachments
(1 file, 8 obsolete files)
(deleted),
patch
|
mkmelin
:
review+
|
Details | Diff | Splinter Review |
We should add mochitests to test various scenarios for message composition where OpenPGP is involved:
-
Create + send (use Send Later) a signed message + open in Outbox, verify it's signed
-
Create + send an encrypted+signed message + open in Outbox, verify it's encrypted+signed
-
Create + send an encrypted (only) + open in Outbox, verify it's encrypted+signed
-
Try to send to encrypted when
** recipient key is not available
** recipient key is available but not (yet) trusted
** more than one recipient, one recipient key available but other not
** more than one recipient, one recipient key available, some not yet trusted
(Note that this flow is clunky and should be improved, so too much details may not be worth testing, the basics still would be the same.) -
Reply to an encrypted message should use encryption by default
Assignee | ||
Comment 1•4 years ago
|
||
Here are the tests I wrote for this. They work locally but there are failures on the try server I'm trying to figure out.
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 2•4 years ago
|
||
Fixed some typos.
Reporter | ||
Comment 3•4 years ago
|
||
Assignee | ||
Comment 4•4 years ago
|
||
I find these easier to read if I name it e.g.
let closed = ...
await closed;
Having the type (Promise) in the variable name is not super good practice.
closed
seems kind of vague to me, anyone unfamiliar with BrowserTestUtils might think it's a boolean at first glance. In fact await <boolean>
is valid syntax (probably due to the automatic wrapping) so they won't be wrong in thinking that. The reason I put "Promise" in the names is to be descriptive as possible. It isn't always clear that something is a Promise without reading the source, especially when we assign them to variables before awaiting.
It's a bit odd to mix callbacks and async
Can't you just let this function resolve(win);
Then let win = await getKeyStatusDialog; win.dowhatever()
The goDoCommand
call blocks until the dialog is closed so we need to close it in the handler of promiseAlertDialogOpen
or the test will timeout. I'll add a comment about that.
Reporter | ||
Comment 5•4 years ago
|
||
Well, having type in the variable name is generally frowned upon. We don't write things like enabledBoolean
either. Your right that sometimes keeping in mind what type it is is important, but here it's usually not many lines between.
Assignee | ||
Comment 6•4 years ago
|
||
Changes made, cleaned up the tests a bit.
Assignee | ||
Comment 7•4 years ago
|
||
Finally got the tests to pass on try server (debug builds most likely fail due to being slower) except for OSX. The screenshot made also shows blank windows so I'm not sure what its problem is.
Reporter | ||
Comment 8•4 years ago
|
||
Assignee | ||
Comment 9•4 years ago
|
||
instead of passing in a callback, maybe it would be better to have this return the window?
It does actually return the window via promiseAlertDialogOpen
, the callback is used because the dialog is opened with the "modal" property:
https://searchfox.org/comm-central/source/mail/components/compose/content/MsgComposeCommands.js#1842
The moment it opens, the current code path will block until it is closed. We can't get a reference to the window without using await on handleKeyStatusDialog
which will also block until we open the window.
Assignee | ||
Comment 10•4 years ago
|
||
Updated some of the Assert messages.
Assignee | ||
Comment 11•4 years ago
|
||
Reporter | ||
Comment 12•4 years ago
|
||
Assignee | ||
Comment 13•4 years ago
|
||
I suspect the failure here is related to the L10Registry error message. If you look at the stack trace being logged it looks like the same kind of issue I brought up in bug 1679213:
2020-12-14T18:17:01.408Z] 18:17:01 INFO - L10nRegistry.loadSync@resource://gre/modules/L10nRegistry.jsm:692:19
[task 2020-12-14T18:17:01.408Z] 18:17:01 INFO - fetchFile@resource://gre/modules/L10nRegistry.jsm:607:31
[task 2020-12-14T18:17:01.408Z] 18:17:01 INFO - generateResourceSetSync/<@resource://gre/modules/L10nRegistry.jsm:512:19
[task 2020-12-14T18:17:01.408Z] 18:17:01 INFO - generateResourceSetSync@resource://gre/modules/L10nRegistry.jsm:507:22
[task 2020-12-14T18:17:01.408Z] 18:17:01 INFO - generateResourceSetsForLocaleSync@resource://gre/modules/L10nRegistry.jsm:449:44
[task 2020-12-14T18:17:01.408Z] 18:17:01 INFO - generateBundlesSync@resource://gre/modules/L10nRegistry.jsm:186:7
[task 2020-12-14T18:17:01.409Z] 18:17:01 INFO - touchNext@resource://gre/modules/Localization.jsm:167:37
[task 2020-12-14T18:17:01.409Z] 18:17:01 INFO - generateBundles@resource://gre/modules/Localization.jsm:473:15
[task 2020-12-14T18:17:01.409Z] 18:17:01 INFO - @chrome://messenger/content/messengercompose/MsgComposeCommands.js:61:19
[task 2020-12-14T18:17:01.409Z] 18:17:01 INFO - waitFor@resource://testing-common/mozmill/utils.jsm:166:12
[task 2020-12-14T18:17:01.409Z] 18:17:01 INFO - WindowWatcher_waitForWindowOpen@resource://testing-common/mozmill/WindowHelpers.jsm:266:11
[task 2020-12-14T18:17:01.409Z] 18:17:01 INFO - wait_for_new_window@resource://testing-common/mozmill/WindowHelpers.jsm:637:19
[task 2020-12-14T18:17:01.409Z] 18:17:01 INFO - wait_for_compose_window@resource://testing-common/mozmill/ComposeHelpers.jsm:277:34
[task 2020-12-14T18:17:01.409Z] 18:17:01 INFO - open_compose_new_mail@resource://testing-common/mozmill/ComposeHelpers.jsm:80:10
[task 2020-12-14T18:17:01.409Z] 18:17:01 INFO - testEncryptedMessageComposition@chrome://mochitests/content/browser/comm/mail/test/browser/openpgp/composition/browser_composeEncrypted.js:153:13
[task 2020-12-14T18:17:01.409Z] 18:17:01 INFO - Tester_execTest/<@chrome://mochikit/content/browser-test.js:1069:34
utils.waitFor
is invoked and it calls thread.processNextEvent(true)
which throws things off. Maybe it's causing things to be executed out of order? Initially I started converting waitFor to use the BrowserTestUtils functions but those changes affect other places and did break at least one test I wrote.
Should I try again? Should we land this for now?
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 14•4 years ago
|
||
Bug 422451 comment 0 provides some insight into the problem with nextThread. Bug 1359923 says it should not be called from JS. Looking more and more like it needs to be replaced.
Assignee | ||
Comment 15•4 years ago
|
||
Looks like we don't use it much in core but in quite a few tests:
https://searchfox.org/comm-central/search?q=processNextEvent&path=&case=true®exp=false
Reporter | ||
Comment 16•4 years ago
|
||
Maybe something like await promiseAnimationFrame
needs to be added`? IIRC I read localization is guaranteed to be ready after that (unless there are bugs).
But yes, let's try to get it landed, with potentially debug+osx disabled if they are refusing to work.
Assignee | ||
Comment 17•4 years ago
|
||
I set the test to skip on osx.
Assignee | ||
Comment 18•4 years ago
|
||
Assignee | ||
Comment 19•4 years ago
|
||
Follow up fix for typo causing bct5
Reporter | ||
Comment 20•4 years ago
|
||
Assignee | ||
Comment 21•4 years ago
|
||
Changes made, disabled all the tests on debug and mac.
Assignee | ||
Comment 22•4 years ago
|
||
Please note; this now needs the patch from bug 1633726 to land before applying.
Assignee | ||
Comment 23•4 years ago
|
||
Try run looks healthy (lint error already fixed).
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=d0858d16280980864268b08cc6e1b835be2baabf
Reporter | ||
Comment 24•4 years ago
|
||
Reporter | ||
Updated•4 years ago
|
Assignee | ||
Comment 25•4 years ago
|
||
I'm surprised if this works, at least it's unusual to place it here. You should put this line below each test you want to disable.
I saw it done like that elsewhere, example:
https://searchfox.org/comm-central/source/mail/test/browser/account/browser.ini#45
https://searchfox.org/comm-central/source/mozilla/accessible/tests/browser/browser.ini#2
Reporter | ||
Comment 26•4 years ago
|
||
Ah, ok. I'd still prefer these to be disabled on a per-test basis.
The tests of https://searchfox.org/comm-central/rev/e385c646e9890c5f9722489a5305fda7e9bf0ebb/mail/test/browser/account/browser.ini#45 look like they could be re-enabled since bug 1265637 is now fixed.
Assignee | ||
Comment 27•4 years ago
|
||
Change made.
Reporter | ||
Comment 28•4 years ago
|
||
Assignee | ||
Comment 29•4 years ago
|
||
Sorry uploaded the wrong file, I have way too many bookmarks and patches lying around.
Reporter | ||
Updated•4 years ago
|
Comment 30•4 years ago
|
||
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/6e53cb981c40
Add tests for OpenPGP message composition. r=mkmelin
Description
•