Bug 1635094 - Cleanup the ReferrerInfo code. r=ckerschb
The cast in InitWithNode is wrong. AsElement() asserts instead of checking the flag, so we always pass an element (and if we didn't we'd have type confusion problems). I audited the callers and we're fine. Anyhow, always require an element, and add two convenience constructors for C++ code. Differential Revision: https://phabricator.services.mozilla.com/D73636
This commit is contained in:
@@ -967,10 +967,9 @@ void EventSourceImpl::SetupHttpChannel() {
|
||||
nsresult EventSourceImpl::SetupReferrerInfo() {
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(!IsShutDown());
|
||||
nsCOMPtr<Document> doc = mEventSource->GetDocumentIfCurrent();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo = new ReferrerInfo();
|
||||
referrerInfo->InitWithDocument(doc);
|
||||
|
||||
if (nsCOMPtr<Document> doc = mEventSource->GetDocumentIfCurrent()) {
|
||||
auto referrerInfo = MakeRefPtr<ReferrerInfo>(*doc);
|
||||
nsresult rv = mHttpChannel->SetReferrerInfoWithoutClone(referrerInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user