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 */
5 #include "jsapi-tests/tests.h"
7 BEGIN_TEST(testJSEvaluateScript)
8 {
9 JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), global));
10 CHECK(obj);
12 CHECK(JS::ContextOptionsRef(cx).varObjFix());
14 static const char src[] = "var x = 5;";
16 JS::RootedValue retval(cx);
17 CHECK(JS_EvaluateScript(cx, obj, src, sizeof(src) - 1, __FILE__, __LINE__, &retval));
19 bool hasProp = true;
20 CHECK(JS_AlreadyHasOwnProperty(cx, obj, "x", &hasProp));
21 CHECK(!hasProp);
23 hasProp = false;
24 CHECK(JS_HasProperty(cx, global, "x", &hasProp));
25 CHECK(hasProp);
27 // Now do the same thing, but without JSOPTION_VAROBJFIX
28 JS::ContextOptionsRef(cx).setVarObjFix(false);
30 static const char src2[] = "var y = 5;";
32 CHECK(JS_EvaluateScript(cx, obj, src2, sizeof(src2) - 1, __FILE__, __LINE__, &retval));
34 hasProp = false;
35 CHECK(JS_AlreadyHasOwnProperty(cx, obj, "y", &hasProp));
36 CHECK(hasProp);
38 hasProp = true;
39 CHECK(JS_AlreadyHasOwnProperty(cx, global, "y", &hasProp));
40 CHECK(!hasProp);
42 return true;
43 }
44 END_TEST(testJSEvaluateScript)