This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 24415 - Replace enums with DOMStrings
Summary: Replace enums with DOMStrings
Status: RESOLVED FIXED
Alias: None
Product: Web Cryptography
Classification: Unclassified
Component: Web Cryptography API Document (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Mark Watson
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 23503 23729
  Show dependency treegraph
 
Reported: 2014-01-27 23:04 UTC by Mark Watson
Modified: 2014-02-07 02:38 UTC (History)
1 user (show)

See Also:


Attachments

Description Mark Watson 2014-01-27 23:04:50 UTC
As discussed at Shenzhen f2f and on 1/27, we should replace all enums with DOMStrings and define explicitly the rules for unrecognized values.
Comment 2 Ryan Sleevi 2014-01-28 07:58:00 UTC
Re-opened.

The proposed specification language in inadequate, and thus needs to be revisited.

1) It continues the pattern of synchronous exceptions. This was the key issue with enums in the first place - since an enum will cause a WebIDL exception in the same way - versus the proposal to invoke the failure handler of the promise - avoiding the need to wrap the invocation in an additional try/catch.

This was the *entire* reason for not using the "standard" WebIDL form of enum (ie: recommended - see XHR Level 2, for ex) and instead using DOMString, was so that the promises could be cancelled asynchronously rather than forcing a synchronous WebIDL exception.

2) It inadequately specifies what a recognized KeyUsage is.

The specification language uses "If keyUsages includes a value that is not a recognized KeyUsage value, throw a NotSupportedError and terminate the algorithm"

However, such language is inadequate for several reasons:
a) The term "recognized key usage" is not listed as a term for reference to the KeyUsage data type/specification
b) It fails to specify how one determines whether or not a value is a recognized KeyUsage. For example, is it a case-sensitive (code-point for code-point) match? Is it a case-insensitive ASCII comparison? 

For example, see the specification for lockOrientation ( https://dvcs.w3.org/hg/screen-orientation/raw-file/tip/Overview.html )

Proposal:
1) Fail the promise, don't throw
2) Ensure that recognized key usages are listed within a normative section, as a referenced/defined term, with a defined comparison algorithm. case-sensitive is fine, referencing ECMA is fine, any other form is fine, as long as it's defined.
Comment 3 Mark Watson 2014-01-28 15:48:41 UTC
1) Asynchronicity: the stated reasons for DOMStrings were forwards/backwards compatibility. We have other errors that can be and are synchronous (unrecognized algorithm, required usage not present). If we want to make *all* failures asynchronous, that's fine, but we should open another bug for that.

2) The KeyUsage definition says "The recognized KeyUsage values are ..." and this definition is linked from every reference to KeyUsage. I can explicitly link the phrase 'recognized KeyUsage value' too if you like. The procedures use the phrase "is not a recognized value' which means an equality comparison rule. Equality is well-defined for DOMStrings. I can add references and clarifications if you like, but it's not underspecified.
Comment 4 Mark Watson 2014-02-07 02:38:57 UTC
For Issue 1) Bug 24427
For Issue 2) https://dvcs.w3.org/hg/webcrypto-api/rev/84ee476e7fc1