Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/nsIScriptGlobalObject.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#ifndef nsIScriptGlobalObject_h__
8
#define nsIScriptGlobalObject_h__
9
10
#include "nsISupports.h"
11
#include "nsIGlobalObject.h"
12
#include "js/TypeDecls.h"
13
#include "mozilla/EventForwards.h"
14
15
class nsIScriptContext;
16
class nsIScriptGlobalObject;
17
18
namespace mozilla {
19
namespace dom {
20
struct ErrorEventInit;
21
} // namespace dom
22
} // namespace mozilla
23
24
// A helper function for nsIScriptGlobalObject implementations to use
25
// when handling a script error.  Generally called by the global when a context
26
// notifies it of an error via nsIScriptGlobalObject::HandleScriptError.
27
// Returns true if HandleDOMEvent was actually called, in which case
28
// aStatus will be filled in with the status.
29
bool
30
NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal,
31
                     const mozilla::dom::ErrorEventInit &aErrorEvent,
32
                     nsEventStatus *aStatus);
33
34
35
// Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
36
#define NS_ISCRIPTGLOBALOBJECT_IID \
37
{ 0x876f83bd, 0x6314, 0x460a, \
38
  { 0xa0, 0x45, 0x1c, 0x8f, 0x46, 0x2f, 0xb8, 0xe1 } }
39
40
/**
41
 * The global object which keeps a script context for each supported script
42
 * language. This often used to store per-window global state.
43
 * This is a heavyweight interface implemented only by DOM globals, and
44
 * it might go away some time in the future.
45
 */
46
47
class nsIScriptGlobalObject : public nsIGlobalObject
48
{
49
public:
50
  NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTGLOBALOBJECT_IID)
51
52
  /**
53
   * Ensure that the script global object is initialized for working with the
54
   * specified script language ID.  This will set up the nsIScriptContext
55
   * and 'script global' for that language, allowing these to be fetched
56
   * and manipulated.
57
   * @return NS_OK if successful; error conditions include that the language
58
   * has not been registered, as well as 'normal' errors, such as
59
   * out-of-memory
60
   */
61
  virtual nsresult EnsureScriptEnvironment() = 0;
62
  /**
63
   * Get a script context (WITHOUT added reference) for the specified language.
64
   */
65
  virtual nsIScriptContext *GetScriptContext() = 0;
66
67
  nsIScriptContext* GetContext() {
68
    return GetScriptContext();
69
  }
70
71
  /**
72
   * Handle a script error.  Generally called by a script context.
73
   */
74
  bool HandleScriptError(const mozilla::dom::ErrorEventInit &aErrorEventInit,
75
                         nsEventStatus *aEventStatus) {
76
    return NS_HandleScriptError(this, aErrorEventInit, aEventStatus);
77
  }
78
79
  virtual bool IsBlackForCC(bool aTracingNeeded = true) { return false; }
80
81
protected:
82
0
  virtual ~nsIScriptGlobalObject() {}
83
};
84
85
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptGlobalObject,
86
                              NS_ISCRIPTGLOBALOBJECT_IID)
87
88
#endif