| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f6d7279 commit fdde369
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -671,4 +671,4 @@ exports.__defineGetter__('createCredentials', | |||
| 671 | 671 | exports.__defineGetter__('Credentials', internalUtil.deprecate(function() { | |
| 672 | 672 | return require('tls').SecureContext; | |
| 673 | 673 | }, 'crypto.Credentials is deprecated. ' + | |
| 674 | - 'Use tls.createSecureContext instead.')); | ||
| 674 | + 'Use tls.SecureContext instead.')); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,31 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + | ||
| 5 | + if (!common.hasCrypto) { | ||
| 6 | + console.log('1..0 # Skipped: missing crypto'); | ||
| 7 | + return; | ||
| 8 | + } | ||
| 9 | + const crypto = require('crypto'); | ||
| 10 | + const tls = require('tls'); | ||
| 11 | + | ||
| 12 | + process.on('warning', common.mustCall((warning) => { | ||
| 13 | + assert.strictEqual(warning.name, 'DeprecationWarning'); | ||
| 14 | + assert.notStrictEqual(expected.indexOf(warning.message), -1, | ||
| 15 | + `unexpected error message: "${warning.message}"`); | ||
| 16 | + // Remove a warning message after it is seen so that we guarantee that we get | ||
| 17 | + // each message only once. | ||
| 18 | + expected.splice(expected.indexOf(warning.message), 1); | ||
| 19 | + }, 2)); | ||
| 20 | + | ||
| 21 | + var expected = [ | ||
| 22 | + 'crypto.Credentials is deprecated. Use tls.SecureContext instead.', | ||
| 23 | + 'crypto.createCredentials is deprecated. Use tls.createSecureContext instead.' | ||
| 24 | + ]; | ||
| 25 | + | ||
| 26 | + // Accessing the deprecated function is enough to trigger the warning event. | ||
| 27 | + // It does not need to be called. So the assert serves the purpose of both | ||
| 28 | + // triggering the warning event and confirming that the deprected function is | ||
| 29 | + // mapped to the correct non-deprecated function. | ||
| 30 | + assert.strictEqual(crypto.Credentials, tls.SecureContext); | ||
| 31 | + assert.strictEqual(crypto.createCredentials, tls.createSecureContext); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments