mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 19:25:43 +00:00
Bug 987387 - Make navigator.sendBeacon() respect private browsing mode; r=jdm
This commit is contained in:
parent
5e8506e0a5
commit
404ff699a8
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user