Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | * This is a mock Link object which can be used in tests. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | #ifndef mock_Link_h__ |
michael@0 | 12 | #define mock_Link_h__ |
michael@0 | 13 | |
michael@0 | 14 | #include "mozilla/MemoryReporting.h" |
michael@0 | 15 | #include "mozilla/dom/Link.h" |
michael@0 | 16 | #include "mozilla/dom/URLSearchParams.h" |
michael@0 | 17 | |
michael@0 | 18 | class mock_Link : public mozilla::dom::Link |
michael@0 | 19 | { |
michael@0 | 20 | public: |
michael@0 | 21 | NS_DECL_ISUPPORTS |
michael@0 | 22 | |
michael@0 | 23 | mock_Link(void (*aHandlerFunction)(nsLinkState), |
michael@0 | 24 | bool aRunNextTest = true) |
michael@0 | 25 | : mozilla::dom::Link(nullptr) |
michael@0 | 26 | , mHandler(aHandlerFunction) |
michael@0 | 27 | , mRunNextTest(aRunNextTest) |
michael@0 | 28 | { |
michael@0 | 29 | // Create a cyclic ownership, so that the link will be released only |
michael@0 | 30 | // after its status has been updated. This will ensure that, when it should |
michael@0 | 31 | // run the next test, it will happen at the end of the test function, if |
michael@0 | 32 | // the link status has already been set before. Indeed the link status is |
michael@0 | 33 | // updated on a separate connection, thus may happen at any time. |
michael@0 | 34 | mDeathGrip = this; |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | virtual void SetLinkState(nsLinkState aState) |
michael@0 | 38 | { |
michael@0 | 39 | // Notify our callback function. |
michael@0 | 40 | mHandler(aState); |
michael@0 | 41 | |
michael@0 | 42 | // Break the cycle so the object can be destroyed. |
michael@0 | 43 | mDeathGrip = 0; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const |
michael@0 | 47 | { |
michael@0 | 48 | return 0; // the value shouldn't matter |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | ~mock_Link() { |
michael@0 | 52 | // Run the next test if we are supposed to. |
michael@0 | 53 | if (mRunNextTest) { |
michael@0 | 54 | run_next_test(); |
michael@0 | 55 | } |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | private: |
michael@0 | 59 | void (*mHandler)(nsLinkState); |
michael@0 | 60 | bool mRunNextTest; |
michael@0 | 61 | nsRefPtr<Link> mDeathGrip; |
michael@0 | 62 | }; |
michael@0 | 63 | |
michael@0 | 64 | NS_IMPL_ISUPPORTS( |
michael@0 | 65 | mock_Link, |
michael@0 | 66 | mozilla::dom::Link |
michael@0 | 67 | ) |
michael@0 | 68 | |
michael@0 | 69 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 70 | //// Needed Link Methods |
michael@0 | 71 | |
michael@0 | 72 | namespace mozilla { |
michael@0 | 73 | namespace dom { |
michael@0 | 74 | |
michael@0 | 75 | Link::Link(Element* aElement) |
michael@0 | 76 | : mElement(aElement) |
michael@0 | 77 | , mLinkState(eLinkState_NotLink) |
michael@0 | 78 | , mRegistered(false) |
michael@0 | 79 | { |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | Link::~Link() |
michael@0 | 83 | { |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | bool |
michael@0 | 87 | Link::ElementHasHref() const |
michael@0 | 88 | { |
michael@0 | 89 | NS_NOTREACHED("Unexpected call to Link::ElementHasHref"); |
michael@0 | 90 | return false; // suppress compiler warning |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | void |
michael@0 | 94 | Link::SetLinkState(nsLinkState aState) |
michael@0 | 95 | { |
michael@0 | 96 | NS_NOTREACHED("Unexpected call to Link::SetLinkState"); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | void |
michael@0 | 100 | Link::ResetLinkState(bool aNotify, bool aHasHref) |
michael@0 | 101 | { |
michael@0 | 102 | NS_NOTREACHED("Unexpected call to Link::ResetLinkState"); |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | nsIURI* |
michael@0 | 106 | Link::GetURI() const |
michael@0 | 107 | { |
michael@0 | 108 | NS_NOTREACHED("Unexpected call to Link::GetURI"); |
michael@0 | 109 | return nullptr; // suppress compiler warning |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | size_t |
michael@0 | 113 | Link::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const |
michael@0 | 114 | { |
michael@0 | 115 | NS_NOTREACHED("Unexpected call to Link::SizeOfExcludingThis"); |
michael@0 | 116 | return 0; |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | void |
michael@0 | 120 | Link::URLSearchParamsUpdated() |
michael@0 | 121 | { |
michael@0 | 122 | NS_NOTREACHED("Unexpected call to Link::URLSearchParamsUpdated"); |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | void |
michael@0 | 126 | Link::UpdateURLSearchParams() |
michael@0 | 127 | { |
michael@0 | 128 | NS_NOTREACHED("Unexpected call to Link::UpdateURLSearchParams"); |
michael@0 | 129 | } |
michael@0 | 130 | |
michael@0 | 131 | NS_IMPL_CYCLE_COLLECTION_CLASS(URLSearchParams) |
michael@0 | 132 | NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(URLSearchParams) |
michael@0 | 133 | NS_IMPL_CYCLE_COLLECTION_UNLINK_END |
michael@0 | 134 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(URLSearchParams) |
michael@0 | 135 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END |
michael@0 | 136 | NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(URLSearchParams) |
michael@0 | 137 | |
michael@0 | 138 | NS_IMPL_CYCLE_COLLECTING_ADDREF(URLSearchParams) |
michael@0 | 139 | NS_IMPL_CYCLE_COLLECTING_RELEASE(URLSearchParams) |
michael@0 | 140 | |
michael@0 | 141 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(URLSearchParams) |
michael@0 | 142 | NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
michael@0 | 143 | NS_INTERFACE_MAP_ENTRY(nsISupports) |
michael@0 | 144 | NS_INTERFACE_MAP_END |
michael@0 | 145 | |
michael@0 | 146 | |
michael@0 | 147 | URLSearchParams::URLSearchParams() |
michael@0 | 148 | { |
michael@0 | 149 | } |
michael@0 | 150 | |
michael@0 | 151 | URLSearchParams::~URLSearchParams() |
michael@0 | 152 | { |
michael@0 | 153 | } |
michael@0 | 154 | |
michael@0 | 155 | JSObject* |
michael@0 | 156 | URLSearchParams::WrapObject(JSContext* aCx) |
michael@0 | 157 | { |
michael@0 | 158 | return nullptr; |
michael@0 | 159 | } |
michael@0 | 160 | |
michael@0 | 161 | void |
michael@0 | 162 | URLSearchParams::ParseInput(const nsACString& aInput, |
michael@0 | 163 | URLSearchParamsObserver* aObserver) |
michael@0 | 164 | { |
michael@0 | 165 | NS_NOTREACHED("Unexpected call to URLSearchParams::ParseInput"); |
michael@0 | 166 | } |
michael@0 | 167 | |
michael@0 | 168 | void |
michael@0 | 169 | URLSearchParams::AddObserver(URLSearchParamsObserver* aObserver) |
michael@0 | 170 | { |
michael@0 | 171 | NS_NOTREACHED("Unexpected call to URLSearchParams::SetObserver"); |
michael@0 | 172 | } |
michael@0 | 173 | |
michael@0 | 174 | void |
michael@0 | 175 | URLSearchParams::RemoveObserver(URLSearchParamsObserver* aObserver) |
michael@0 | 176 | { |
michael@0 | 177 | NS_NOTREACHED("Unexpected call to URLSearchParams::SetObserver"); |
michael@0 | 178 | } |
michael@0 | 179 | |
michael@0 | 180 | void |
michael@0 | 181 | URLSearchParams::Serialize(nsAString& aValue) const |
michael@0 | 182 | { |
michael@0 | 183 | NS_NOTREACHED("Unexpected call to URLSearchParams::Serialize"); |
michael@0 | 184 | } |
michael@0 | 185 | |
michael@0 | 186 | void |
michael@0 | 187 | URLSearchParams::Get(const nsAString& aName, nsString& aRetval) |
michael@0 | 188 | { |
michael@0 | 189 | NS_NOTREACHED("Unexpected call to URLSearchParams::Get"); |
michael@0 | 190 | } |
michael@0 | 191 | |
michael@0 | 192 | void |
michael@0 | 193 | URLSearchParams::GetAll(const nsAString& aName, nsTArray<nsString >& aRetval) |
michael@0 | 194 | { |
michael@0 | 195 | NS_NOTREACHED("Unexpected call to URLSearchParams::GetAll"); |
michael@0 | 196 | } |
michael@0 | 197 | |
michael@0 | 198 | void |
michael@0 | 199 | URLSearchParams::Set(const nsAString& aName, const nsAString& aValue) |
michael@0 | 200 | { |
michael@0 | 201 | NS_NOTREACHED("Unexpected call to URLSearchParams::Set"); |
michael@0 | 202 | } |
michael@0 | 203 | |
michael@0 | 204 | void |
michael@0 | 205 | URLSearchParams::Append(const nsAString& aName, const nsAString& aValue) |
michael@0 | 206 | { |
michael@0 | 207 | NS_NOTREACHED("Unexpected call to URLSearchParams::Append"); |
michael@0 | 208 | } |
michael@0 | 209 | |
michael@0 | 210 | void |
michael@0 | 211 | URLSearchParams::AppendInternal(const nsAString& aName, const nsAString& aValue) |
michael@0 | 212 | { |
michael@0 | 213 | NS_NOTREACHED("Unexpected call to URLSearchParams::AppendInternal"); |
michael@0 | 214 | } |
michael@0 | 215 | |
michael@0 | 216 | bool |
michael@0 | 217 | URLSearchParams::Has(const nsAString& aName) |
michael@0 | 218 | { |
michael@0 | 219 | NS_NOTREACHED("Unexpected call to URLSearchParams::Has"); |
michael@0 | 220 | return false; |
michael@0 | 221 | } |
michael@0 | 222 | |
michael@0 | 223 | void |
michael@0 | 224 | URLSearchParams::Delete(const nsAString& aName) |
michael@0 | 225 | { |
michael@0 | 226 | NS_NOTREACHED("Unexpected call to URLSearchParams::Delete"); |
michael@0 | 227 | } |
michael@0 | 228 | |
michael@0 | 229 | void |
michael@0 | 230 | URLSearchParams::DeleteAll() |
michael@0 | 231 | { |
michael@0 | 232 | NS_NOTREACHED("Unexpected call to URLSearchParams::DeleteAll"); |
michael@0 | 233 | } |
michael@0 | 234 | |
michael@0 | 235 | void |
michael@0 | 236 | URLSearchParams::NotifyObservers(URLSearchParamsObserver* aExceptObserver) |
michael@0 | 237 | { |
michael@0 | 238 | NS_NOTREACHED("Unexpected call to URLSearchParams::NotifyObservers"); |
michael@0 | 239 | } |
michael@0 | 240 | |
michael@0 | 241 | } // namespace dom |
michael@0 | 242 | } // namespace mozilla |
michael@0 | 243 | |
michael@0 | 244 | #endif // mock_Link_h__ |