2017-06-19 16:19:55 +08:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
|
2018-07-17 08:23:49 +02:00
|
|
|
common.disableCrashOnUnhandledRejection();
|
|
|
|
|
2018-03-20 12:39:46 +01:00
|
|
|
const expectedDeprecationWarning = ['Unhandled promise rejections are ' +
|
2017-06-19 16:19:55 +08:00
|
|
|
'deprecated. In the future, promise ' +
|
|
|
|
'rejections that are not handled will ' +
|
|
|
|
'terminate the Node.js process with a ' +
|
2018-03-20 12:39:46 +01:00
|
|
|
'non-zero exit code.', 'DEP0018'];
|
|
|
|
const expectedPromiseWarning = ['Unhandled promise rejection. ' +
|
2017-11-20 14:22:37 -05:00
|
|
|
'This error originated either by throwing ' +
|
|
|
|
'inside of an async function without a catch ' +
|
|
|
|
'block, or by rejecting a promise which was ' +
|
2018-12-28 14:33:33 +01:00
|
|
|
'not handled with .catch(). (rejection id: 1)'];
|
2017-06-19 16:19:55 +08:00
|
|
|
|
|
|
|
function throwErr() {
|
|
|
|
throw new Error('Error from proxy');
|
|
|
|
}
|
|
|
|
|
|
|
|
const thorny = new Proxy({}, {
|
|
|
|
getPrototypeOf: throwErr,
|
|
|
|
setPrototypeOf: throwErr,
|
|
|
|
isExtensible: throwErr,
|
|
|
|
preventExtensions: throwErr,
|
|
|
|
getOwnPropertyDescriptor: throwErr,
|
|
|
|
defineProperty: throwErr,
|
|
|
|
has: throwErr,
|
|
|
|
get: throwErr,
|
|
|
|
set: throwErr,
|
|
|
|
deleteProperty: throwErr,
|
|
|
|
ownKeys: throwErr,
|
|
|
|
apply: throwErr,
|
|
|
|
construct: throwErr
|
|
|
|
});
|
|
|
|
|
|
|
|
common.expectWarning({
|
|
|
|
DeprecationWarning: expectedDeprecationWarning,
|
|
|
|
UnhandledPromiseRejectionWarning: expectedPromiseWarning,
|
|
|
|
});
|
|
|
|
|
|
|
|
// ensure this doesn't crash
|
|
|
|
Promise.reject(thorny);
|