Closed Bug 1174071 Opened 9 years ago Closed 9 years ago

[bluetooth2] Remove 'required' keyword for Bluetooth*EventInit dictionary members.

Categories

(Firefox OS Graveyard :: Bluetooth, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(firefox41 fixed)

RESOLVED FIXED
FxOS-S1 (26Jun)
Tracking Status
firefox41 --- fixed

People

(Reporter: yrliou, Assigned: yrliou)

References

Details

(Whiteboard: [webbt-api])

Attachments

(1 file, 2 obsolete files)

Currently mochitest-3 will fail since we didn't provide 'required' members in the eventInit for some bluetooth events, for example, BluetoothPairingEvent.
And some of these members cannot be constructed by JS, so we cannot assign a valid value in the mochitest.
According to Olli's suggestion in Bug 1167064 Comment 26, we should remove those required limitation for these members.
As I stated in Bug 1167064 Comment 27, I don't see strong reasons that we need to make this restriction for web pages and especially we cannot restrict it for some cases.
IMO, it's reasonable to remove all 'required' members in our eventInit dictionaries in our case.
Comment on attachment 8621483 [details] [diff] [review]
Bug 1174071 - Remove 'required' keyword for Bluetooth*EventInit dictionary members.

Review of attachment 8621483 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with comment addressed.

::: dom/bluetooth/bluetooth2/BluetoothLeDeviceEvent.cpp
@@ +95,5 @@
> +  const uint8_t* data = nullptr;
> +  size_t length = 0;
> +
> +  if (aEventInitDict.mScanRecord.WasPassed()) {
> +    const auto& a = aEventInitDict.mScanRecord.Value();

Replace |a| with a meaningful name instead.

::: dom/webidl/BluetoothLeDeviceEvent.webidl
@@ +20,1 @@
>    short  rssi = 0;

nit: remove extra space.
Attachment #8621483 - Flags: review?(btian) → review+
Hi Boris,

Would it be OK for asking your help to review my patch?
It's came from the question I asked in Bug 1167064.
If you're not available for doing reviews, please feel free to let me know.

Thanks,
Jocelyn
Attachment #8621483 - Attachment is obsolete: true
Attachment #8621524 - Flags: review?(bzbarsky)
Comment on attachment 8621524 [details] [diff] [review]
Bug 1174071 - Remove 'required' keyword for Bluetooth*EventInit dictionary members. r=btian

r=me assuming creating an empty array buffer with null data pointer does the right thing.  Please add some tests for these constructors!
Attachment #8621524 - Flags: review?(bzbarsky) → review+
(In reply to Not doing reviews right now from comment #4)
> Comment on attachment 8621524 [details] [diff] [review]
> Bug 1174071 - Remove 'required' keyword for Bluetooth*EventInit dictionary
> members. r=btian
> 
> r=me assuming creating an empty array buffer with null data pointer does the
> right thing.  Please add some tests for these constructors!

Hi Boris,

Thanks for your comment, I revisited this part, and I think using ArrayBuffer? here might be more reasonable.
I am thinking of revising the constructor of LeDeviceEvent to only create array buffer if it is mScanRecord is not null.
How does this sound to you?

About the test, doesn't test_all_synthetic_events.html test these constructors?

Besides this, in bluetooth component, we use marionette tests to test the flow from enable/disable BT to pairing with devices, which will fire |BluetoothPairingEvent| and |BluetoothAttributeEvent| during the test flow, but we have not yet cover |LeDeviceEvent| and |GattCharacteristicEvent|.

Thanks,
Jocelyn
Flags: needinfo?(bzbarsky)
(In reply to Jocelyn Liu [:jocelyn] [:joliu] from comment #5)
> 
> Hi Boris,
> 
> Thanks for your comment, I revisited this part, and I think using
> ArrayBuffer? here might be more reasonable.
> I am thinking of revising the constructor of LeDeviceEvent to only create
> array buffer if it is mScanRecord is not null.
typo here, sorry, I mean 'only create the array buffer if mScanRecord is not null'.
> How does this sound to you?

I don't have a strong opinion, because I'm not sure how this API is used in practice.  But yes, making this nullable with default null would certainly work. 

> doesn't test_all_synthetic_events.html test these constructors

Well, it tests that you can run them.  It doesn't test anything about what the result looks like, right?  e.g. it would not check that you in fact got an empty arraybuffer.
Flags: needinfo?(bzbarsky)
(In reply to Not doing reviews right now from comment #7)
> > How does this sound to you?
> 
> I don't have a strong opinion, because I'm not sure how this API is used in
> practice.  But yes, making this nullable with default null would certainly
> work. 
> 
> > doesn't test_all_synthetic_events.html test these constructors
> 
> Well, it tests that you can run them.  It doesn't test anything about what
> the result looks like, right?  e.g. it would not check that you in fact got
> an empty arraybuffer.

Yes, you were right, thanks for the explanation.
I suppose this would probably be done by adding test items in test_eventctors.html?
Would it be OK to split this part into a followup bug?

Thanks,
Jocelyn
(In reply to Jocelyn Liu [:jocelyn] [:joliu] from comment #8)
> (In reply to Not doing reviews right now from comment #7)
> > > How does this sound to you?
> > 
> > I don't have a strong opinion, because I'm not sure how this API is used in
> > practice.  But yes, making this nullable with default null would certainly
> > work. 
> > 
> > > doesn't test_all_synthetic_events.html test these constructors
> > 
> > Well, it tests that you can run them.  It doesn't test anything about what
> > the result looks like, right?  e.g. it would not check that you in fact got
> > an empty arraybuffer.
> 
> Yes, you were right, thanks for the explanation.
> I suppose this would probably be done by adding test items in
> test_eventctors.html?
> Would it be OK to split this part into a followup bug?
> 
> Thanks,
> Jocelyn

The reason I would like to do it in a followup bug is because we didn't cover all BT events in this bug.
I would like to file a bug to add all BT events into test_eventctors.html.

Use ni here in case you didn't see the bug mail.

Thanks,
Jocelyn
Flags: needinfo?(bzbarsky)
Followup bug is fine.
Flags: needinfo?(bzbarsky)
Blocks: 1174312
- Make "LeDeviceEvent.scanRecord" nullable.
- Bug 1174312 has been filed for testing event constructions.

Thanks for your time, Ben and Boris.
Attachment #8621524 - Attachment is obsolete: true
No try server result since bluetooth2 won't be build on try server.
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/78a1a93d3904
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → NGA S3 (26Jun)
As NGA Program Manager suggested, let's replace the NGA-Sx milestones with FxOS-Sx ones (more generic ones), once Bug 1174794 has already landed
Target Milestone: NGA S3 (26Jun) → FxOS-S1 (26Jun)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: