Bug 1879774 [wpt PR 44524] - WebKit export: Implement field-sizing support for input...
[gecko.git] / dom / workers / WorkerError.h
blob43600fbf1ad13c5366b4371b453f59491ded6804
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_workers_WorkerError_h
8 #define mozilla_dom_workers_WorkerError_h
10 #include "mozilla/dom/SerializedStackHolder.h"
11 #include "mozilla/dom/WorkerCommon.h"
12 #include "jsapi.h"
14 namespace mozilla {
16 class DOMEventTargetHelper;
18 namespace dom {
20 class ErrorData;
21 class WorkerErrorBase {
22 public:
23 nsString mMessage;
24 nsString mFilename;
25 // Line number (1-origin).
26 uint32_t mLineNumber;
27 // Column number in UTF-16 code units (1-origin).
28 uint32_t mColumnNumber;
29 uint32_t mErrorNumber;
31 WorkerErrorBase() : mLineNumber(0), mColumnNumber(0), mErrorNumber(0) {}
33 void AssignErrorBase(JSErrorBase* aReport);
36 class WorkerErrorNote : public WorkerErrorBase {
37 public:
38 void AssignErrorNote(JSErrorNotes::Note* aNote);
41 class WorkerPrivate;
43 class WorkerErrorReport : public WorkerErrorBase, public SerializedStackHolder {
44 public:
45 nsString mLine;
46 bool mIsWarning;
47 JSExnType mExnType;
48 bool mMutedError;
49 nsTArray<WorkerErrorNote> mNotes;
51 WorkerErrorReport();
53 void AssignErrorReport(JSErrorReport* aReport);
55 // aWorkerPrivate is the worker thread we're on (or the main thread, if null)
56 // aTarget is the worker object that we are going to fire an error at
57 // (if any).
58 // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1743443)
59 MOZ_CAN_RUN_SCRIPT_BOUNDARY static void ReportError(
60 JSContext* aCx, WorkerPrivate* aWorkerPrivate, bool aFireAtScope,
61 DOMEventTargetHelper* aTarget, UniquePtr<WorkerErrorReport> aReport,
62 uint64_t aInnerWindowId,
63 JS::Handle<JS::Value> aException = JS::NullHandleValue);
65 static void LogErrorToConsole(JSContext* aCx, WorkerErrorReport& aReport,
66 uint64_t aInnerWindowId);
68 static void LogErrorToConsole(const mozilla::dom::ErrorData& aReport,
69 uint64_t aInnerWindowId,
70 JS::Handle<JSObject*> aStack = nullptr,
71 JS::Handle<JSObject*> aStackGlobal = nullptr);
73 static void CreateAndDispatchGenericErrorRunnableToParent(
74 WorkerPrivate* aWorkerPrivate);
77 } // namespace dom
78 } // namespace mozilla
80 #endif // mozilla_dom_workers_WorkerError_h