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 #include "mozilla/Assertions.h"
3 #include <stdio.h>
5 #include "nscore.h"
6 #include "nsXULAppAPI.h"
7 #include "nsExceptionHandler.h"
8 #include "mozilla/unused.h"
10 /*
11 * This pure virtual call example is from MSDN
12 */
13 class A;
15 void fcn( A* );
17 class A
18 {
19 public:
20 virtual void f() = 0;
21 A() { fcn( this ); }
22 };
24 class B : A
25 {
26 void f() { }
27 public:
28 void use() { }
29 };
31 void fcn( A* p )
32 {
33 p->f();
34 }
36 void PureVirtualCall()
37 {
38 // generates a pure virtual function call
39 B b;
40 b.use(); // make sure b's actually used
41 }
43 // Keep these in sync with CrashTestUtils.jsm!
44 const int16_t CRASH_INVALID_POINTER_DEREF = 0;
45 const int16_t CRASH_PURE_VIRTUAL_CALL = 1;
46 const int16_t CRASH_RUNTIMEABORT = 2;
47 const int16_t CRASH_OOM = 3;
48 const int16_t CRASH_MOZ_CRASH = 4;
49 const int16_t CRASH_ABORT = 5;
51 extern "C" NS_EXPORT
52 void Crash(int16_t how)
53 {
54 switch (how) {
55 case CRASH_INVALID_POINTER_DEREF: {
56 volatile int* foo = (int*)0x42;
57 *foo = 0;
58 // not reached
59 break;
60 }
61 case CRASH_PURE_VIRTUAL_CALL: {
62 PureVirtualCall();
63 // not reached
64 break;
65 }
66 case CRASH_RUNTIMEABORT: {
67 NS_RUNTIMEABORT("Intentional crash");
68 break;
69 }
70 case CRASH_OOM: {
71 mozilla::unused << moz_xmalloc((size_t) -1);
72 mozilla::unused << moz_xmalloc((size_t) -1);
73 mozilla::unused << moz_xmalloc((size_t) -1);
74 break;
75 }
76 case CRASH_MOZ_CRASH: {
77 MOZ_CRASH();
78 break;
79 }
80 case CRASH_ABORT: {
81 abort();
82 break;
83 }
84 default:
85 break;
86 }
87 }
89 extern "C" NS_EXPORT
90 nsISupports* LockDir(nsIFile *directory)
91 {
92 nsISupports* lockfile = nullptr;
93 XRE_LockProfileDirectory(directory, &lockfile);
94 return lockfile;
95 }
97 char testData[32];
99 extern "C" NS_EXPORT
100 uint64_t SaveAppMemory()
101 {
102 for (size_t i=0; i<sizeof(testData); i++)
103 testData[i] = i;
105 FILE *fp = fopen("crash-addr", "w");
106 if (!fp)
107 return 0;
108 fprintf(fp, "%p\n", (void *)testData);
109 fclose(fp);
111 return (int64_t)testData;
112 }
114 #ifdef XP_WIN32
115 static LONG WINAPI HandleException(EXCEPTION_POINTERS* exinfo)
116 {
117 TerminateProcess(GetCurrentProcess(), 0);
118 return 0;
119 }
121 extern "C" NS_EXPORT
122 void TryOverrideExceptionHandler()
123 {
124 SetUnhandledExceptionFilter(HandleException);
125 }
126 #endif