Bug 964239 - Check for special baseURI value for view-source:about:srcdoc. r=hsivonen

This commit is contained in:
James Kitchener
2014-02-06 09:46:30 -05:00
parent a9cf2b495a
commit c4e2e8e7a3

View File

@@ -931,6 +931,25 @@ nsIURI*
nsHtml5TreeOpExecutor::GetViewSourceBaseURI()
{
if (!mViewSourceBaseURI) {
// We query the channel for the baseURI of srcdoc view-source loads as it
// cannot be otherwise determined. If any step in this process fails, fall
// back to the standard method.
nsCOMPtr<nsIViewSourceChannel> vsc;
vsc = do_QueryInterface(mDocument->GetChannel());
if (vsc) {
bool isSrcdocChannel;
// Note that the channel is a srcdoc channel, but mDocument is not a
// srcdoc document.
nsresult rv = vsc->GetIsSrcdocChannel(&isSrcdocChannel);
if (NS_SUCCEEDED(rv) && isSrcdocChannel) {
rv = vsc->GetBaseURI(getter_AddRefs(mViewSourceBaseURI));
if (NS_SUCCEEDED(rv) && mViewSourceBaseURI) {
return mViewSourceBaseURI;
}
}
}
nsCOMPtr<nsIURI> orig = mDocument->GetOriginalURI();
bool isViewSource;
orig->SchemeIs("view-source", &isViewSource);