Commit 7e70bd1f authored by Francois Beaufort's avatar Francois Beaufort Committed by Commit Bot

[webhid] Use [EnforceRange] for reportId

This CL makes sure sendReport(), sendFeatureReport() and
receiveFeatureReport() will throw an error if an invalid reportId is
provided by simply using EnforceRange.

Spec: https://github.com/WICG/webhid/pull/25
Bug: 890096
Change-Id: I4d6eee9a7460cfe1d707d87702f58c9fe43d39d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2317788
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: default avatarMatt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792899}
parent c0502a2d
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
[ [
CallWith=ScriptState, CallWith=ScriptState,
MeasureAs=HidDeviceSendReport MeasureAs=HidDeviceSendReport
] Promise<void> sendReport(octet reportId, BufferSource data); ] Promise<void> sendReport(
[EnforceRange] octet reportId, BufferSource data);
// Send a feature report to the device. Set |reportId| to the first byte of // Send a feature report to the device. Set |reportId| to the first byte of
// the report and |data| to the remaining bytes. Set |reportId| to zero if // the report and |data| to the remaining bytes. Set |reportId| to zero if
...@@ -52,7 +53,8 @@ ...@@ -52,7 +53,8 @@
[ [
CallWith=ScriptState, CallWith=ScriptState,
MeasureAs=HidDeviceSendFeatureReport MeasureAs=HidDeviceSendFeatureReport
] Promise<void> sendFeatureReport(octet reportId, BufferSource data); ] Promise<void> sendFeatureReport(
[EnforceRange] octet reportId, BufferSource data);
// Request a feature report from the device. Set |reportId| to the ID of the // Request a feature report from the device. Set |reportId| to the ID of the
// feature report to request, or zero if the device does not use report IDs. // feature report to request, or zero if the device does not use report IDs.
...@@ -61,5 +63,6 @@ ...@@ -61,5 +63,6 @@
[ [
CallWith=ScriptState, CallWith=ScriptState,
MeasureAs=HidDeviceReceiveFeatureReport MeasureAs=HidDeviceReceiveFeatureReport
] Promise<DataView> receiveFeatureReport(octet reportId); ] Promise<DataView> receiveFeatureReport(
[EnforceRange] octet reportId);
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment