Skip to content

Commit 203d0c0

Browse files
fixup! Bug #5742: API allows you to get the url bar URI for a channel or nsIDocument.
1 parent 08a3456 commit 203d0c0

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

dom/base/ThirdPartyUtil.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,17 @@ ThirdPartyUtil::GetFirstPartyURIInternal(nsIChannel *aChannel,
648648

649649
if (aDoc->GetWindow()) {
650650
aDoc->GetWindow()->GetTop(getter_AddRefs(top));
651-
top->GetDocument(getter_AddRefs(topDDoc));
652-
653-
nsCOMPtr<nsIDocument> topDoc(do_QueryInterface(topDDoc));
654-
docURI = topDoc->GetOriginalURI();
655-
if (docURI) {
656-
// Give us a mutable URI and also addref
657-
rv = NS_EnsureSafeToReturn(docURI, aOutput);
651+
if (top) {
652+
top->GetDocument(getter_AddRefs(topDDoc));
653+
654+
nsCOMPtr<nsIDocument> topDoc(do_QueryInterface(topDDoc));
655+
if (topDoc) {
656+
docURI = topDoc->GetOriginalURI();
657+
if (docURI) {
658+
// Give us a mutable URI and also addref
659+
rv = NS_EnsureSafeToReturn(docURI, aOutput);
660+
}
661+
}
658662
}
659663
} else {
660664
// XXX: Chrome callers (such as NoScript) can end up here

0 commit comments

Comments
 (0)