Closed Bug 1139817 Opened 9 years ago Closed 9 years ago

TypeError: imgs is undefined in TypeError: imgs is undefined

Categories

(Thunderbird :: Mail Window Front End, defect)

x86_64
Windows 8.1
defect
Not set
normal

Tracking

(thunderbird38+ fixed)

RESOLVED FIXED
Thunderbird 39.0
Tracking Status
thunderbird38 + fixed

People

(Reporter: rkent, Assigned: rkent)

References

Details

Attachments

(1 file, 1 obsolete file)

Regularly I get this error in the error console:

Timestamp: 3/5/2015 1:59:59 AM
Error: TypeError: imgs is undefined
Source File: chrome://communicator/content/TypeError: imgs is undefined
Line: 63
Attached patch contentAreaClick.patch (obsolete) — Splinter Review
Also check for missing images.
Assignee: nobody → rkent
Status: NEW → ASSIGNED
Attachment #8573158 - Flags: review?(squibblyflabbetydoo)
Comment on attachment 8573158 [details] [diff] [review]
contentAreaClick.patch

Review of attachment 8573158 [details] [diff] [review]:
-----------------------------------------------------------------

r- but only because the existing code is really ugly, and we should take this opportunity to clean it up a bit.

::: mail/base/content/contentAreaClick.js
@@ +58,5 @@
>    {
>      // Scale any overflowing images, exclude http content.
>      let browser = getBrowser();
>      let doc = browser && browser.contentDocument ? browser.contentDocument : null;
> +    let imgs = doc && !doc.URL.startsWith("http") && doc.images ? doc.images : [];

I'd like this a lot better if it were something like the following. Note that I eliminated the null-check for getBrowser(), because if that returns null, something is seriously wrong, and I think we should log that error. Arguably, the same could be said for contentDocument too.

let doc = getBrowser().contentDocument;
if (!doc || doc.URL.startsWith("http") || !doc.images)
  return;
for (let img of doc.images) {
  // ...
}
Attachment #8573158 - Flags: review?(squibblyflabbetydoo) → review-
If we're going to change it, let's also remove its indent.
Attachment #8573158 - Attachment is obsolete: true
Attachment #8573534 - Flags: review?(squibblyflabbetydoo)
Attachment #8573534 - Flags: review?(squibblyflabbetydoo) → review+
https://hg.mozilla.org/comm-central/rev/33a9d905aa6e
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 39.0
Depends on: 1163299
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: