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"
16 class DOMEventTargetHelper
;
21 class WorkerErrorBase
{
25 // Line number (1-origin).
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
{
38 void AssignErrorNote(JSErrorNotes::Note
* aNote
);
43 class WorkerErrorReport
: public WorkerErrorBase
, public SerializedStackHolder
{
49 nsTArray
<WorkerErrorNote
> mNotes
;
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
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
);
78 } // namespace mozilla
80 #endif // mozilla_dom_workers_WorkerError_h