GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: allow unbound SubtleCrypto.supports · nodejs/node@0346e4e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/crypto
    • webcrypto.js
  • test/parallel
    • test-webcrypto-constructors.js
    • test-webcrypto-supports-receiver.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/crypto/webcrypto.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/webcrypto.js
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,6 @@ class SubtleCrypto {
17611761
// TODO(panva): Make supports() account for the active FIPS state.
17621762
static supports(operation, algorithm, lengthOrAdditionalAlgorithm = null) {
17631763
emitExperimentalWarning('The supports Web Crypto API method');
1764-
if (this !== SubtleCrypto) throw new ERR_INVALID_THIS('SubtleCrypto constructor');
17651764
webidl ??= require('internal/crypto/webidl');
17661765
const prefix = "Failed to execute 'supports' on 'SubtleCrypto'";
17671766
webidl.requiredArguments(arguments.length, 2, { prefix });
Collapse file

‎test/parallel/test-webcrypto-constructors.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-webcrypto-constructors.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const notSubtle = Reflect.construct(function() {}, [], SubtleCrypto);
142142
// Test SubtleCrypto.supports
143143
{
144144
assert.throws(() => SubtleCrypto.supports.call(undefined), {
145-
name: 'TypeError', code: 'ERR_INVALID_THIS',
145+
name: 'TypeError', code: 'ERR_MISSING_ARGS',
146146
});
147147
}
148148

Collapse file

‎test/parallel/test-webcrypto-supports-receiver.js‎

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
7+
const assert = require('assert');
8+
const { supports } = SubtleCrypto;
9+
10+
assert.strictEqual(supports('digest', 'SHA-256'), true);
11+
for (const receiver of [undefined, null, {}, globalThis.crypto.subtle]) {
12+
assert.strictEqual(supports.call(receiver, 'digest', 'SHA-256'), true);
13+
assert.strictEqual(supports.call(receiver, 'digest', 'unknown'), false);
14+
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.