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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "WaiveXrayWrapper.h" |
michael@0 | 8 | #include "WrapperFactory.h" |
michael@0 | 9 | #include "jsapi.h" |
michael@0 | 10 | |
michael@0 | 11 | using namespace JS; |
michael@0 | 12 | |
michael@0 | 13 | namespace xpc { |
michael@0 | 14 | |
michael@0 | 15 | static bool |
michael@0 | 16 | WaiveAccessors(JSContext *cx, JS::MutableHandle<JSPropertyDescriptor> desc) |
michael@0 | 17 | { |
michael@0 | 18 | if (desc.hasGetterObject() && desc.getterObject()) { |
michael@0 | 19 | RootedValue v(cx, JS::ObjectValue(*desc.getterObject())); |
michael@0 | 20 | if (!WrapperFactory::WaiveXrayAndWrap(cx, &v)) |
michael@0 | 21 | return false; |
michael@0 | 22 | desc.setGetterObject(&v.toObject()); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | if (desc.hasSetterObject() && desc.setterObject()) { |
michael@0 | 26 | RootedValue v(cx, JS::ObjectValue(*desc.setterObject())); |
michael@0 | 27 | if (!WrapperFactory::WaiveXrayAndWrap(cx, &v)) |
michael@0 | 28 | return false; |
michael@0 | 29 | desc.setSetterObject(&v.toObject()); |
michael@0 | 30 | } |
michael@0 | 31 | return true; |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | WaiveXrayWrapper::WaiveXrayWrapper(unsigned flags) : js::CrossCompartmentWrapper(flags) |
michael@0 | 35 | { |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | WaiveXrayWrapper::~WaiveXrayWrapper() |
michael@0 | 39 | { |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | bool |
michael@0 | 43 | WaiveXrayWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, |
michael@0 | 44 | HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc) |
michael@0 | 45 | { |
michael@0 | 46 | return CrossCompartmentWrapper::getPropertyDescriptor(cx, wrapper, id, desc) && |
michael@0 | 47 | WrapperFactory::WaiveXrayAndWrap(cx, desc.value()) && WaiveAccessors(cx, desc); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | bool |
michael@0 | 51 | WaiveXrayWrapper::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, |
michael@0 | 52 | HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc) |
michael@0 | 53 | { |
michael@0 | 54 | return CrossCompartmentWrapper::getOwnPropertyDescriptor(cx, wrapper, id, desc) && |
michael@0 | 55 | WrapperFactory::WaiveXrayAndWrap(cx, desc.value()) && WaiveAccessors(cx, desc); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | bool |
michael@0 | 59 | WaiveXrayWrapper::get(JSContext *cx, HandleObject wrapper, |
michael@0 | 60 | HandleObject receiver, HandleId id, |
michael@0 | 61 | MutableHandleValue vp) |
michael@0 | 62 | { |
michael@0 | 63 | return CrossCompartmentWrapper::get(cx, wrapper, receiver, id, vp) && |
michael@0 | 64 | WrapperFactory::WaiveXrayAndWrap(cx, vp); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | bool |
michael@0 | 68 | WaiveXrayWrapper::call(JSContext *cx, HandleObject wrapper, const JS::CallArgs &args) |
michael@0 | 69 | { |
michael@0 | 70 | return CrossCompartmentWrapper::call(cx, wrapper, args) && |
michael@0 | 71 | WrapperFactory::WaiveXrayAndWrap(cx, args.rval()); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | bool |
michael@0 | 75 | WaiveXrayWrapper::construct(JSContext *cx, HandleObject wrapper, const JS::CallArgs &args) |
michael@0 | 76 | { |
michael@0 | 77 | return CrossCompartmentWrapper::construct(cx, wrapper, args) && |
michael@0 | 78 | WrapperFactory::WaiveXrayAndWrap(cx, args.rval()); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | // NB: This is important as the other side of a handshake with FieldGetter. See |
michael@0 | 82 | // nsXBLProtoImplField.cpp. |
michael@0 | 83 | bool |
michael@0 | 84 | WaiveXrayWrapper::nativeCall(JSContext *cx, JS::IsAcceptableThis test, |
michael@0 | 85 | JS::NativeImpl impl, JS::CallArgs args) |
michael@0 | 86 | { |
michael@0 | 87 | return CrossCompartmentWrapper::nativeCall(cx, test, impl, args) && |
michael@0 | 88 | WrapperFactory::WaiveXrayAndWrap(cx, args.rval()); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | bool |
michael@0 | 92 | WaiveXrayWrapper::getPrototypeOf(JSContext *cx, HandleObject wrapper, MutableHandleObject protop) |
michael@0 | 93 | { |
michael@0 | 94 | return CrossCompartmentWrapper::getPrototypeOf(cx, wrapper, protop) && |
michael@0 | 95 | (!protop || WrapperFactory::WaiveXrayAndWrap(cx, protop)); |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | } |