mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 966471. Add some facilities for examining the state of a promise via a PromiseDebugging utility namespace. r=nsm,peterv
This commit is contained in:
parent
20075d3df1
commit
5118eea016
@ -997,6 +997,10 @@ DOMInterfaces = {
|
||||
'implicitJSContext': [ 'then', 'catch' ],
|
||||
},
|
||||
|
||||
'PromiseDebugging': {
|
||||
'concrete': False,
|
||||
},
|
||||
|
||||
'PropertyNodeList': {
|
||||
'headerFile': 'HTMLPropertiesCollection.h',
|
||||
'resultNotAddRefed': [ 'item' ]
|
||||
|
@ -30,6 +30,7 @@ class DOMError;
|
||||
class PromiseCallback;
|
||||
class PromiseInit;
|
||||
class PromiseNativeHandler;
|
||||
class PromiseDebugging;
|
||||
|
||||
class Promise;
|
||||
class PromiseReportRejectFeature : public workers::WorkerFeature
|
||||
@ -154,6 +155,8 @@ public:
|
||||
void AppendNativeHandler(PromiseNativeHandler* aRunnable);
|
||||
|
||||
private:
|
||||
friend class PromiseDebugging;
|
||||
|
||||
enum PromiseState {
|
||||
Pending,
|
||||
Resolved,
|
||||
|
40
dom/promise/PromiseDebugging.cpp
Normal file
40
dom/promise/PromiseDebugging.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/PromiseDebugging.h"
|
||||
|
||||
#include "js/Value.h"
|
||||
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/PromiseDebuggingBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/* static */ void
|
||||
PromiseDebugging::GetState(GlobalObject&, Promise& aPromise,
|
||||
PromiseDebuggingStateHolder& aState)
|
||||
{
|
||||
switch (aPromise.mState) {
|
||||
case Promise::Pending:
|
||||
aState.mState = PromiseDebuggingState::Pending;
|
||||
break;
|
||||
case Promise::Resolved:
|
||||
aState.mState = PromiseDebuggingState::Fulfilled;
|
||||
JS::ExposeValueToActiveJS(aPromise.mResult);
|
||||
aState.mValue = aPromise.mResult;
|
||||
break;
|
||||
case Promise::Rejected:
|
||||
aState.mState = PromiseDebuggingState::Rejected;
|
||||
JS::ExposeValueToActiveJS(aPromise.mResult);
|
||||
aState.mReason = aPromise.mResult;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
27
dom/promise/PromiseDebugging.h
Normal file
27
dom/promise/PromiseDebugging.h
Normal file
@ -0,0 +1,27 @@
|
||||
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_PromiseDebugging_h
|
||||
#define mozilla_dom_PromiseDebugging_h
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Promise;
|
||||
struct PromiseDebuggingStateHolder;
|
||||
class GlobalObject;
|
||||
|
||||
class PromiseDebugging
|
||||
{
|
||||
public:
|
||||
static void GetState(GlobalObject&, Promise& aPromise,
|
||||
PromiseDebuggingStateHolder& aState);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_PromiseDebugging_h
|
@ -8,13 +8,15 @@ TEST_DIRS += ['tests']
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'Promise.h',
|
||||
'PromiseDebugging.h',
|
||||
'PromiseNativeHandler.h',
|
||||
'PromiseWorkerProxy.h',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
UNIFIED_SOURCES += [
|
||||
'Promise.cpp',
|
||||
'PromiseCallback.cpp',
|
||||
'PromiseDebugging.cpp'
|
||||
]
|
||||
|
||||
FAIL_ON_WARNINGS = True
|
||||
|
20
dom/webidl/PromiseDebugging.webidl
Normal file
20
dom/webidl/PromiseDebugging.webidl
Normal file
@ -0,0 +1,20 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
/* This is a utility namespace for promise-debugging functionality */
|
||||
|
||||
|
||||
dictionary PromiseDebuggingStateHolder {
|
||||
PromiseDebuggingState state = "pending";
|
||||
any value;
|
||||
any reason;
|
||||
};
|
||||
enum PromiseDebuggingState { "pending", "fulfilled", "rejected" };
|
||||
|
||||
[ChromeOnly]
|
||||
interface PromiseDebugging {
|
||||
static PromiseDebuggingStateHolder getState(Promise p);
|
||||
};
|
@ -297,6 +297,7 @@ WEBIDL_FILES = [
|
||||
'PositionError.webidl',
|
||||
'ProcessingInstruction.webidl',
|
||||
'Promise.webidl',
|
||||
'PromiseDebugging.webidl',
|
||||
'PushManager.webidl',
|
||||
'Range.webidl',
|
||||
'Rect.webidl',
|
||||
|
Loading…
Reference in New Issue
Block a user