Closed Bug 595738 Opened 15 years ago Closed 15 years ago

Warning: assignment to undeclared variable index (in msgHdrViewOverlay.js)

Categories

(SeaMonkey :: MailNews: Message Display, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
seamonkey2.1b1

People

(Reporter: stefanh, Assigned: philip.chee)

Details

Attachments

(1 file)

Seems that we use "for (index in something)" without actually declare 'index' in a few places.
OS: Mac OS X → All
Hardware: x86 → All
Assignee: nobody → philip.chee
Status: NEW → ASSIGNED
> Seems that we use "for (index in something)" without actually declare 'index' > in a few places. I've added let to the index of various for loops. I may have gone a bit overboard with some extra s/for/let/ inside if and for blocks.
Attachment #480407 - Flags: review?(iann_bugzilla)
Also I keep getting these errors. I don't know why because as far as I can tell msgWindow.msgHeaderSink is defined in InitWindow() Warning: reference to undefined property msgWindow.msgHeaderSink Source file: chrome://messenger/content/mailWindowOverlay.js Line: 2861 ---------- Warning: reference to undefined property msgWindow.msgHeaderSink Source file: chrome://messenger-smime/content/msgHdrViewSMIMEOverlay.js Line: 216
(In reply to comment #2) > Also I keep getting these errors. I don't know why because as far as I can tell > msgWindow.msgHeaderSink is defined in InitWindow() > > Warning: reference to undefined property msgWindow.msgHeaderSink > Source file: chrome://messenger/content/mailWindowOverlay.js > Line: 2861 > ---------- > Warning: reference to undefined property msgWindow.msgHeaderSink > Source file: chrome://messenger-smime/content/msgHdrViewSMIMEOverlay.js > Line: 216 Do they appear only on certain activities?
> Do they appear only on certain activities? AFAIK, only when I open a new 3pane window or a standalone message window.
Comment on attachment 480407 [details] [diff] [review] Patch v1.0 Sprinkle some let's. r=me for the drive-by-letting
Attachment #480407 - Flags: review?(iann_bugzilla) → review+
Comment on attachment 480407 [details] [diff] [review] Patch v1.0 Sprinkle some let's. ># HG changeset patch ># User Philip Chee <philip.chee@gmail.com> ># Date 1286041038 -28800 ># Node ID 97a770c6d8d80300257427c33728da89ba87555c ># Parent 51fbb624b47a91db0a9c1f4f99932561e8322b56 >Bug 595738 Warning: assignment to undeclared variable index (in msgHdrViewOverlay.js) > >diff --git a/suite/mailnews/msgHdrViewOverlay.js b/suite/mailnews/msgHdrViewOverlay.js >--- a/suite/mailnews/msgHdrViewOverlay.js >+++ b/suite/mailnews/msgHdrViewOverlay.js >@@ -194,53 +194,52 @@ function createHeaderEntry(prefix, heade > else > this.outputFunction = updateHeaderValue; > } > > function initializeHeaderViewTables() > { > // iterate over each header in our header list arrays and create header entries > // for each one. These header entries are then stored in the appropriate header table >- var index; >- for (index = 0; index < gCollapsedHeaderList.length; index++) >+ for (let index = 0; index < gCollapsedHeaderList.length; index++) > { > gCollapsedHeaderView[gCollapsedHeaderList[index].name] = > new createHeaderEntry('collapsed', gCollapsedHeaderList[index]); > } > >- for (index = 0; index < gExpandedHeaderList.length; index++) >+ for (let index = 0; index < gExpandedHeaderList.length; index++) > { > var headerName = gExpandedHeaderList[index].name; > gExpandedHeaderView[headerName] = new createHeaderEntry('expanded', gExpandedHeaderList[index]); > } > > var extraHeaders = gExtraExpandedHeaders.match(/[^ ]+/g); > if (extraHeaders) { >- for (index = 0; index < extraHeaders.length; index++) >+ for (let index = 0; index < extraHeaders.length; index++) > { >- var extraHeader = extraHeaders[index]; >+ let extraHeader = extraHeaders[index]; > gExpandedHeaderView[extraHeader.toLowerCase()] = new createNewHeaderView(extraHeader, extraHeader + ':'); > } > } > > if (gShowOrganization) > { >- var organizationEntry = {name:"organization", outputFunction:updateHeaderValue}; >+ let organizationEntry = {name:"organization", outputFunction:updateHeaderValue}; > gExpandedHeaderView[organizationEntry.name] = new createHeaderEntry('expanded', organizationEntry); > } > > if (gShowUserAgent) > { >- var userAgentEntry = {name:"user-agent", outputFunction:updateHeaderValue}; >+ let userAgentEntry = {name:"user-agent", outputFunction:updateHeaderValue}; > gExpandedHeaderView[userAgentEntry.name] = new createHeaderEntry('expanded', userAgentEntry); > } > > if (gShowMessageId) > { >- var messageIdEntry = {name:"message-id", outputFunction:OutputMessageIds}; >+ let messageIdEntry = {name:"message-id", outputFunction:OutputMessageIds}; > gExpandedHeaderView[messageIdEntry.name] = new createHeaderEntry('expanded', messageIdEntry); > } > } > > function OnLoadMsgHeaderPane() > { > // HACK...force our XBL bindings file to be load before we try to create our first xbl widget.... > // otherwise we have problems. >@@ -499,17 +498,17 @@ var messageHeaderSink = { > onEndAllAttachments: function() > { > // AddSaveAllAttachmentsMenu(); > if (gCollapsedHeaderViewMode) > displayAttachmentsForCollapsedView(); > else > displayAttachmentsForExpandedView(); > >- for (index in gMessageListeners) { >+ for (let index in gMessageListeners) { > if ("onEndAttachments" in gMessageListeners[index]) > gMessageListeners[index].onEndAttachments(); > } > }, > > onEndMsgDownload: function(url) > { > // if we don't have any attachments, turn off the attachments flag >@@ -601,17 +600,17 @@ function SetTagHeader() > var labelKey = "$label" + label; > if (msgKeyArray.indexOf(labelKey) < 0) > msgKeyArray.unshift(labelKey); > } > > // Rebuild the keywords string with just the keys that are actual tags or > // legacy labels and not other keywords like Junk and NonJunk. > // Retain their order, though, with the label as oldest element. >- for (var i = msgKeyArray.length - 1; i >= 0; --i) >+ for (let i = msgKeyArray.length - 1; i >= 0; --i) > if (!(msgKeyArray[i] in tagKeys)) > msgKeyArray.splice(i, 1); // remove non-tag key > var msgKeys = msgKeyArray.join(" "); > > if (msgKeys) > currentHeaderData.tags = {headerName: "tags", headerValue: msgKeys}; > else // no more tags, so clear out the header field > delete currentHeaderData.tags; >@@ -663,45 +662,44 @@ function OnTagsChange() > } > } > } > > // flush out any local state being held by a header entry for a given > // table > function ClearHeaderView(headerTable) > { >- for (index in headerTable) >+ for (let index in headerTable) > { >- var headerEntry = headerTable[index]; >+ let headerEntry = headerTable[index]; > if (headerEntry.useToggle) > { > headerEntry.enclosingBox.clearHeaderValues(); > } > > headerEntry.valid = false; > } > } > > // make sure that any valid header entry in the table is collapsed > function hideHeaderView(headerTable) > { >- for (index in headerTable) >+ for (let index in headerTable) > { > headerTable[index].enclosingBox.collapsed = true; > } > } > > // make sure that any valid header entry in the table specified is > // visible > function showHeaderView(headerTable) > { >- var headerEntry; >- for (index in headerTable) >+ for (let index in headerTable) > { >- headerEntry = headerTable[index]; >+ let headerEntry = headerTable[index]; > if (headerEntry.valid) > { > headerEntry.enclosingBox.collapsed = false; > } > else // if the entry is invalid, always make sure it's collapsed > headerEntry.enclosingBox.collapsed = true; > } > } >@@ -795,45 +793,44 @@ function createNewHeaderView(headerName, > > /** > * Removes all non-predefined header nodes from the view. > * > * @param aHeaderTable Table of header entries. > */ > function RemoveNewHeaderViews(aHeaderTable) > { >- for (var index in aHeaderTable) >+ for (let index in aHeaderTable) > { >- var headerEntry = aHeaderTable[index]; >+ let headerEntry = aHeaderTable[index]; > if (headerEntry.isNewHeader) > headerEntry.enclosingBox.parentNode > .removeChild(headerEntry.enclosingBox); > } > } > > // UpdateMessageHeaders: Iterate through all the current header data we received from mime for this message > // for each header entry table, see if we have a corresponding entry for that header. i.e. does the particular > // view care about this header value. if it does then call updateHeaderEntry > function UpdateMessageHeaders() > { > // iterate over each header we received and see if we have a matching entry in each > // header view table... > >- var headerName; >- for (headerName in currentHeaderData) >+ for (let headerName in currentHeaderData) > { >- var headerField = currentHeaderData[headerName]; >- var headerEntry = null; >+ let headerField = currentHeaderData[headerName]; >+ let headerEntry = null; > > if (headerName == "subject") > { > try { > if (gDBView.keyForFirstSelectedMessage == nsMsgKey_None) > { >- var folder = null; >+ let folder = null; > if (gCurrentFolderUri) > folder = GetMsgFolderFromUri(gCurrentFolderUri); > setTitleFromFolder(folder, headerField.headerValue); > } > } catch (ex) {} > } > > if (gCollapsedHeaderViewMode && !gBuiltCollapsedView) >@@ -847,17 +844,17 @@ function UpdateMessageHeaders() > headerEntry = gExpandedHeaderView[headerName]; > > if (!headerEntry && gViewAllHeaders) > { > // for view all headers, if we don't have a header field for this value....cheat and create one....then > // fill in a headerEntry > if (headerName == "message-id" || headerName == "in-reply-to") > { >- var messageIdEntry = {name:headerName, outputFunction:OutputMessageIds}; >+ let messageIdEntry = {name:headerName, outputFunction:OutputMessageIds}; > gExpandedHeaderView[headerName] = new createHeaderEntry('expanded', messageIdEntry); > } > else > { > gExpandedHeaderView[headerName] = new createNewHeaderView(headerName, > currentHeaderData[headerName].headerName + ':'); > } > >@@ -948,17 +945,17 @@ function OutputNewsgroups(headerEntry, h > // take string of message-ids separated by whitespace, split it > // into message-ids and send them together with the index number > // to the corresponding mail-messageids-headerfield element > function OutputMessageIds(headerEntry, headerValue) > { > var messageIdArray = headerValue.split(/\s+/); > > headerEntry.enclosingBox.clearHeaderValues(); >- for (var i = 0; i < messageIdArray.length; i++) >+ for (let i = 0; i < messageIdArray.length; i++) > headerEntry.enclosingBox.addMessageIdView(messageIdArray[i]); > > headerEntry.enclosingBox.fillMessageIdNodes(); > } > > // OutputEmailAddresses --> knows how to take a comma separated list of email addresses, > // extracts them one by one, linkifying each email address into a mailto url. > // Then we add the link-ified email address to the parentDiv passed in. >@@ -1250,30 +1247,30 @@ function onShowAttachmentContextMenu() > > var canDetach = CanDetachAttachments(); > var deletedAmongSelected = false; > var detachedAmongSelected = false; > var anyDeleted = false; // at least one deleted attachment in the list > var anyDetached = false; // at least one detached attachment in the list > > // Check if one or more of the selected attachments are deleted. >- for (var i = 0; i < selectedAttachments.length && !deletedAmongSelected; i++) >+ for (let i = 0; i < selectedAttachments.length && !deletedAmongSelected; i++) > deletedAmongSelected = > (selectedAttachments[i].attachment.contentType == 'text/x-moz-deleted'); > > // Check if one or more of the selected attachments are detached. >- for (var i = 0; i < selectedAttachments.length && !detachedAmongSelected; i++) >+ for (let i = 0; i < selectedAttachments.length && !detachedAmongSelected; i++) > detachedAmongSelected = selectedAttachments[i].attachment.isExternalAttachment; > > // Check if any attachments are deleted. >- for (var i = 0; i < currentAttachments.length && !anyDeleted; i++) >+ for (let i = 0; i < currentAttachments.length && !anyDeleted; i++) > anyDeleted = (currentAttachments[i].contentType == 'text/x-moz-deleted'); > > // Check if any attachments are detached. >- for (var i = 0; i < currentAttachments.length && !anyDetached; i++) >+ for (let i = 0; i < currentAttachments.length && !anyDetached; i++) > anyDetached = currentAttachments[i].isExternalAttachment; > > if (!deletedAmongSelected && selectedAttachments.length == 1) > { > openMenu.removeAttribute('disabled'); > viewMenu.removeAttribute('disabled'); > } > else >@@ -1340,25 +1337,25 @@ function createAttachmentDisplayName(aAt > return aAttachment.displayName.trimRight(); > } > > function displayAttachmentsForExpandedView() > { > var numAttachments = currentAttachments.length; > if (numAttachments > 0 && !gBuildAttachmentsForCurrentMsg) > { >- var attachmentList = document.getElementById('attachmentList'); >+ let attachmentList = document.getElementById('attachmentList'); > >- for (index in currentAttachments) >+ for (let index in currentAttachments) > { >- var attachment = currentAttachments[index]; >+ let attachment = currentAttachments[index]; > > // create a listitem for the attachment listbox >- var displayName = createAttachmentDisplayName(attachment); >- var item = attachmentList.appendItem(displayName, ""); >+ let displayName = createAttachmentDisplayName(attachment); >+ let item = attachmentList.appendItem(displayName, ""); > item.setAttribute("crop", "center"); > item.setAttribute("class", "listitem-iconic attachment-item"); > item.setAttribute("tooltiptext", attachment.displayName); > item.attachment = attachment; > item.setAttribute("attachmentUrl", attachment.url); > item.setAttribute("attachmentContentType", attachment.contentType); > item.setAttribute("attachmentUri", attachment.uri); > if (attachment.contentType == "text/x-moz-deleted") >@@ -1400,17 +1397,17 @@ function FillAttachmentListPopup(popup) > var attachmentIndex = 0; > > // otherwise we need to build the attachment view... > // First clear out the old view... > ClearAttachmentMenu(popup); > > var canDetachOrDeleteAll = CanDetachAttachments(); > >- for (index in currentAttachments) >+ for (let index in currentAttachments) > { > ++attachmentIndex; > addAttachmentToPopup(popup, currentAttachments[index], attachmentIndex); > if (canDetachOrDeleteAll && > (currentAttachments[index].isExternalAttachment || > currentAttachments[index].contentType == 'text/x-moz-deleted')) > canDetachOrDeleteAll = false; > } >@@ -1517,17 +1514,17 @@ function HandleMultipleAttachments(comma > var attachmentContentTypeArray = new Array(); > var attachmentUrlArray = new Array(); > var attachmentDisplayNameArray = new Array(); > var attachmentMessageUriArray = new Array(); > > // populate these arrays.. > for (let index in selectedAttachments) > { >- var attachment = selectedAttachments[index].attachment; >+ let attachment = selectedAttachments[index].attachment; > attachmentContentTypeArray[index] = attachment.contentType; > attachmentUrlArray[index] = attachment.url; > attachmentDisplayNameArray[index] = encodeURI(attachment.displayName); > attachmentMessageUriArray[index] = attachment.uri; > } > > // okay the list has been built... now call our action code... > switch (commandPrefix) >@@ -1677,17 +1674,17 @@ nsFlavorDataProvider.prototype = > aTransferable.getTransferData("application/x-moz-file-promise-dir", dirPrimitive, dataSize); > var destDirectory = dirPrimitive.value.QueryInterface(Components.interfaces.nsILocalFile); > > // now save the attachment to the specified location > // XXX: we need more information than just the attachment url to save it, fortunately, we have an array > // of all the current attachments so we can cheat and scan through them > > var attachment = null; >- for (index in currentAttachments) >+ for (let index in currentAttachments) > { > attachment = currentAttachments[index]; > if (attachment.url == srcUrlPrimitive) > break; > } > > // call our code for saving attachments > if (attachment)
Attachment #480407 - Flags: superreview?(neil)
Comment on attachment 480407 [details] [diff] [review] Patch v1.0 Sprinkle some let's. Yes, you have gone overboard. And try clearing your cache.
Attachment #480407 - Flags: superreview?(neil) → superreview+
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → seamonkey2.1b1
Using SeaMonkey 2.46 Windows every time i reply to an email, i get a script error, and then seamonkey freezes and i have to restart. " A script on this page may be busy, or it may have stopped responding. You can stop the script now, open the script in the debugger, or let the script continue. Script: chrome://messenger/content/msgHdrViewOverlay.js:309 any fix? thx
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: