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