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.
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim:cindent:ts=8:et:sw=4:
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 /*
9 * This test is NOT intended to be run. It's a test to make sure
10 * a group of functions BUILD correctly.
11 */
13 #include "nsISupportsUtils.h"
14 #include "nsIWeakReference.h"
15 #include "nsIComponentManager.h"
16 #include "nsIServiceManager.h"
17 #include "nsWeakReference.h"
18 #include "nsIInterfaceRequestor.h"
19 #include "nsIInterfaceRequestorUtils.h"
20 #include "nsComponentManagerUtils.h"
21 #include "nsServiceManagerUtils.h"
22 #include "nsAutoPtr.h"
23 #include "mozilla/Attributes.h"
25 #define NS_ITESTSERVICE_IID \
26 {0x127b5253, 0x37b1, 0x43c7, \
27 { 0x96, 0x2b, 0xab, 0xf1, 0x2d, 0x22, 0x56, 0xae }}
29 class NS_NO_VTABLE nsITestService : public nsISupports {
30 public:
31 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITESTSERVICE_IID)
32 };
34 NS_DEFINE_STATIC_IID_ACCESSOR(nsITestService, NS_ITESTSERVICE_IID)
36 class nsTestService MOZ_FINAL : public nsITestService,
37 public nsSupportsWeakReference
38 {
39 public:
40 NS_DECL_ISUPPORTS
41 };
43 NS_IMPL_ISUPPORTS(nsTestService, nsITestService, nsISupportsWeakReference)
45 #define NS_TEST_SERVICE_CONTRACTID "@mozilla.org/test/testservice;1"
46 #define NS_TEST_SERVICE_CID \
47 {0xa00c1406, 0x283a, 0x45c9, \
48 {0xae, 0xd2, 0x1a, 0xb6, 0xdd, 0xba, 0xfe, 0x53}}
49 static NS_DEFINE_CID(kTestServiceCID, NS_TEST_SERVICE_CID);
51 int main()
52 {
53 /*
54 * NOTE: This does NOT demonstrate how these functions are
55 * intended to be used. They are intended for filling in out
56 * parameters that need to be |AddRef|ed. I'm just too lazy
57 * to write lots of little getter functions for a test program
58 * when I don't need to.
59 */
61 NS_NOTREACHED("This test is not intended to run, only to compile!");
63 /* Test CallQueryInterface */
65 nsISupports *mySupportsPtr = reinterpret_cast<nsISupports*>(0x1000);
67 nsITestService *myITestService = nullptr;
68 CallQueryInterface(mySupportsPtr, &myITestService);
70 nsTestService *myTestService =
71 reinterpret_cast<nsTestService*>(mySupportsPtr);
72 nsISupportsWeakReference *mySupportsWeakRef;
73 CallQueryInterface(myTestService, &mySupportsWeakRef);
75 nsCOMPtr<nsISupports> mySupportsCOMPtr = mySupportsPtr;
76 CallQueryInterface(mySupportsCOMPtr, &myITestService);
78 nsRefPtr<nsTestService> myTestServiceRefPtr = myTestService;
79 CallQueryInterface(myTestServiceRefPtr, &mySupportsWeakRef);
81 /* Test CallQueryReferent */
83 nsIWeakReference *myWeakRef =
84 static_cast<nsIWeakReference*>(mySupportsPtr);
85 CallQueryReferent(myWeakRef, &myITestService);
87 /* Test CallCreateInstance */
89 CallCreateInstance(kTestServiceCID, mySupportsPtr, &myITestService);
90 CallCreateInstance(kTestServiceCID, &myITestService);
91 CallCreateInstance(NS_TEST_SERVICE_CONTRACTID, mySupportsPtr,
92 &myITestService);
93 CallCreateInstance(NS_TEST_SERVICE_CONTRACTID, &myITestService);
95 /* Test CallGetService */
96 CallGetService(kTestServiceCID, &myITestService);
97 CallGetService(NS_TEST_SERVICE_CONTRACTID, &myITestService);
99 /* Test CallGetInterface */
100 nsIInterfaceRequestor *myInterfaceRequestor =
101 static_cast<nsIInterfaceRequestor*>(mySupportsPtr);
102 CallGetInterface(myInterfaceRequestor, &myITestService);
104 return 0;
105 }