Account manage files importing AccountManager.js inherit unwanted event handlers for dialogaccept/cancel
Categories
(MailNews Core :: Account Manager, defect)
Tracking
(thunderbird68 fixed, thunderbird69 fixed)
People
(Reporter: aceman, Assigned: aceman)
Details
Attachments
(1 file)
|
15.71 KB,
patch
|
jorgk-bmo
:
review+
jorgk-bmo
:
approval-comm-beta+
|
Details | Diff | Splinter Review |
Some files in /mailnews/base/prefs/content import AccountManager.js which then runs
document.addEventListener("dialogcancel", onNotAccept);
document.addEventListener("dialogaccept", (event) => {if (!onAccept(true)) { ... }}
Thus, all the subdialogs also get these handlers even if not applicable. Those functions are only valid in the main AM window when whole AM is closed.
E.g. after closing the Manage identities->Edit identity dialog with Cancel, I get
ReferenceError: reference to undefined property "contentFrame" in AccountManager.js:324:7
Here is the patch. It shuffles some imports and functions around so that the files do not need import AccountManager.js . I passes mozmill/account for me and we will see better on try once it works again.
Comment 3•7 years ago
|
||
Is this good for review?
Comment 5•7 years ago
|
||
(In reply to Jorg K (GMT+2) from comment #5)
::: mailnews/base/prefs/content/am-junk.js
@@ +110,5 @@}
function onPreInit(account, accountValues) {
- if (top.getAccountValue(account, accountValues, "server", "type", null, false) == "pop3")
- gDeferredToAccount = top.getAccountValue(account, accountValues,
Why adding
top.here and below?
When I remove import of AccountManager.js from am-junk.js I lose access to the function getAccountValue(). I didn't want to move that one to amUtils.js as it is dependent on other functions and global variables (which should only exist once), so I let it in AccountManager.js. Now, AccountManager.js is loaded in AccountManager.xul with is the top level document and the AM pages are separate documents inside an <iframe>. Calling 'top.' from them accesses the functions in the parent document (AccountManager.xul). We have the needed function there so we do not need to import it again via AccountManager.js. Notice there are already some calls with 'top.' in the AM files. We could actually not import anything in the frames and call all functions with 'top.', if somebody would be brave enough for that rewrite :)
I have tested this returns the correct values of "pop3" or "imap" with this 'top.' prefix.
It also makes eslint happy even though it sees no definition of getAccountValue().
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/db2315124020
move shared functions from AccountManager.js to other AM utility files so they can be safely imported without whole of AccountManager.js, to prevent adding unwanted event handlers. r=jorgk
Updated•7 years ago
|
Comment 9•7 years ago
|
||
| Assignee | ||
Comment 10•7 years ago
|
||
You want this in 68 regardless of AM in tab, otherwise AM is broken (at least the editing of identities).
Comment 11•7 years ago
|
||
Description
•