| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,7 @@ const { | |||
| 23 | 23 | } = require('internal/util'); | |
| 24 | 24 | ||
| 25 | 25 | const { | |
| 26 | + ERR_INVALID_THIS, | ||
| 26 | 27 | ERR_MANIFEST_ASSERT_INTEGRITY, | |
| 27 | 28 | ERR_NO_CRYPTO, | |
| 28 | 29 | } = require('internal/errors').codes; | |
@@ -278,7 +279,15 @@ function setupWebCrypto() { | |||
| 278 | 279 | ||
| 279 | 280 | if (internalBinding('config').hasOpenSSL) { | |
| 280 | 281 | defineReplaceableLazyAttribute( | |
| 281 | - globalThis, 'internal/crypto/webcrypto', ['crypto'], false | ||
| 282 | + globalThis, | ||
| 283 | + 'internal/crypto/webcrypto', | ||
| 284 | + ['crypto'], | ||
| 285 | + false, | ||
| 286 | + function cryptoThisCheck() { | ||
| 287 | + if (this !== globalThis && this != null) | ||
| 288 | + throw new ERR_INVALID_THIS( | ||
| 289 | + 'nullish or must be the global object'); | ||
| 290 | + } | ||
| 282 | 291 | ); | |
| 283 | 292 | exposeLazyInterfaces( | |
| 284 | 293 | globalThis, 'internal/crypto/webcrypto', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -552,14 +552,17 @@ function defineLazyProperties(target, id, keys, enumerable = true) { | |||
| 552 | 552 | ObjectDefineProperties(target, descriptors); | |
| 553 | 553 | } | |
| 554 | 554 | ||
| 555 | - function defineReplaceableLazyAttribute(target, id, keys, writable = true) { | ||
| 555 | + function defineReplaceableLazyAttribute(target, id, keys, writable = true, check) { | ||
| 556 | 556 | let mod; | |
| 557 | 557 | for (let i = 0; i < keys.length; i++) { | |
| 558 | 558 | const key = keys[i]; | |
| 559 | 559 | let value; | |
| 560 | 560 | let setterCalled = false; | |
| 561 | 561 | ||
| 562 | 562 | function get() { | |
| 563 | + if (check !== undefined) { | ||
| 564 | + FunctionPrototypeCall(check, this); | ||
| 565 | + } | ||
| 563 | 566 | if (setterCalled) { | |
| 564 | 567 | return value; | |
| 565 | 568 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,13 +17,5 @@ | |||
| 17 | 17 | }, | |
| 18 | 18 | "historical.any.js": { | |
| 19 | 19 | "skip": "Not relevant in Node.js context" | |
| 20 | - }, | ||
| 21 | - "idlharness.https.any.js": { | ||
| 22 | - "fail": { | ||
| 23 | - "expected": [ | ||
| 24 | - "CryptoKey interface: existence and properties of interface object", | ||
| 25 | - "Window interface: attribute crypto" | ||
| 26 | - ] | ||
| 27 | - } | ||
| 28 | 20 | } | |
| 29 | 21 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments