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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 7 | |
michael@0 | 8 | #include "jsapi.h" |
michael@0 | 9 | #include "jsstr.h" |
michael@0 | 10 | |
michael@0 | 11 | #include "js/CharacterEncoding.h" |
michael@0 | 12 | #include "jsapi-tests/tests.h" |
michael@0 | 13 | |
michael@0 | 14 | BEGIN_TEST(testUTF8_badUTF8) |
michael@0 | 15 | { |
michael@0 | 16 | static const char badUTF8[] = "...\xC0..."; |
michael@0 | 17 | JSString *str = JS_NewStringCopyZ(cx, badUTF8); |
michael@0 | 18 | CHECK(str); |
michael@0 | 19 | const jschar *chars = JS_GetStringCharsZ(cx, str); |
michael@0 | 20 | CHECK(chars); |
michael@0 | 21 | CHECK(chars[3] == 0x00C0); |
michael@0 | 22 | return true; |
michael@0 | 23 | } |
michael@0 | 24 | END_TEST(testUTF8_badUTF8) |
michael@0 | 25 | |
michael@0 | 26 | BEGIN_TEST(testUTF8_bigUTF8) |
michael@0 | 27 | { |
michael@0 | 28 | static const char bigUTF8[] = "...\xFB\xBF\xBF\xBF\xBF..."; |
michael@0 | 29 | JSString *str = JS_NewStringCopyZ(cx, bigUTF8); |
michael@0 | 30 | CHECK(str); |
michael@0 | 31 | const jschar *chars = JS_GetStringCharsZ(cx, str); |
michael@0 | 32 | CHECK(chars); |
michael@0 | 33 | CHECK(chars[3] == 0x00FB); |
michael@0 | 34 | return true; |
michael@0 | 35 | } |
michael@0 | 36 | END_TEST(testUTF8_bigUTF8) |
michael@0 | 37 | |
michael@0 | 38 | BEGIN_TEST(testUTF8_badSurrogate) |
michael@0 | 39 | { |
michael@0 | 40 | static const jschar badSurrogate[] = { 'A', 'B', 'C', 0xDEEE, 'D', 'E', 0 }; |
michael@0 | 41 | JS::TwoByteChars tbchars(badSurrogate, js_strlen(badSurrogate)); |
michael@0 | 42 | JS::Latin1CharsZ latin1 = JS::LossyTwoByteCharsToNewLatin1CharsZ(cx, tbchars); |
michael@0 | 43 | CHECK(latin1); |
michael@0 | 44 | CHECK(latin1[3] == 0x00EE); |
michael@0 | 45 | return true; |
michael@0 | 46 | } |
michael@0 | 47 | END_TEST(testUTF8_badSurrogate) |