Closed Bug 831664 Opened 8 years ago Closed 8 years ago

IMAP property such as incomingServer.trashFolderName/isGMailServer of IMAP server is kept undefined after account switch or restart, unless all properties of an msgFolder object including rootFolder under the server is accessed

Categories

(MailNews Core :: Backend, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: World, Unassigned)

References

(Depends on 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

[BuildID] Thunderbird 17.0.2 on Win-XP(upgraded from Tb 17.0)

"undefined" is returned to msgFolder.server.trashFolderName/isGMailServer, and if change is attempted, exception occurrs.
> [Exception... "Cannot modify properties of a WrappedNative" nsresult: "0x80570034 (NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN)"

[Step to reproduce]
(1) Gmail IMAP account (mail.server.serverN.hostname=imap.gmail.com)
    IMAP delete model = "Move to trash". Other: existent folder
(2) Install extension for test which accesses incomingServer's properties.

[ Phenomenon-1 ]

Do following by JavaScript code of an extension when an folder of Gmail IMAP account is selected at folder pane. 
> var CurrentFolder = GetFirstSelectedMsgFolder() ; // window.GetFirstSelectedMsgFolder()
> var message =" serverURI = " + CurrentFolder.server.serverURI      +
>                  ", type = " + CurrentFolder.server.type           +
>         ", isGMailServer = " + CurrentFolder.server.isGMailServer  +
>       ", trashFolderName = " + CurrentFolder.server.trashFolderName ;
> Write the message to Error Console

Following is shown at Error Console.
>  serverURI = imap://yatter.king%40gmail.com@imap.gmail.com, type = imap,
>              isGMailServer = undefined, trashFolderName = undefined

[ Phenomenon-2 ]

If CurrentFolder.server.trashFolderName="TrashX"("[Gmail]/Trash", "TestX/TrashX" etc.), or CurrentFolder.server.isGMailServer=true(or false), is requsted when trashFolderName==undefined/isGMailServer==undefined, following exception is reported to Error Console.
> [Exception... "Cannot modify properties of a WrappedNative"  nsresult: "0x80570034 (NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN)"
> location: "JS frame :: chrome:// ...JS-file-of-addon.js :: <TOP_LEVEL> :: line NNN"  data: no]

This is same exception as bug 428602(many are closed as DUP simply because of "same exception" even though exception on different object.)
Bug 701326 is a bug which is not duped to bug 428602.

[ Phenomenon-3 ]

With test profile I used for long time, I could see following,
- isGMailServer=true is returned.
  change to isGMailServer=false is successful.
  after collapse/expand of Gmail account, isGMailServer=true is returned.
- trashFolderName = <currently set folder name> is returned.
  change to isGMailServer=<different folder name> is successful.
  and the change is imeediately propagated to following prefs.js entry,
      mail.server.serverN.trash_folder_name 
  ans is also reflected to trash folder selection of Server Settings.
After some tests, "undefined" was returned, and once "undefined" is retrned, I couldn't obtain normal value.

After new profile creation, I couldn't see normal value in Tb 17.0.2 any more.

After new profile creation and after some unknown operations(delete panacea.dat, delete server.msf, collapse/expand of account, restart, subscribe/unsubscribe, ...), I could observe normal value several by Tb 10.0esr, by a Tb 16 trunk nightly build several times. But once "undefined" is returned, I couldn't see normal value.

[Q1] Is msgFolder.server.trashFolderName=="undefined" and msgFolder.server.isGMailServer=="undefined" intentional?

IIRC, "Others: Trash at Server Settings ( == mail.server.serverN.trash_folder_name = "
[Gmail]/Trash") was automatically set after login to Gmail IMAP server by old Tb. This may be done by flow like following;
  msgFolder.erver.trashFolderName change to [Gmail]/Trash by Imap code
  => mail.server.serverN.trash_folder_name change by Account Manager
If so, it's broken in Tb 17.0.2...

(Q2) Script is loaded by following overlayMessenger.xul which is overlay to chrome://messenger/content/extraCustomizeItems.xul for adding customized ToolBar button.
Caue of "undefined" is bad Script load request at wrong place by me?

> <overlay id="WinBackMyTrash-overlay"
>          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
> 	<script src="WinBackMyTrash-0-Define-Global.js" />
> 	<script src="WinBackMyTrash-1-Handler.js"       />
> 	<script src="WinBackMyTrash.js"                 />
> 	<toolbarpalette id="MailToolbarPalette">
> 		<toolbarbutton
> 			         id="WinBackMyTrash1"
> 			      label="WinBackMyTrash1"
> 			tooltiptext="WinBackMyTrash1"
> 			oncommand="WinBackMyTrashGlobals.myfunc.Handler_1(WinBackMyTrashGlobals);"
> 			class="toolbarbutton-1"
> 			removable="true"
> 		/>
> 	</toolbarpalette>
</overlay>
While I repeated check of trashFolderName and isGMailServer value by the extension for test(upon button click, check the properties ans show the value) with Tb 17.0.2, with newly created profile, I could see normal value upon a button click, but upon other folder selecttion and next button click, "undefined" was shown again.

Problem in wrapper of native object?
When "undefind" is returned, property actually doesn't exist.
> for(var prop in msgFolder.server)
> { text = prop + " = " + msgFolder.server[prop]; Write to Error Console; }
> => trashFolderName, isGMailServer, is not listed

Wrapper fails to find propety? Or Tb dosn't set the property?
Setting dependency to bug 428602 or ease of analysis and tracking.
Depends on: 428602
When wrong text was written to Error Consolde, missing properties was shown normally. (trashFolderName, isGMailServer, personalNamespace is checked) 
  A way to write long txt to Error Console.
    var msg=new Array();for(var key in obj){msg[msg.length]=key+" = "+obj[key];}
    var text=msg.join("\n"); Write text to Error Console;
This extenstion has two customized ToolBar buttons.
Buton 1 is for this bug.
Button 1 simply does following under messenger window.
  var CurrentFolder=GetFirstSelectedMsgFolder();
  Dump CurrentFolder.server object etc.
  Putlog dumped data to Error Console, 
     where 
       Dump   : put object data to JavaScript Array by
                for(var x in object){ txt[txt.length]=x+"="+object[x];},
       Putlog : convert data saved in array of txt to string by txt.join(","),
  Try to change CurrentFolder.server.isGmailServer even when undefined.

How to use, and test result.

(1) Add button1 of customized ToolBar button to Menue Bar(or ToolBar),
    Open Error Console.
(2) Select folder of an Gmail IMAP account at folder pane,
    Select a mail at thread pane.
(3) Select a submenu under "Toggle is_gmail" of button 1.
    Button1 -> Toggle is_gmail
      Without log
        var CurrentFolder=GetFirstSelectedMsgFolder();
        CurrentFolder.server.isGmailServer=true => Exception
      With log(multi-server)
        var CurrentFolder=GetFirstSelectedMsgFolder();
        10 times of ( Dump CurrentFolder.server => isGmailServer == undefined )
        Force Putlog to Error Console 
        Dump CurrentFolder.server => isGmailServer is still undefined
        CurrentFolder.server.isGmailServer=true => Exception
      With log(service)
        var CurrentFolder=GetFirstSelectedMsgFolder();
        Dump CurrentFolder.server => isGmailServer == undefined
        Dump many services such as IO service, Console service, IMAP service
        Force Putlog to Error Console 
        Dump CurrentFolder.server => isGmailServer is still undefined
        CurrentFolder.server.isGmailServer=true => Exception
      With log(window)
        var CurrentFolder=GetFirstSelectedMsgFolder();
        Dump CurrentFolder.server => isGmailServer == undefined
        Dump window.window
        Force Putlog to Error Console 
        Dump CurrentFolder.server => isGmailServer is still undefined
        CurrentFolder.server.isGmailServer=true => Exception
      With log(msgFolder)
        var CurrentFolder=GetFirstSelectedMsgFolder();
        Dump CurrentFolder.server => isGmailServer == undefined
        Dump CurrentFolder
        (== accessed all properties of owner of CurrentFolder.server) 
        Don't Putlog to Error Console in this case
        Dump CurrentFolder.server => isGmailServer is returned
        Other property such as trashFolderName, personalNamespace,
        are also normally returned at this step.
        CurrentFolder.server.isGmailServer=true => normally changed
        
"Forcing Error Console log write or not" is irrelivant to problem.
"Forcing Error Console log write" is to see "log volume written to Error Console is irrelevant to problem"."
Why "writing many logs to Error Console" could be an workaound in previous tests was;
  I dumped CurrentFolder object who is owner of CurrentFolder.server while test
  to see data of CurrentFolder object for other test.

It may be phenomenon like next.
   Until some properties of CurrentFolder is accessed,
   some properties of object pointed by CurrentFolder.server
   is not set correctly, or is not accessible.
Button1, "MsgFolder.server check" submenu, is added.
Checks difference of enumerated properties of CurrenFolder.server, between "Before access of all properties of CorrentFolder" and "After access of all properties of CorrentFolder".
"AfterOnly" in Error Console log is property name which apears only after access of all properties of CurrrentFolder object.
It looks IMAP related properties.

Some properties of MsgFolder is initialized upon first access of other property and some properties of MsgFolder.server are also initialized by it?
Attachment #709797 - Attachment is obsolete: true
Following is properties of window.GetFirstSelectedMsgFolder().server object which are shown only after all properties of window.GetFirstSelectedMsgFolder() object is accessed. Many of them looks IMAP property.

AfterOnly = { maximumConnectionsNumber, timeOutLimits, adminUrl, serverDirectory, serverIDPref, cleanupInboxOnExit, deleteModel, dualUseFolders, emptyTrashThreshhold, personalNamespace, publicNamespace, otherUsersNamespace, offlineDownload, overrideNamespaces, usingSubscription, manageMailAccountUrl, fetchByChunks, mimePartsOnDemand, sendID, isAOLServer, capabilityACL, capabilityQuota, useIdle, checkAllFoldersForNew, isGMailServer, useCondStore, useCompressDeflate, trashFolderName, downloadBodiesOnGetNewMail, autoSyncOfflineStores, autoSyncMaxAgeDays, GetImapConnectionAndLoadUrl, RemoveConnection, ResetNamespaceReferences, pseudoInterruptMsgLoad, ResetConnection, CloseConnectionForFolder, reDiscoverAllFolders, subscribeToFolder, GetNewMessagesForNonInboxFolders, PromptPassword, doingLsub, getUriWithNamespacePrefixIfNecessary, shuttingDown }
Removing description about exception detail from bug summary, because no problem in the exception if error code will be changed to one like NS_ERROR_XPC_CANT_CREATE_PROP_ON_WN instead of misleading NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN.
Summary: "undefined" is returned to msgFolder.server.trashFolderName/isGMailServer, and if chage is attempted, exception occurrs. [Exception... "Cannot modify properties of a WrappedNative" nsresult: "0x80570034 (NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN)" → IMAP property such as incomingServer.trashFolderName/isGMailServer of IMAP server is kept undefined after account switch or restart, unless all properties of an msgFolder object including rootFolder under the server is accessed
New Bug Summary:
IMAP property such as incomingServer.trashFolderName/isGMailServer of IMAP server is kept undefined after account switch or restart, unless all properties of an msgFolder object including rootFolder under the server is accessed.
trashFolderName and isGMailServer are both properties on the nsIImapIncomingServer interface (http://mxr.mozilla.org/comm-central/source/mailnews/imap/public/nsIImapIncomingServer.idl).

As indicated in various places in your debug, your incomingServer/server is an nsIMsgIncomingInterface. Therefore you must queryInterface(Components.interfaces.nsIImapIncomingServer) to access these properties.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.