Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Backed out 16 changesets (bug 1525245) for perma failing test_documen…
Browse files Browse the repository at this point in the history
…t_cookie.html CLOSED TREE

Backed out changeset 3fd27215698f (bug 1525245)
Backed out changeset d9a9e8e77873 (bug 1525245)
Backed out changeset 0e6f7be92e3f (bug 1525245)
Backed out changeset 6790802e2fa5 (bug 1525245)
Backed out changeset a5a9e01116ed (bug 1525245)
Backed out changeset 66e19a0c38dd (bug 1525245)
Backed out changeset fb90d51ba853 (bug 1525245)
Backed out changeset 4772db3625b3 (bug 1525245)
Backed out changeset 9affaf0cb998 (bug 1525245)
Backed out changeset a91b7ebe8bdd (bug 1525245)
Backed out changeset c2a13a7480e1 (bug 1525245)
Backed out changeset abe4482fa137 (bug 1525245)
Backed out changeset b3920c0bcf84 (bug 1525245)
Backed out changeset 0821b81f2724 (bug 1525245)
Backed out changeset 70bed2ad7899 (bug 1525245)
Backed out changeset 5f72ba232cc8 (bug 1525245)
  • Loading branch information
SV-ACiure committed Mar 7, 2019
1 parent 0b23f3b commit 04778ba
Show file tree
Hide file tree
Showing 150 changed files with 1,259 additions and 2,927 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ XPCOMUtils.defineLazyServiceGetter(Services, "cookiemgr",
function restore_prefs() {
Services.prefs.clearUserPref("network.cookie.cookieBehavior");
Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
Services.prefs.clearUserPref("network.cookieSettings.unblocked_for_testing");
}

registerCleanupFunction(restore_prefs);

async function fake_profile_change() {
Expand Down Expand Up @@ -134,7 +132,6 @@ add_task(async function prepare_tracker_tables() {
});

add_task(async function test_initial_state() {
Services.prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
await test_cookie_settings({
cookiesEnabled: true,
thirdPartyCookiesEnabled: true,
Expand All @@ -147,7 +144,6 @@ add_task(async function test_initial_state() {
add_task(async function test_undefined_unlocked() {
Services.prefs.setIntPref("network.cookie.cookieBehavior", 3);
Services.prefs.setIntPref("network.cookie.lifetimePolicy", 2);
Services.prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
await setupPolicyEngineWithJson({
"policies": {
"Cookies": {
Expand All @@ -162,7 +158,6 @@ add_task(async function test_undefined_unlocked() {
});

add_task(async function test_disabled() {
Services.prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
await setupPolicyEngineWithJson({
"policies": {
"Cookies": {
Expand All @@ -181,7 +176,6 @@ add_task(async function test_disabled() {
});

add_task(async function test_third_party_disabled() {
Services.prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
await setupPolicyEngineWithJson({
"policies": {
"Cookies": {
Expand All @@ -200,7 +194,6 @@ add_task(async function test_third_party_disabled() {
});

add_task(async function test_disabled_and_third_party_disabled() {
Services.prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
await setupPolicyEngineWithJson({
"policies": {
"Cookies": {
Expand All @@ -220,7 +213,6 @@ add_task(async function test_disabled_and_third_party_disabled() {
});

add_task(async function test_disabled_and_third_party_disabled_locked() {
Services.prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
await setupPolicyEngineWithJson({
"policies": {
"Cookies": {
Expand All @@ -241,7 +233,6 @@ add_task(async function test_disabled_and_third_party_disabled_locked() {
});

add_task(async function test_undefined_locked() {
Services.prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
await setupPolicyEngineWithJson({
"policies": {
"Cookies": {
Expand All @@ -260,7 +251,6 @@ add_task(async function test_undefined_locked() {
});

add_task(async function test_cookie_expire() {
Services.prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
await setupPolicyEngineWithJson({
"policies": {
"Cookies": {
Expand All @@ -279,7 +269,6 @@ add_task(async function test_cookie_expire() {
});

add_task(async function test_cookie_reject_trackers() {
Services.prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
await setupPolicyEngineWithJson({
"policies": {
"Cookies": {
Expand All @@ -299,7 +288,6 @@ add_task(async function test_cookie_reject_trackers() {
});

add_task(async function test_cookie_expire_locked() {
Services.prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
await setupPolicyEngineWithJson({
"policies": {
"Cookies": {
Expand All @@ -319,7 +307,6 @@ add_task(async function test_cookie_expire_locked() {
});

add_task(async function test_disabled_cookie_expire_locked() {
Services.prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
await setupPolicyEngineWithJson({
"policies": {
"Cookies": {
Expand Down
32 changes: 4 additions & 28 deletions dom/base/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
#include "mozilla/dom/ShadowIncludingTreeIterator.h"
#include "mozilla/dom/StyleSheetList.h"
#include "mozilla/dom/SVGUseElement.h"
#include "mozilla/net/CookieSettings.h"
#include "nsGenericHTMLElement.h"
#include "mozilla/dom/CDATASection.h"
#include "mozilla/dom/ProcessingInstruction.h"
Expand Down Expand Up @@ -129,7 +128,6 @@
#include "nsIDOMWindow.h"
#include "nsPIDOMWindow.h"
#include "nsFocusManager.h"
#include "nsICookiePermission.h"
#include "nsICookieService.h"

#include "nsBidiUtils.h"
Expand Down Expand Up @@ -2561,18 +2559,6 @@ nsresult Document::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
aChannel->Cancel(NS_ERROR_CSP_FRAME_ANCESTOR_VIOLATION);
}

// Let's take the CookieSettings from the loadInfo or from the parent
// document.
if (loadInfo) {
rv = loadInfo->GetCookieSettings(getter_AddRefs(mCookieSettings));
NS_ENSURE_SUCCESS(rv, rv);
} else {
nsCOMPtr<Document> parentDocument = GetParentDocument();
if (parentDocument) {
mCookieSettings = parentDocument->CookieSettings();
}
}

return NS_OK;
}

Expand Down Expand Up @@ -11805,7 +11791,7 @@ DocumentAutoplayPolicy Document::AutoplayPolicy() const {
}

void Document::MaybeAllowStorageForOpenerAfterUserInteraction() {
if (mCookieSettings->GetCookieBehavior() !=
if (StaticPrefs::network_cookie_cookieBehavior() !=
nsICookieService::BEHAVIOR_REJECT_TRACKER) {
return;
}
Expand Down Expand Up @@ -12321,8 +12307,8 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
}

// Only enforce third-party checks when there is a reason to enforce them.
if (mCookieSettings->GetCookieBehavior() !=
nsICookieService::BEHAVIOR_REJECT_TRACKER) {
if (StaticPrefs::network_cookie_cookieBehavior() !=
nsICookieService::BEHAVIOR_ACCEPT) {
// Step 3. If the document's frame is the main frame, resolve.
if (IsTopLevelContentDocument()) {
promise->MaybeResolveWithUndefined();
Expand Down Expand Up @@ -12374,7 +12360,7 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
return promise.forget();
}

if (mCookieSettings->GetCookieBehavior() ==
if (StaticPrefs::network_cookie_cookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT_TRACKER &&
inner) {
// Only do something special for third-party tracking content.
Expand Down Expand Up @@ -12632,15 +12618,5 @@ void Document::RecomputeLanguageFromCharset() {
mLanguageFromCharset = language.forget();
}

nsICookieSettings* Document::CookieSettings() {
// If we are here, this is probably a javascript: URL document. In any case,
// we must have a nsCookieSettings. Let's create it.
if (!mCookieSettings) {
mCookieSettings = net::CookieSettings::Create();
}

return mCookieSettings;
}

} // namespace dom
} // namespace mozilla
8 changes: 1 addition & 7 deletions dom/base/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#include "nsCOMArray.h" // for member
#include "nsCompatibility.h" // for member
#include "nsCOMPtr.h" // for member
#include "nsICookieSettings.h"
#include "nsGkAtoms.h" // for static class members
#include "nsGkAtoms.h" // for static class members
#include "nsIApplicationCache.h"
#include "nsIApplicationCacheContainer.h"
#include "nsIContentViewer.h"
Expand Down Expand Up @@ -1489,9 +1488,6 @@ class Document : public nsINode,
// flag.
bool StorageAccessSandboxed() const;

// Returns the cookie settings for this and sub contexts.
nsICookieSettings* CookieSettings();

// Increments the document generation.
inline void Changed() { ++mGeneration; }

Expand Down Expand Up @@ -4694,8 +4690,6 @@ class Document : public nsINode,

bool mPendingInitialTranslation;

nsCOMPtr<nsICookieSettings> mCookieSettings;

// Document generation. Gets incremented everytime it changes.
int32_t mGeneration;

Expand Down
36 changes: 5 additions & 31 deletions dom/base/EventSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ class EventSourceImpl final : public nsIObserver,
NS_DECL_NSIEVENTTARGET_FULL
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER

EventSourceImpl(EventSource* aEventSource,
nsICookieSettings* aCookieSettings);
explicit EventSourceImpl(EventSource* aEventSource);

enum { CONNECTING = 0U, OPEN = 1U, CLOSED = 2U };

Expand Down Expand Up @@ -292,8 +291,6 @@ class EventSourceImpl final : public nsIObserver,
uint64_t mInnerWindowID;

private:
nsCOMPtr<nsICookieSettings> mCookieSettings;

// Pointer to the target thread for checking whether we are
// on the target thread. This is intentionally a non-owning
// pointer in order not to affect the thread destruction
Expand All @@ -319,8 +316,7 @@ NS_IMPL_ISUPPORTS(EventSourceImpl, nsIObserver, nsIStreamListener,
nsIInterfaceRequestor, nsISupportsWeakReference,
nsIEventTarget, nsIThreadRetargetableStreamListener)

EventSourceImpl::EventSourceImpl(EventSource* aEventSource,
nsICookieSettings* aCookieSettings)
EventSourceImpl::EventSourceImpl(EventSource* aEventSource)
: mEventSource(aEventSource),
mReconnectionTime(0),
mStatus(PARSE_STATE_OFF),
Expand All @@ -332,7 +328,6 @@ EventSourceImpl::EventSourceImpl(EventSource* aEventSource,
mScriptLine(0),
mScriptColumn(0),
mInnerWindowID(0),
mCookieSettings(aCookieSettings),
mTargetThread(NS_GetCurrentThread()) {
MOZ_ASSERT(mEventSource);
if (!mIsMainThread) {
Expand Down Expand Up @@ -976,8 +971,6 @@ nsresult EventSourceImpl::InitChannelAndRequestEventSource() {
nsCOMPtr<nsIChannel> channel;
// If we have the document, use it
if (doc) {
MOZ_ASSERT(mCookieSettings == doc->CookieSettings());

nsCOMPtr<nsILoadGroup> loadGroup = doc->GetDocumentLoadGroup();
rv = NS_NewChannel(getter_AddRefs(channel), mSrc, doc, securityFlags,
nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE,
Expand All @@ -989,7 +982,6 @@ nsresult EventSourceImpl::InitChannelAndRequestEventSource() {
// otherwise use the principal
rv = NS_NewChannel(getter_AddRefs(channel), mSrc, mPrincipal, securityFlags,
nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE,
mCookieSettings,
nullptr, // aPerformanceStorage
nullptr, // loadGroup
nullptr, // aCallbacks
Expand Down Expand Up @@ -1785,14 +1777,12 @@ EventSourceImpl::CheckListenerChain() {
////////////////////////////////////////////////////////////////////////////////

EventSource::EventSource(nsPIDOMWindowInner* aOwnerWindow,
nsICookieSettings* aCookieSettings,
bool aWithCredentials)
: DOMEventTargetHelper(aOwnerWindow),
mWithCredentials(aWithCredentials),
mIsMainThread(true),
mKeepingAlive(false) {
MOZ_ASSERT(aCookieSettings);
mImpl = new EventSourceImpl(this, aCookieSettings);
mImpl = new EventSourceImpl(this);
}

EventSource::~EventSource() {}
Expand All @@ -1816,24 +1806,8 @@ already_AddRefed<EventSource> EventSource::Constructor(

MOZ_ASSERT(!NS_IsMainThread() || ownerWindow);

nsCOMPtr<nsICookieSettings> cookieSettings;
if (ownerWindow) {
Document* doc = ownerWindow->GetExtantDoc();
if (NS_WARN_IF(!doc)) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}

cookieSettings = doc->CookieSettings();
} else {
// Worker side.
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
cookieSettings = workerPrivate->CookieSettings();
}

RefPtr<EventSource> eventSource = new EventSource(
ownerWindow, cookieSettings, aEventSourceInitDict.mWithCredentials);
RefPtr<EventSource> eventSource =
new EventSource(ownerWindow, aEventSourceInitDict.mWithCredentials);
RefPtr<EventSourceImpl> eventSourceImp = eventSource->mImpl;

if (NS_IsMainThread()) {
Expand Down
4 changes: 1 addition & 3 deletions dom/base/EventSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "nsDeque.h"

class nsPIDOMWindowInner;
class nsICookieSettings;

namespace mozilla {

Expand Down Expand Up @@ -81,8 +80,7 @@ class EventSource final : public DOMEventTargetHelper {
void Close();

private:
EventSource(nsPIDOMWindowInner* aOwnerWindow,
nsICookieSettings* aCookieSettings, bool aWithCredentials);
EventSource(nsPIDOMWindowInner* aOwnerWindow, bool aWithCredentials);
virtual ~EventSource();
// prevent bad usage
EventSource(const EventSource& x) = delete;
Expand Down
Loading

0 comments on commit 04778ba

Please sign in to comment.