Closed Bug 1552851 Opened 7 years ago Closed 7 years ago

Account manage files importing AccountManager.js inherit unwanted event handlers for dialogaccept/cancel

Categories

(MailNews Core :: Account Manager, defect)

defect
Not set
normal

Tracking

(thunderbird68 fixed, thunderbird69 fixed)

RESOLVED FIXED
Thunderbird 69.0
Tracking Status
thunderbird68 --- fixed
thunderbird69 --- fixed

People

(Reporter: aceman, Assigned: aceman)

Details

Attachments

(1 file)

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

Attached patch 1552851.patchSplinter Review

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.

Assignee: nobody → acelists
Status: NEW → ASSIGNED

Is this good for review?

Attachment #9066192 - Flags: review?(jorgk)
Comment on attachment 9066192 [details] [diff] [review] 1552851.patch Review of attachment 9066192 [details] [diff] [review]: ----------------------------------------------------------------- Looks OK, try is green apart from the currently expected failures. ::: 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?
Attachment #9066192 - Flags: review?(jorgk) → review+

(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().

Thanks for the explanation. Good to go, right?

Keywords: checkin-needed

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

Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 69.0
Comment on attachment 9066192 [details] [diff] [review] 1552851.patch I guess we want to backport this to prepare for "AM in tab", right?
Attachment #9066192 - Flags: approval-comm-beta+

You want this in 68 regardless of AM in tab, otherwise AM is broken (at least the editing of identities).

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: