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 #ifndef vm_ErrorObject_h_
8 #define vm_ErrorObject_h_
10 #include "jsobj.h"
12 #include "vm/Shape.h"
14 struct JSExnPrivate;
16 /*
17 * Initialize the exception constructor/prototype hierarchy.
18 */
19 extern JSObject *
20 js_InitExceptionClasses(JSContext *cx, JS::HandleObject obj);
22 namespace js {
24 class ErrorObject : public JSObject
25 {
26 static ErrorObject *
27 createProto(JSContext *cx, JS::Handle<GlobalObject*> global, JSExnType type,
28 JS::HandleObject proto);
30 /* For access to createProto. */
31 friend JSObject *
32 ::js_InitExceptionClasses(JSContext *cx, JS::HandleObject global);
34 /* For access to assignInitialShape. */
35 friend bool
36 EmptyShape::ensureInitialCustomShape<ErrorObject>(ExclusiveContext *cx,
37 Handle<ErrorObject*> obj);
39 /*
40 * Assign the initial error shape to the empty object. (This shape does
41 * *not* include .message, which must be added separately if needed; see
42 * ErrorObject::init.)
43 */
44 static Shape *
45 assignInitialShape(ExclusiveContext *cx, Handle<ErrorObject*> obj);
47 static bool
48 init(JSContext *cx, Handle<ErrorObject*> obj, JSExnType type,
49 ScopedJSFreePtr<JSErrorReport> *errorReport, HandleString fileName, HandleString stack,
50 uint32_t lineNumber, uint32_t columnNumber, HandleString message);
52 protected:
53 static const uint32_t EXNTYPE_SLOT = 0;
54 static const uint32_t ERROR_REPORT_SLOT = EXNTYPE_SLOT + 1;
55 static const uint32_t FILENAME_SLOT = ERROR_REPORT_SLOT + 1;
56 static const uint32_t LINENUMBER_SLOT = FILENAME_SLOT + 1;
57 static const uint32_t COLUMNNUMBER_SLOT = LINENUMBER_SLOT + 1;
58 static const uint32_t STACK_SLOT = COLUMNNUMBER_SLOT + 1;
59 static const uint32_t MESSAGE_SLOT = STACK_SLOT + 1;
61 static const uint32_t RESERVED_SLOTS = MESSAGE_SLOT + 1;
63 public:
64 static const Class class_;
66 // Create an error of the given type corresponding to the provided location
67 // info. If |message| is non-null, then the error will have a .message
68 // property with that value; otherwise the error will have no .message
69 // property.
70 static ErrorObject *
71 create(JSContext *cx, JSExnType type, HandleString stack, HandleString fileName,
72 uint32_t lineNumber, uint32_t columnNumber, ScopedJSFreePtr<JSErrorReport> *report,
73 HandleString message);
75 JSExnType type() const {
76 return JSExnType(getReservedSlot(EXNTYPE_SLOT).toInt32());
77 }
79 JSErrorReport * getErrorReport() const {
80 const Value &slot = getReservedSlot(ERROR_REPORT_SLOT);
81 if (slot.isUndefined())
82 return nullptr;
83 return static_cast<JSErrorReport*>(slot.toPrivate());
84 }
86 JSErrorReport * getOrCreateErrorReport(JSContext *cx);
88 inline JSString * fileName(JSContext *cx) const;
89 inline uint32_t lineNumber() const;
90 inline uint32_t columnNumber() const;
91 inline JSString * stack(JSContext *cx) const;
93 JSString * getMessage() const {
94 const HeapSlot &slot = getReservedSlotRef(MESSAGE_SLOT);
95 return slot.isString() ? slot.toString() : nullptr;
96 }
97 };
99 } // namespace js
101 #endif // vm_ErrorObject_h_