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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "js/StructuredClone.h" |
michael@0 | 6 | |
michael@0 | 7 | #include "jsapi-tests/tests.h" |
michael@0 | 8 | |
michael@0 | 9 | BEGIN_TEST(testStructuredClone_object) |
michael@0 | 10 | { |
michael@0 | 11 | JS::RootedObject g1(cx, createGlobal()); |
michael@0 | 12 | JS::RootedObject g2(cx, createGlobal()); |
michael@0 | 13 | CHECK(g1); |
michael@0 | 14 | CHECK(g2); |
michael@0 | 15 | |
michael@0 | 16 | JS::RootedValue v1(cx); |
michael@0 | 17 | |
michael@0 | 18 | { |
michael@0 | 19 | JSAutoCompartment ac(cx, g1); |
michael@0 | 20 | JS::RootedValue prop(cx, JS::Int32Value(1337)); |
michael@0 | 21 | |
michael@0 | 22 | JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); |
michael@0 | 23 | v1 = JS::ObjectOrNullValue(obj); |
michael@0 | 24 | CHECK(v1.isObject()); |
michael@0 | 25 | CHECK(JS_SetProperty(cx, obj, "prop", prop)); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | { |
michael@0 | 29 | JSAutoCompartment ac(cx, g2); |
michael@0 | 30 | JS::RootedValue v2(cx); |
michael@0 | 31 | |
michael@0 | 32 | CHECK(JS_StructuredClone(cx, v1, &v2, nullptr, nullptr)); |
michael@0 | 33 | CHECK(v2.isObject()); |
michael@0 | 34 | JS::RootedObject obj(cx, &v2.toObject()); |
michael@0 | 35 | |
michael@0 | 36 | JS::RootedValue prop(cx); |
michael@0 | 37 | CHECK(JS_GetProperty(cx, obj, "prop", &prop)); |
michael@0 | 38 | CHECK(prop.isInt32()); |
michael@0 | 39 | CHECK(&v1.toObject() != obj); |
michael@0 | 40 | CHECK_EQUAL(prop.toInt32(), 1337); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | return true; |
michael@0 | 44 | } |
michael@0 | 45 | END_TEST(testStructuredClone_object) |
michael@0 | 46 | |
michael@0 | 47 | BEGIN_TEST(testStructuredClone_string) |
michael@0 | 48 | { |
michael@0 | 49 | JS::RootedObject g1(cx, createGlobal()); |
michael@0 | 50 | JS::RootedObject g2(cx, createGlobal()); |
michael@0 | 51 | CHECK(g1); |
michael@0 | 52 | CHECK(g2); |
michael@0 | 53 | |
michael@0 | 54 | JS::RootedValue v1(cx); |
michael@0 | 55 | |
michael@0 | 56 | { |
michael@0 | 57 | JSAutoCompartment ac(cx, g1); |
michael@0 | 58 | JS::RootedValue prop(cx, JS::Int32Value(1337)); |
michael@0 | 59 | |
michael@0 | 60 | v1 = JS::StringValue(JS_NewStringCopyZ(cx, "Hello World!")); |
michael@0 | 61 | CHECK(v1.isString()); |
michael@0 | 62 | CHECK(v1.toString()); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | { |
michael@0 | 66 | JSAutoCompartment ac(cx, g2); |
michael@0 | 67 | JS::RootedValue v2(cx); |
michael@0 | 68 | |
michael@0 | 69 | CHECK(JS_StructuredClone(cx, v1, &v2, nullptr, nullptr)); |
michael@0 | 70 | CHECK(v2.isString()); |
michael@0 | 71 | CHECK(v2.toString()); |
michael@0 | 72 | |
michael@0 | 73 | JS::RootedValue expected(cx, JS::StringValue( |
michael@0 | 74 | JS_NewStringCopyZ(cx, "Hello World!"))); |
michael@0 | 75 | CHECK_SAME(v2, expected); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | return true; |
michael@0 | 79 | } |
michael@0 | 80 | END_TEST(testStructuredClone_string) |