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