Bug 987387 - Make navigator.sendBeacon() respect private browsing mode; r=jdm

This commit is contained in:
Ehsan Akhgari 2014-03-25 23:22:55 -04:00
parent 5e8506e0a5
commit 404ff699a8

View File

@ -91,6 +91,7 @@
#include "nsIUploadChannel2.h"
#include "nsFormData.h"
#include "nsIPrivateBrowsingChannel.h"
namespace mozilla {
namespace dom {
@ -1138,6 +1139,18 @@ Navigator::SendBeacon(const nsAString& aUrl,
return false;
}
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(channel);
if (pbChannel) {
nsIDocShell* docShell = mWindow->GetDocShell();
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
if (loadContext) {
rv = pbChannel->SetPrivate(loadContext->UsePrivateBrowsing());
if (NS_FAILED(rv)) {
NS_WARNING("Setting the privacy status on the beacon channel failed");
}
}
}
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
if (!httpChannel) {
// Beacon spec only supports HTTP requests at this time