Closed Bug 467021 Opened 16 years ago Closed 16 years ago

about / chrome start pages should be allowed to load in offline mode

Categories

(Thunderbird :: Preferences, defect)

defect
Not set
minor

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 3.0b2

People

(Reporter: maxxmozilla, Assigned: maxxmozilla)

References

Details

Attachments

(2 files, 2 obsolete files)

      No description provided.
Attached patch Fix v1 (obsolete) — Splinter Review
Allows to load uri.scheme about and chrome in online/offline mode.

For completeness data and file schemes could be also allowed ?
While I'm at it I could enhance the IF
> if (uri && [...]
and fix partially Bug 388509, wanted ?
Attachment #350376 - Flags: review?(mkmelin+mozilla)
Comment on attachment 350376 [details] [diff] [review]
Fix v1

>+    // Load about:blank as the start page if we are offline and uri.scheme
>+    // is different from about / chrome or we don't have a start page url...
>+    var scheme = "";
>+    var uri = null;

No need to initialize either of these, and uri should be declared where first used.

>+    try {
>+      uri = makeURI(startpage);
>+      scheme = uri.scheme;
>+    } catch (ex) {}

No need to try catch here, (especially) as you're inside a try-block already.
For future reference, in cases you need to catch, usually dumping out what
the exception was is helpful.

>+    if (scheme == "about" || scheme == "chrome" || MailOfflineMgr.isOnline()
>+                                                && startpage != "")

What about file:// and res://? Blacklist offline http:// and https:// instead?

"" is falsy, so prefer to use !startpage

>+      GetMessagePaneFrame().location.href = startpage;
>+    else
>+      GetMessagePaneFrame().location.href = startpage = "about:blank";

I think I'd much prefer if you do an if MailOfflineMgr.isOnline() and put all 
the additional scheme checking inside that.
>+      GetMessagePaneFrame().location.href = startpage = "about:blank";

An extra = startpage snuck in.
> >+    try {
> >+      uri = makeURI(startpage);
> >+      scheme = uri.scheme;
> >+    } catch (ex) {}
> No need to try catch here, (especially) as you're inside a try-block already.
> For future reference, in cases you need to catch, usually dumping out what
> the exception was is helpful.
without try catch header pane is being hidden when trying to load badly formatted uri (instead of error or about:blank) - makeURI(startpage) failing ?
 
> What about file:// and res://? Blacklist offline http:// and https:// instead?
OK, will blacklist for offline

> "" is falsy, so prefer to use !startpage
startpage != "" is needed to not try to load undefined startpage -> you end up with thunderbird window loaded :)
 
should I check for properly formatted uri and prevent "File Not Found" or leave it for Bug 388509
(In reply to comment #4)
> should I check for properly formatted uri and prevent "File Not Found" or leave
> it for Bug 388509
even if it would be fixed it would rather not apply to existing prefs hmm

BTW I've used this part as my "book example"
http://hg.mozilla.org/mozilla-central/file/a8f64c6df6b8/toolkit/mozapps/extensions/content/about.js#l77
(In reply to comment #4)
> without try catch header pane is being hidden when trying to load badly
> formatted uri (instead of error or about:blank) - makeURI(startpage) failing ?

Ok, keep the try-catch. I suppose that's a bit better behaviour.

> startpage != "" is needed to not try to load undefined startpage -> you end up
> with thunderbird window loaded :)

What i meant was: if (startpage != "") behaves the same way as if (startpage)

> should I check for properly formatted uri and prevent "File Not Found" or leave
> it for Bug 388509

Your choice;)
> > should I check for properly formatted uri and prevent "File Not Found" or leave
> > it for Bug 388509
> Your choice;)
thanks ;)
I'll leave it as it is and I will look into mentioned bug later on
Attached patch Fix v2 (obsolete) — Splinter Review
v2
I didn't want to introduce too many IFs but if this one is too long I can split it into 1 or 2 inside
Attachment #350376 - Attachment is obsolete: true
Attachment #350671 - Flags: review?(mkmelin+mozilla)
Attachment #350376 - Flags: review?(mkmelin+mozilla)
Comment on attachment 350671 [details] [diff] [review]
Fix v2

Nit: |var scheme| isn't properly indented.

With that, r=mkmelin. Thanks for the patch!
Attachment #350671 - Flags: review?(mkmelin+mozilla) → review+
Attached patch Fix v3Splinter Review
nit fixed, carrying forward r+
Attachment #350671 - Attachment is obsolete: true
Attachment #350791 - Flags: review+
Keywords: checkin-needed
Checked in: http://hg.mozilla.org/comm-central/rev/5643c712393a
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 3.0b2
Attached patch comment fixSplinter Review
description fix
Attachment #351048 - Flags: review?(mkmelin+mozilla)
I've just noticed "small" bug in description, sorry!
Can you Magnus or Mark please checkin it quickly ?
Attachment #351048 - Flags: review?(mkmelin+mozilla) → review+
Blocks: 467790
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: