Closed Bug 1025330 Opened 10 years ago Closed 10 years ago

expose the failed channel from the docshell so error pages can have access to it

Categories

(Core :: DOM: Navigation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: keeler, Assigned: keeler)

References

Details

Attachments

(1 file, 2 obsolete files)

Unless I'm misunderstanding how the docshell works, when an error page (in particular an SSL error page) has been loaded, the original channel that failed to load is not available. However, it seems the docshell does know what that failed channel is. It would be very useful to have access to it. (This applies to the SSL error reporting project as well as properly enabling certificate overrides so we don't have to use the inherently broken recent bad certs service.)
Attached patch patch (obsolete) — Splinter Review
jst - looks like you're the docshell peer with the fewest review requests at the moment - would you mind having a look?
Attachment #8440172 - Flags: review?(jst)
To see how this is going to be used, see the patch in bug 1025332.
Comment on attachment 8440172 [details] [diff] [review]
patch

This looks correct to me, but requesting review from bz as well to ensure this doesn't leave mFailedChannel set to some old failed channel forever or somesuch. AFAICT Stop() is always called between loads, and that sets mFailedChannel to null if the load type is for an error page, which is the only case where mFailedChannel is set for. But again, I'd like bz to look this over as well.
Attachment #8440172 - Flags: review?(jst)
Attachment #8440172 - Flags: review?(bzbarsky)
Attachment #8440172 - Flags: review+
Comment on attachment 8440172 [details] [diff] [review]
patch

Hmm.  Relying on the Stop(args) behavior is really fragile.  As one simple example, if a javascript: URI is loaded, it won't call Stop(args) in the docshell (relying on the JS protocol handler to do it), but _will_ set mLoadType, so by the time Stop(args) is called the load type is not LOAD_ERROR_PAGE.  I'm pretty sure there are more convoluted cases like that if we look hard enough.

I would be happier if we just put the failed channel on the error page document instead.  In the code in CreateContentViewer(), we should be able to get a document from the new content viewer, right?  That would ensure that the lifetime of that channel won't exceed that of the document in question.
Attachment #8440172 - Flags: review?(bzbarsky) → review-
Attached patch patch v2 (obsolete) — Splinter Review
Thanks for the reviews, jst and bz.
bz - I'm not sure I understood what you were saying to do. Is this on the right track?
Attachment #8440172 - Attachment is obsolete: true
Attachment #8440966 - Flags: review?(bzbarsky)
Comment on attachment 8440966 [details] [diff] [review]
patch v2

>+#include "nsIChannel.h"                  // for member

Please just put that in nsDocument.h (where it's already included) and make this a virtual getter/setter like GetChannel() is.  You'll need to change the nsIDocument IID.

>+    nsCOMPtr<nsIDocument> doc(GetDocument());

No need for the strong ref.

>+    NS_IF_ADDREF(*aFailedChannel = doc->GetFailedChannel());

On the other hand, doc can be null, so you need to check that.

>+        viewer->GetDOMDocument(getter_AddRefs(domDoc));

If you use viewer->GetDocument() here, you can get the nsIDocument* directly.

>+  readonly attribute nsIChannel failedChannel;

Needs documentation.  And an IID change for nsIDocShell.

r=me with those fixed.
Attachment #8440966 - Flags: review?(bzbarsky) → review+
Attached patch patch v2.1Splinter Review
Thanks for the reviews! Carrying over r+.
https://hg.mozilla.org/integration/mozilla-inbound/rev/d906d4e1acbe
Attachment #8440966 - Attachment is obsolete: true
Attachment #8443043 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/d906d4e1acbe
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: