Bug 1681763 [wpt PR 26839] - WPT test: referrer on navigation from opaque origin...
[gecko.git] / js / src / debugger / Environment.h
blob0a02a25ed210e4db7500bd6d24a225acefec15a4
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
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 debugger_Environment_h
8 #define debugger_Environment_h
10 #include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT
11 #include "mozilla/Attributes.h" // for MOZ_MUST_USE
12 #include "mozilla/Maybe.h" // for Maybe
14 #include "jstypes.h" // for JS_PUBLIC_API
15 #include "NamespaceImports.h" // for Value, HandleId, HandleObject
16 #include "debugger/Debugger.h" // for Env
17 #include "gc/Rooting.h" // for HandleDebuggerEnvironment
18 #include "js/PropertySpec.h" // for JSFunctionSpec, JSPropertySpec
19 #include "js/RootingAPI.h" // for Handle, MutableHandle
20 #include "vm/NativeObject.h" // for NativeObject
21 #include "vm/Scope.h" // for ScopeKind
23 class JS_PUBLIC_API JSObject;
24 struct JS_PUBLIC_API JSContext;
25 class JSTracer;
27 namespace js {
29 class GlobalObject;
31 enum class DebuggerEnvironmentType { Declarative, With, Object };
33 class DebuggerEnvironment : public NativeObject {
34 public:
35 enum { OWNER_SLOT };
37 static const unsigned RESERVED_SLOTS = 1;
39 static const JSClass class_;
41 static NativeObject* initClass(JSContext* cx, Handle<GlobalObject*> global,
42 HandleObject dbgCtor);
43 static DebuggerEnvironment* create(JSContext* cx, HandleObject proto,
44 HandleObject referent,
45 HandleNativeObject debugger);
47 void trace(JSTracer* trc);
49 DebuggerEnvironmentType type() const;
50 mozilla::Maybe<ScopeKind> scopeKind() const;
51 MOZ_MUST_USE bool getParent(JSContext* cx,
52 MutableHandleDebuggerEnvironment result) const;
53 MOZ_MUST_USE bool getObject(JSContext* cx,
54 MutableHandleDebuggerObject result) const;
55 MOZ_MUST_USE bool getCalleeScript(JSContext* cx,
56 MutableHandleDebuggerScript result) const;
57 bool isDebuggee() const;
58 bool isOptimized() const;
60 static MOZ_MUST_USE bool getNames(JSContext* cx,
61 HandleDebuggerEnvironment environment,
62 MutableHandle<IdVector> result);
63 static MOZ_MUST_USE bool find(JSContext* cx,
64 HandleDebuggerEnvironment environment,
65 HandleId id,
66 MutableHandleDebuggerEnvironment result);
67 static MOZ_MUST_USE bool getVariable(JSContext* cx,
68 HandleDebuggerEnvironment environment,
69 HandleId id, MutableHandleValue result);
70 static MOZ_MUST_USE bool setVariable(JSContext* cx,
71 HandleDebuggerEnvironment environment,
72 HandleId id, HandleValue value);
74 bool isInstance() const;
75 Debugger* owner() const;
77 Env* referent() const {
78 Env* env = static_cast<Env*>(getPrivate());
79 MOZ_ASSERT(env);
80 return env;
83 private:
84 static const JSClassOps classOps_;
86 static const JSPropertySpec properties_[];
87 static const JSFunctionSpec methods_[];
89 bool requireDebuggee(JSContext* cx) const;
91 static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp);
93 struct CallData;
96 } /* namespace js */
98 #endif /* debugger_Environment_h */