Use sequence instead of map for data filters - #545
Conversation
02ba744 to
3e350a0
Compare
|
Note that CI should succeed once #546 is merged. |
3e350a0 to
e3139c1
Compare
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
| 1. Let |canonicalizedDataFilter| be the result of <a | ||
| for="BluetoothDataFilterInit">canonicalizing</a> |dataFilter|, | ||
| present and | ||
| <code>|filter|.{{BluetoothLEScanFilterInit/manufacturerData}}.length === 0</code>, |
There was a problem hiding this comment.
A nit, as was pointed out to me on the most recent specifications I worked on, the correct syntax for referring to a member of a dictionary is filter["manufacturerData"] rather than filter.manufacturerData. We should do a pass to fix this over the whole specification but might as well avoid introducing new examples of the old style.
| [ | ||
| { | ||
| manufacturerData: [ | ||
| { companyIdentifier: 17, dataPrefix: new Uint8Array([1, 2, 3]) }, |
There was a problem hiding this comment.
Put companyIdentifier and dataPrefix on separate lines in this and the next two examples to avoid this table column becoming too wide.
| 1. For each |manufacturerData| in | ||
| <code>|filter|.{{BluetoothLEScanFilterInit/manufacturerData}}</code>, do the following sub-steps: | ||
| 1. If <code>|manufacturerData|.{{BluetoothManufacturerDataFilterInit/companyIdentifier}}</code> | ||
| is present in |canonicalizedFilter|.manufacturerData, |
There was a problem hiding this comment.
We should probably be more specific about what "present" means here. Something like, "If there exists a object |existing| in |canonicalizedFilter|["manufacturerData"] where |existing|["companyIdentifier"] === |manufacturerData|["companyIdentifier"], throw..."
| for="BluetoothDataFilterInit">canonicalizing</a> |manufacturerData|, | ||
| <a>converted to an ECMAScript value</a>. If this throws an exception, | ||
| propagate that exception and abort these steps. | ||
| 1. Call <a abstract-op>CreateDataProperty</a> |
There was a problem hiding this comment.
Since canonicalizedFilter["manufacturerData"] is now a sequence rather than an object we can append to it.
| @@ -1400,51 +1431,42 @@ returned from the following steps: | |||
| <code><var>filter</var>.namePrefix</code>. | |||
| 1. Set <code>|canonicalizedFilter|.manufacturerData</code> to `{}`. | |||
There was a problem hiding this comment.
Initialize canonicalizedFilter["manufacturerData"] to an empty array rather than an empty object.
| (|canonicalizedFilter|.manufacturerData, | ||
| <code>|manufacturerData|.{{BluetoothManufacturerDataFilterInit/companyIdentifier}}</code>, | ||
| |canonicalizedManufacturerDataFilter|). | ||
| 1. Set <code>|canonicalizedFilter|.serviceData</code> to `{}`. |
| <a>converted to an ECMAScript value</a>. If this throws an exception, | ||
| propagate that exception and abort these steps. | ||
| 1. Call <a | ||
| abstract-op>CreateDataProperty</a>(|canonicalizedFilter|.serviceData, |
| type:enum-value; for:PermissionName; text:"bluetooth" | ||
| spec: permissions-1 | ||
| type: enum-value | ||
| text: "bluetooth" |
There was a problem hiding this comment.
In #546 you only removed the conflicting enum value above. Is this change also necessary?
There was a problem hiding this comment.
It's not anymore. Thanks for catching!
e3139c1 to
509e088
Compare
beaufortfrancois
left a comment
There was a problem hiding this comment.
Thanks for the review!
| [ | ||
| { | ||
| manufacturerData: [ | ||
| { companyIdentifier: 17, dataPrefix: new Uint8Array([1, 2, 3]) }, |
| 1. Let |canonicalizedDataFilter| be the result of <a | ||
| for="BluetoothDataFilterInit">canonicalizing</a> |dataFilter|, | ||
| present and | ||
| <code>|filter|.{{BluetoothLEScanFilterInit/manufacturerData}}.length === 0</code>, |
| 1. For each |manufacturerData| in | ||
| <code>|filter|.{{BluetoothLEScanFilterInit/manufacturerData}}</code>, do the following sub-steps: | ||
| 1. If <code>|manufacturerData|.{{BluetoothManufacturerDataFilterInit/companyIdentifier}}</code> | ||
| is present in |canonicalizedFilter|.manufacturerData, |
| type:enum-value; for:PermissionName; text:"bluetooth" | ||
| spec: permissions-1 | ||
| type: enum-value | ||
| text: "bluetooth" |
There was a problem hiding this comment.
It's not anymore. Thanks for catching!
| for="BluetoothDataFilterInit">canonicalizing</a> |manufacturerData|, | ||
| <a>converted to an ECMAScript value</a>. If this throws an exception, | ||
| propagate that exception and abort these steps. | ||
| 1. Call <a abstract-op>CreateDataProperty</a> |
| (|canonicalizedFilter|.manufacturerData, | ||
| <code>|manufacturerData|.{{BluetoothManufacturerDataFilterInit/companyIdentifier}}</code>, | ||
| |canonicalizedManufacturerDataFilter|). | ||
| 1. Set <code>|canonicalizedFilter|.serviceData</code> to `{}`. |
| <a>converted to an ECMAScript value</a>. If this throws an exception, | ||
| propagate that exception and abort these steps. | ||
| 1. Call <a | ||
| abstract-op>CreateDataProperty</a>(|canonicalizedFilter|.serviceData, |
| @@ -1400,51 +1431,42 @@ returned from the following steps: | |||
| <code><var>filter</var>.namePrefix</code>. | |||
| 1. Set <code>|canonicalizedFilter|.manufacturerData</code> to `{}`. | |||
953f24d to
e7a6e1a
Compare
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
SHA: d9eeae5 Reason: push, by @beaufortfrancois Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: d9eeae5 Reason: push, by @beaufortfrancois Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: d9eeae5 Reason: push, by @beaufortfrancois Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: d9eeae5 Reason: push, by @beaufortfrancois Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2830933 Commit-Queue: François Beaufort <beaufort.francois@gmail.com> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/master@{#879284}
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2830933 Commit-Queue: François Beaufort <beaufort.francois@gmail.com> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/master@{#879284}
This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2830933 Commit-Queue: François Beaufort <beaufort.francois@gmail.com> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/master@{#879284}
…ilter when requesting device, a=testonly Automatic update from web-platform-tests [Web Bluetooth] Add `manufacturerData` filter when requesting device This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2830933 Commit-Queue: François Beaufort <beaufort.francois@gmail.com> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/master@{#879284} -- wpt-commits: d50983bfca33b58be57894725b190b8c1a011ddc wpt-pr: 28718
…ilter when requesting device, a=testonly Automatic update from web-platform-tests [Web Bluetooth] Add `manufacturerData` filter when requesting device This CL adds support for new manufacturerData filter so that developers can request Bluetooth LE devices based on manufacturer specific data (company identifier and data). Spec: WebBluetoothCG/web-bluetooth#545 Test: https://manufacturer-data.glitch.me/ Bug: 707635 Change-Id: I63b80812f35c8f0f557ceaf53632d0d6d2d52b9b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2830933 Commit-Queue: François Beaufort <beaufort.francois@gmail.com> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/master@{#879284} -- wpt-commits: d50983bfca33b58be57894725b190b8c1a011ddc wpt-pr: 28718
The more I'm playing with manufacturer data filters, the more I think we should go with a
sequenceinstead of amapin BluetoothLEScanFilterInit for bothmanufacturerDataandserviceData.Because users can have different strings to express the same uint16 ('0' and '00' for instance), we'll have to check for the unicity of the key which is what we're doing already with a sequence.
Moreover, having a required
companyIdentifierdictionary key seems more readable than a simple object key.I've added some code samples below to give you an idea of what I'm experiencing.
And here's what I'm proposing:
@reillyeon What do you think?
Preview | Diff