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 "jsapi-tests/tests.h" |
michael@0 | 6 | |
michael@0 | 7 | BEGIN_TEST(testObjectIsRegExp) |
michael@0 | 8 | { |
michael@0 | 9 | JS::RootedValue val(cx); |
michael@0 | 10 | |
michael@0 | 11 | EVAL("new Object", &val); |
michael@0 | 12 | JS::RootedObject obj(cx, JSVAL_TO_OBJECT(val)); |
michael@0 | 13 | CHECK(!JS_ObjectIsRegExp(cx, obj)); |
michael@0 | 14 | |
michael@0 | 15 | EVAL("/foopy/", &val); |
michael@0 | 16 | obj = JSVAL_TO_OBJECT(val); |
michael@0 | 17 | CHECK(JS_ObjectIsRegExp(cx, obj)); |
michael@0 | 18 | |
michael@0 | 19 | return true; |
michael@0 | 20 | } |
michael@0 | 21 | END_TEST(testObjectIsRegExp) |
michael@0 | 22 | |
michael@0 | 23 | BEGIN_TEST(testGetRegExpFlags) |
michael@0 | 24 | { |
michael@0 | 25 | JS::RootedValue val(cx); |
michael@0 | 26 | JS::RootedObject obj(cx); |
michael@0 | 27 | |
michael@0 | 28 | EVAL("/foopy/", &val); |
michael@0 | 29 | obj = JSVAL_TO_OBJECT(val); |
michael@0 | 30 | CHECK_EQUAL(JS_GetRegExpFlags(cx, obj), 0); |
michael@0 | 31 | |
michael@0 | 32 | EVAL("/foopy/g", &val); |
michael@0 | 33 | obj = JSVAL_TO_OBJECT(val); |
michael@0 | 34 | CHECK_EQUAL(JS_GetRegExpFlags(cx, obj), JSREG_GLOB); |
michael@0 | 35 | |
michael@0 | 36 | EVAL("/foopy/gi", &val); |
michael@0 | 37 | obj = JSVAL_TO_OBJECT(val); |
michael@0 | 38 | CHECK_EQUAL(JS_GetRegExpFlags(cx, obj), (JSREG_FOLD | JSREG_GLOB)); |
michael@0 | 39 | |
michael@0 | 40 | return true; |
michael@0 | 41 | } |
michael@0 | 42 | END_TEST(testGetRegExpFlags) |
michael@0 | 43 | |
michael@0 | 44 | BEGIN_TEST(testGetRegExpSource) |
michael@0 | 45 | { |
michael@0 | 46 | JS::RootedValue val(cx); |
michael@0 | 47 | JS::RootedObject obj(cx); |
michael@0 | 48 | |
michael@0 | 49 | EVAL("/foopy/", &val); |
michael@0 | 50 | obj = JSVAL_TO_OBJECT(val); |
michael@0 | 51 | JSString *source = JS_GetRegExpSource(cx, obj); |
michael@0 | 52 | CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(source), "foopy")); |
michael@0 | 53 | |
michael@0 | 54 | return true; |
michael@0 | 55 | } |
michael@0 | 56 | END_TEST(testGetRegExpSource) |