toolkit/crashreporter/google-breakpad/src/common/android/breakpad_getcontext_unittest.cc

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 // Copyright (c) 2012, Google Inc.
     2 // All rights reserved.
     3 //
     4 // Redistribution and use in source and binary forms, with or without
     5 // modification, are permitted provided that the following conditions are
     6 // met:
     7 //
     8 //     * Redistributions of source code must retain the above copyright
     9 // notice, this list of conditions and the following disclaimer.
    10 //     * Redistributions in binary form must reproduce the above
    11 // copyright notice, this list of conditions and the following disclaimer
    12 // in the documentation and/or other materials provided with the
    13 // distribution.
    14 //     * Neither the name of Google Inc. nor the names of its
    15 // contributors may be used to endorse or promote products derived from
    16 // this software without specific prior written permission.
    17 //
    18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    30 #include <sys/ucontext.h>
    32 #include "breakpad_googletest_includes.h"
    33 #include "common/android/ucontext_constants.h"
    35 TEST(AndroidUContext, GRegsOffset) {
    36 #ifdef __arm__
    37   // There is no gregs[] array on ARM, so compare to the offset of
    38   // first register fields, since they're stored in order.
    39   ASSERT_EQ(static_cast<size_t>(MCONTEXT_GREGS_OFFSET),
    40             offsetof(ucontext_t,uc_mcontext.arm_r0));
    41 #elif defined(__i386__)
    42   ASSERT_EQ(static_cast<size_t>(MCONTEXT_GREGS_OFFSET),
    43             offsetof(ucontext_t,uc_mcontext.gregs));
    44 #define CHECK_REG(x) \
    45   ASSERT_EQ(static_cast<size_t>(MCONTEXT_##x##_OFFSET),         \
    46             offsetof(ucontext_t,uc_mcontext.gregs[REG_##x]))
    47   CHECK_REG(GS);
    48   CHECK_REG(FS);
    49   CHECK_REG(ES);
    50   CHECK_REG(DS);
    51   CHECK_REG(EDI);
    52   CHECK_REG(ESI);
    53   CHECK_REG(EBP);
    54   CHECK_REG(ESP);
    55   CHECK_REG(EBX);
    56   CHECK_REG(EDX);
    57   CHECK_REG(ECX);
    58   CHECK_REG(EAX);
    59   CHECK_REG(TRAPNO);
    60   CHECK_REG(ERR);
    61   CHECK_REG(EIP);
    62   CHECK_REG(CS);
    63   CHECK_REG(EFL);
    64   CHECK_REG(UESP);
    65   CHECK_REG(SS);
    67   ASSERT_EQ(static_cast<size_t>(UCONTEXT_FPREGS_OFFSET),
    68             offsetof(ucontext_t,uc_mcontext.fpregs));
    70   ASSERT_EQ(static_cast<size_t>(UCONTEXT_FPREGS_MEM_OFFSET),
    71             offsetof(ucontext_t,__fpregs_mem));
    72 #else
    73   ASSERT_EQ(static_cast<size_t>(MCONTEXT_GREGS_OFFSET),
    74             offsetof(ucontext_t,uc_mcontext.gregs));
    75 #endif
    76 }
    78 TEST(AndroidUContext, SigmakOffset) {
    79   ASSERT_EQ(static_cast<size_t>(UCONTEXT_SIGMASK_OFFSET),
    80             offsetof(ucontext_t,uc_sigmask));
    81 }

mercurial