Skip to content
Prev Previous commit
Next Next commit
global crypto getter this
  • Loading branch information
panva committed Nov 22, 2022
commit 321fab6fc0bb60a86d160f6860f39e86ea1b69cf
4 changes: 4 additions & 0 deletions lib/internal/process/pre_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const {
} = require('internal/util');

const {
ERR_INVALID_THIS,
ERR_MANIFEST_ASSERT_INTEGRITY,
ERR_NO_CRYPTO,
} = require('internal/errors').codes;
Expand Down Expand Up @@ -278,6 +279,9 @@ function setupWebCrypto() {
ObjectDefineProperty(globalThis, 'crypto',
{ __proto__: null, ...ObjectGetOwnPropertyDescriptor({
get crypto() {
if (this !== globalThis && this !== undefined)
Comment thread
panva marked this conversation as resolved.
Outdated
throw new ERR_INVALID_THIS(
'globalThis or undefined');
Comment thread
panva marked this conversation as resolved.
Outdated
return webcrypto.crypto;
}
}, 'crypto') });
Expand Down
3 changes: 1 addition & 2 deletions test/wpt/status/WebCryptoAPI.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"fail": {
"expected": [
"CryptoKey interface: existence and properties of interface object",
"CryptoKey interface: existence and properties of interface prototype object",
"Window interface: attribute crypto"
"CryptoKey interface: existence and properties of interface prototype object"
]
}
}
Expand Down