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