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: set ts=8 sts=4 et sw=4 tw=99:
3 *
4 * Any copyright is dedicated to the Public Domain.
5 * http://creativecommons.org/licenses/publicdomain/
6 * Contributor: Igor Bukanov
7 */
9 #include "jsapi-tests/tests.h"
11 static unsigned errorCount = 0;
13 static void
14 ErrorCounter(JSContext *cx, const char *message, JSErrorReport *report)
15 {
16 ++errorCount;
17 }
19 BEGIN_TEST(testGCOutOfMemory)
20 {
21 JS_SetErrorReporter(cx, ErrorCounter);
23 JS::RootedValue root(cx);
25 static const char source[] =
26 "var max = 0; (function() {"
27 " var array = [];"
28 " for (; ; ++max)"
29 " array.push({});"
30 " array = []; array.push(0);"
31 "})();";
32 bool ok = JS_EvaluateScript(cx, global, source, strlen(source), "", 1, &root);
34 /* Check that we get OOM. */
35 CHECK(!ok);
36 CHECK(!JS_IsExceptionPending(cx));
37 CHECK_EQUAL(errorCount, 1);
38 JS_GC(rt);
40 // Temporarily disabled to reopen the tree. Bug 847579.
41 return true;
43 EVAL("(function() {"
44 " var array = [];"
45 " for (var i = max >> 2; i != 0;) {"
46 " --i;"
47 " array.push({});"
48 " }"
49 "})();", &root);
50 CHECK_EQUAL(errorCount, 1);
51 return true;
52 }
54 virtual JSRuntime * createRuntime() {
55 JSRuntime *rt = JS_NewRuntime(768 * 1024, JS_USE_HELPER_THREADS);
56 if (!rt)
57 return nullptr;
58 setNativeStackQuota(rt);
59 return rt;
60 }
62 virtual void destroyRuntime() {
63 JS_DestroyRuntime(rt);
64 }
66 END_TEST(testGCOutOfMemory)