KEMBAR78
Do not use 'any' to define NDEFRecordInit#data by beaufortfrancois · Pull Request #454 · w3c/web-nfc · GitHub
Skip to content

Conversation

@beaufortfrancois
Copy link
Collaborator

@beaufortfrancois beaufortfrancois commented Nov 27, 2019

This PR replaces NDEFRecord any data with NDEFRecordSource data. The new NDEFRecordSource is typedef (DOMString or BufferSource or NDEFMessageInit)

const textRecord = new NDEFRecord({ recordType: "text", data: "foo" });

FIX #453


Preview | Diff

Copy link
Contributor

@leonhsl leonhsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
By the way, could this PR also change NDEFMessage in 'data' column (the 1st table at https://w3c.github.io/web-nfc/#data-mapping) to NDEFMessageInit?

Copy link
Contributor

@leonhsl leonhsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with a nit.

@beaufortfrancois beaufortfrancois merged commit 06671e6 into w3c:gh-pages Nov 27, 2019
@beaufortfrancois beaufortfrancois deleted the remove-any branch November 27, 2019 08:28
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 29, 2019
Use the following union type instead of 'any' to define
NDEFRecordInit#data.
"
typedef (DOMString or BufferSource or NDEFMessageInit)
  NDEFRecordDataSource
"

The spec change:
w3c/web-nfc#454

BUG=520391

Change-Id: Ic917be001d5e3502caeea29ff4a3401ff7197298
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 3, 2019
Use the following union type instead of 'any' to define
NDEFRecordInit#data.
"
typedef (DOMString or BufferSource or NDEFMessageInit)
  NDEFRecordDataSource
"

The spec change:
w3c/web-nfc#454

BUG=520391

Change-Id: Ic917be001d5e3502caeea29ff4a3401ff7197298
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1941083
Reviewed-by: Rijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Commit-Queue: Leon Han <leon.han@intel.com>
Cr-Commit-Position: refs/heads/master@{#720803}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 3, 2019
Use the following union type instead of 'any' to define
NDEFRecordInit#data.
"
typedef (DOMString or BufferSource or NDEFMessageInit)
  NDEFRecordDataSource
"

The spec change:
w3c/web-nfc#454

BUG=520391

Change-Id: Ic917be001d5e3502caeea29ff4a3401ff7197298
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1941083
Reviewed-by: Rijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Commit-Queue: Leon Han <leon.han@intel.com>
Cr-Commit-Position: refs/heads/master@{#720803}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 9, 2019
…RecordInit#data, a=testonly

Automatic update from web-platform-tests
[webnfc] Do not use 'any' to define NDEFRecordInit#data

Use the following union type instead of 'any' to define
NDEFRecordInit#data.
"
typedef (DOMString or BufferSource or NDEFMessageInit)
  NDEFRecordDataSource
"

The spec change:
w3c/web-nfc#454

BUG=520391

Change-Id: Ic917be001d5e3502caeea29ff4a3401ff7197298
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1941083
Reviewed-by: Rijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Commit-Queue: Leon Han <leon.han@intel.com>
Cr-Commit-Position: refs/heads/master@{#720803}

--

wpt-commits: 0ac244337ec64d16f50eb9fe8202413e76ec58c1
wpt-pr: 20527
xeonchen pushed a commit to xeonchen/gecko that referenced this pull request Dec 9, 2019
…RecordInit#data, a=testonly

Automatic update from web-platform-tests
[webnfc] Do not use 'any' to define NDEFRecordInit#data

Use the following union type instead of 'any' to define
NDEFRecordInit#data.
"
typedef (DOMString or BufferSource or NDEFMessageInit)
  NDEFRecordDataSource
"

The spec change:
w3c/web-nfc#454

BUG=520391

Change-Id: Ic917be001d5e3502caeea29ff4a3401ff7197298
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1941083
Reviewed-by: Rijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Commit-Queue: Leon Han <leon.han@intel.com>
Cr-Commit-Position: refs/heads/master@{#720803}

--

wpt-commits: 0ac244337ec64d16f50eb9fe8202413e76ec58c1
wpt-pr: 20527
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Dec 10, 2019
…RecordInit#data, a=testonly

Automatic update from web-platform-tests
[webnfc] Do not use 'any' to define NDEFRecordInit#data

Use the following union type instead of 'any' to define
NDEFRecordInit#data.
"
typedef (DOMString or BufferSource or NDEFMessageInit)
  NDEFRecordDataSource
"

The spec change:
w3c/web-nfc#454

BUG=520391

Change-Id: Ic917be001d5e3502caeea29ff4a3401ff7197298
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1941083
Reviewed-by: Rijubrata Bhaumik <rijubrata.bhaumikintel.com>
Reviewed-by: Yuki Shiino <yukishiinochromium.org>
Commit-Queue: Leon Han <leon.hanintel.com>
Cr-Commit-Position: refs/heads/master{#720803}

--

wpt-commits: 0ac244337ec64d16f50eb9fe8202413e76ec58c1
wpt-pr: 20527

UltraBlame original commit: 84a97b774d4b8cbcd1c9ea0e1d5bc43a0e811d8b
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Dec 10, 2019
…RecordInit#data, a=testonly

Automatic update from web-platform-tests
[webnfc] Do not use 'any' to define NDEFRecordInit#data

Use the following union type instead of 'any' to define
NDEFRecordInit#data.
"
typedef (DOMString or BufferSource or NDEFMessageInit)
  NDEFRecordDataSource
"

The spec change:
w3c/web-nfc#454

BUG=520391

Change-Id: Ic917be001d5e3502caeea29ff4a3401ff7197298
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1941083
Reviewed-by: Rijubrata Bhaumik <rijubrata.bhaumikintel.com>
Reviewed-by: Yuki Shiino <yukishiinochromium.org>
Commit-Queue: Leon Han <leon.hanintel.com>
Cr-Commit-Position: refs/heads/master{#720803}

--

wpt-commits: 0ac244337ec64d16f50eb9fe8202413e76ec58c1
wpt-pr: 20527

UltraBlame original commit: 84a97b774d4b8cbcd1c9ea0e1d5bc43a0e811d8b
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Dec 10, 2019
…RecordInit#data, a=testonly

Automatic update from web-platform-tests
[webnfc] Do not use 'any' to define NDEFRecordInit#data

Use the following union type instead of 'any' to define
NDEFRecordInit#data.
"
typedef (DOMString or BufferSource or NDEFMessageInit)
  NDEFRecordDataSource
"

The spec change:
w3c/web-nfc#454

BUG=520391

Change-Id: Ic917be001d5e3502caeea29ff4a3401ff7197298
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1941083
Reviewed-by: Rijubrata Bhaumik <rijubrata.bhaumikintel.com>
Reviewed-by: Yuki Shiino <yukishiinochromium.org>
Commit-Queue: Leon Han <leon.hanintel.com>
Cr-Commit-Position: refs/heads/master{#720803}

--

wpt-commits: 0ac244337ec64d16f50eb9fe8202413e76ec58c1
wpt-pr: 20527

UltraBlame original commit: 84a97b774d4b8cbcd1c9ea0e1d5bc43a0e811d8b
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 21, 2021
Implement w3c/web-nfc#621, which adds a
hard-coded maximum of 32 NDEFMessage objects that can be in the same
chain.

w3c/web-nfc#454 (and
https://chromium-review.googlesource.com/c/chromium/src/+/1941083 on the
implementation side) ended up creating a cycle between
NDEFRecordInit.data and NDEFMessageInit, as the former can be an
NDEFMessage, which could have one or more entries pointing to the same
NDEFRecordInit. Recursion in Web IDL dictionaries are disallowed, so
this change also fixes some invalid IDL that was present in the spec and
our IDL file.

This CL attempts to optimize or modify other parts of the code as little
as possible, but the the change ended up being a bit big mainly due to
two things:
- Since NDEFRecordInit.data's type is now `any`, we need to do more type
  conversions ourselves in NDEFRecord that we used to get for free when
  using IDL unions. This means attempting to convert a V8 value into one
  or more C++ types and accounting for conversion failures.
- In order to do the above, we need access to v8::Isolate, so several
  functions in NDEFRecord that used to take an ExecutionContext needed
  to be changed to take a ScriptState instead.

The usage of ScriptState and the need to perform multiple type
conversions also caused NDEFReadingEvent's constructor to start
passing one to NDEFMessage, which at the end causes the NDEFRecords
that may get created to contain a proper `lang` attribute rather than
null. This is a user-visible change, but I could not find anything in
the spec supporting the previous behavior.

Bug: 1242274
Change-Id: Ia4de230ea45f63f903760865bf85594f79da9eb7
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 22, 2021
Implement w3c/web-nfc#621, which adds a
hard-coded maximum of 32 NDEFMessage objects that can be in the same
chain.

w3c/web-nfc#454 (and
https://chromium-review.googlesource.com/c/chromium/src/+/1941083 on the
implementation side) ended up creating a cycle between
NDEFRecordInit.data and NDEFMessageInit, as the former can be an
NDEFMessage, which could have one or more entries pointing to the same
NDEFRecordInit. Recursion in Web IDL dictionaries are disallowed, so
this change also fixes some invalid IDL that was present in the spec and
our IDL file.

This CL attempts to optimize or modify other parts of the code as little
as possible, but the the change ended up being a bit big mainly due to
two things:
- Since NDEFRecordInit.data's type is now `any`, we need to do more type
  conversions ourselves in NDEFRecord that we used to get for free when
  using IDL unions. This means attempting to convert a V8 value into one
  or more C++ types and accounting for conversion failures.
- In order to do the above, we need access to v8::Isolate, so several
  functions in NDEFRecord that used to take an ExecutionContext needed
  to be changed to take a ScriptState instead.

The usage of ScriptState and the need to perform multiple type
conversions also caused NDEFReadingEvent's constructor to start
passing one to NDEFMessage, which at the end causes the NDEFRecords
that may get created to contain a proper `lang` attribute rather than
null. This is a user-visible change, but I could not find anything in
the spec supporting the previous behavior.

Bug: 1242274
Change-Id: Ia4de230ea45f63f903760865bf85594f79da9eb7
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 22, 2021
Implement w3c/web-nfc#621, which adds a
hard-coded maximum of 32 NDEFMessage objects that can be in the same
chain.

w3c/web-nfc#454 (and
https://chromium-review.googlesource.com/c/chromium/src/+/1941083 on the
implementation side) ended up creating a cycle between
NDEFRecordInit.data and NDEFMessageInit, as the former can be an
NDEFMessage, which could have one or more entries pointing to the same
NDEFRecordInit. Recursion in Web IDL dictionaries are disallowed, so
this change also fixes some invalid IDL that was present in the spec and
our IDL file.

This CL attempts to optimize or modify other parts of the code as little
as possible, but the the change ended up being a bit big mainly due to
two things:
- Since NDEFRecordInit.data's type is now `any`, we need to do more type
  conversions ourselves in NDEFRecord that we used to get for free when
  using IDL unions. This means attempting to convert a V8 value into one
  or more C++ types and accounting for conversion failures.
- In order to do the above, we need access to v8::Isolate, so several
  functions in NDEFRecord that used to take an ExecutionContext needed
  to be changed to take a ScriptState instead.

The usage of ScriptState and the need to perform multiple type
conversions also caused NDEFReadingEvent's constructor to start
passing one to NDEFMessage, which at the end causes the NDEFRecords
that may get created to contain a proper `lang` attribute rather than
null. This is a user-visible change, but I could not find anything in
the spec supporting the previous behavior.

Bug: 1242274
Change-Id: Ia4de230ea45f63f903760865bf85594f79da9eb7
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 23, 2021
Implement w3c/web-nfc#621, which adds a
hard-coded maximum of 32 NDEFMessage objects that can be in the same
chain.

w3c/web-nfc#454 (and
https://chromium-review.googlesource.com/c/chromium/src/+/1941083 on the
implementation side) ended up creating a cycle between
NDEFRecordInit.data and NDEFMessageInit, as the former can be an
NDEFMessage, which could have one or more entries pointing to the same
NDEFRecordInit. Recursion in Web IDL dictionaries are disallowed, so
this change also fixes some invalid IDL that was present in the spec and
our IDL file.

This CL attempts to optimize or modify other parts of the code as little
as possible, but the the change ended up being a bit big mainly due to
two things:
- Since NDEFRecordInit.data's type is now `any`, we need to do more type
  conversions ourselves in NDEFRecord that we used to get for free when
  using IDL unions. This means attempting to convert a V8 value into one
  or more C++ types and accounting for conversion failures.
- In order to do the above, we need access to v8::Isolate, so several
  functions in NDEFRecord that used to take an ExecutionContext needed
  to be changed to take a ScriptState instead.

The usage of ScriptState and the need to perform multiple type
conversions also caused NDEFReadingEvent's constructor to start
passing one to NDEFMessage, which at the end causes the NDEFRecords
that may get created to contain a proper `lang` attribute rather than
null. This is a user-visible change, but I could not find anything in
the spec supporting the previous behavior.

Bug: 1242274
Change-Id: Ia4de230ea45f63f903760865bf85594f79da9eb7
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 27, 2021
Implement w3c/web-nfc#621, which adds a
hard-coded maximum of 32 NDEFMessage objects that can be in the same
chain.

w3c/web-nfc#454 (and
https://chromium-review.googlesource.com/c/chromium/src/+/1941083 on the
implementation side) ended up creating a cycle between
NDEFRecordInit.data and NDEFMessageInit, as the former can be an
NDEFMessage, which could have one or more entries pointing to the same
NDEFRecordInit. Recursion in Web IDL dictionaries are disallowed, so
this change also fixes some invalid IDL that was present in the spec and
our IDL file.

This CL attempts to optimize or modify other parts of the code as little
as possible, but the the change ended up being a bit big mainly due to
two things:
- Since NDEFRecordInit.data's type is now `any`, we need to do more type
  conversions ourselves in NDEFRecord that we used to get for free when
  using IDL unions. This means attempting to convert a V8 value into one
  or more C++ types and accounting for conversion failures.
- In order to do the above, we need access to v8::Isolate, so several
  functions in NDEFRecord that used to take an ExecutionContext needed
  to be changed to take a ScriptState instead.

The usage of ScriptState and the need to perform multiple type
conversions also caused NDEFReadingEvent's constructor to start
passing one to NDEFMessage, which at the end causes the NDEFRecords
that may get created to contain a proper `lang` attribute rather than
null. This is a user-visible change, but I could not find anything in
the spec supporting the previous behavior.

Bug: 1242274
Change-Id: Ia4de230ea45f63f903760865bf85594f79da9eb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3169656
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/main@{#925263}
blueboxd pushed a commit to blueboxd/chromium-legacy that referenced this pull request Sep 27, 2021
Implement w3c/web-nfc#621, which adds a
hard-coded maximum of 32 NDEFMessage objects that can be in the same
chain.

w3c/web-nfc#454 (and
https://chromium-review.googlesource.com/c/chromium/src/+/1941083 on the
implementation side) ended up creating a cycle between
NDEFRecordInit.data and NDEFMessageInit, as the former can be an
NDEFMessage, which could have one or more entries pointing to the same
NDEFRecordInit. Recursion in Web IDL dictionaries are disallowed, so
this change also fixes some invalid IDL that was present in the spec and
our IDL file.

This CL attempts to optimize or modify other parts of the code as little
as possible, but the the change ended up being a bit big mainly due to
two things:
- Since NDEFRecordInit.data's type is now `any`, we need to do more type
  conversions ourselves in NDEFRecord that we used to get for free when
  using IDL unions. This means attempting to convert a V8 value into one
  or more C++ types and accounting for conversion failures.
- In order to do the above, we need access to v8::Isolate, so several
  functions in NDEFRecord that used to take an ExecutionContext needed
  to be changed to take a ScriptState instead.

The usage of ScriptState and the need to perform multiple type
conversions also caused NDEFReadingEvent's constructor to start
passing one to NDEFMessage, which at the end causes the NDEFRecords
that may get created to contain a proper `lang` attribute rather than
null. This is a user-visible change, but I could not find anything in
the spec supporting the previous behavior.

Bug: 1242274
Change-Id: Ia4de230ea45f63f903760865bf85594f79da9eb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3169656
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/main@{#925263}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 27, 2021
Implement w3c/web-nfc#621, which adds a
hard-coded maximum of 32 NDEFMessage objects that can be in the same
chain.

w3c/web-nfc#454 (and
https://chromium-review.googlesource.com/c/chromium/src/+/1941083 on the
implementation side) ended up creating a cycle between
NDEFRecordInit.data and NDEFMessageInit, as the former can be an
NDEFMessage, which could have one or more entries pointing to the same
NDEFRecordInit. Recursion in Web IDL dictionaries are disallowed, so
this change also fixes some invalid IDL that was present in the spec and
our IDL file.

This CL attempts to optimize or modify other parts of the code as little
as possible, but the the change ended up being a bit big mainly due to
two things:
- Since NDEFRecordInit.data's type is now `any`, we need to do more type
  conversions ourselves in NDEFRecord that we used to get for free when
  using IDL unions. This means attempting to convert a V8 value into one
  or more C++ types and accounting for conversion failures.
- In order to do the above, we need access to v8::Isolate, so several
  functions in NDEFRecord that used to take an ExecutionContext needed
  to be changed to take a ScriptState instead.

The usage of ScriptState and the need to perform multiple type
conversions also caused NDEFReadingEvent's constructor to start
passing one to NDEFMessage, which at the end causes the NDEFRecords
that may get created to contain a proper `lang` attribute rather than
null. This is a user-visible change, but I could not find anything in
the spec supporting the previous behavior.

Bug: 1242274
Change-Id: Ia4de230ea45f63f903760865bf85594f79da9eb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3169656
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/main@{#925263}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Oct 4, 2021
…at can be nested., a=testonly

Automatic update from web-platform-tests
nfc: Limit amount NDEFMessage objects that can be nested.

Implement w3c/web-nfc#621, which adds a
hard-coded maximum of 32 NDEFMessage objects that can be in the same
chain.

w3c/web-nfc#454 (and
https://chromium-review.googlesource.com/c/chromium/src/+/1941083 on the
implementation side) ended up creating a cycle between
NDEFRecordInit.data and NDEFMessageInit, as the former can be an
NDEFMessage, which could have one or more entries pointing to the same
NDEFRecordInit. Recursion in Web IDL dictionaries are disallowed, so
this change also fixes some invalid IDL that was present in the spec and
our IDL file.

This CL attempts to optimize or modify other parts of the code as little
as possible, but the the change ended up being a bit big mainly due to
two things:
- Since NDEFRecordInit.data's type is now `any`, we need to do more type
  conversions ourselves in NDEFRecord that we used to get for free when
  using IDL unions. This means attempting to convert a V8 value into one
  or more C++ types and accounting for conversion failures.
- In order to do the above, we need access to v8::Isolate, so several
  functions in NDEFRecord that used to take an ExecutionContext needed
  to be changed to take a ScriptState instead.

The usage of ScriptState and the need to perform multiple type
conversions also caused NDEFReadingEvent's constructor to start
passing one to NDEFMessage, which at the end causes the NDEFRecords
that may get created to contain a proper `lang` attribute rather than
null. This is a user-visible change, but I could not find anything in
the spec supporting the previous behavior.

Bug: 1242274
Change-Id: Ia4de230ea45f63f903760865bf85594f79da9eb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3169656
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/main@{#925263}

--

wpt-commits: d02695a83d483670b3cef6f2c6e492f698212700
wpt-pr: 30896
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Oct 6, 2021
…at can be nested., a=testonly

Automatic update from web-platform-tests
nfc: Limit amount NDEFMessage objects that can be nested.

Implement w3c/web-nfc#621, which adds a
hard-coded maximum of 32 NDEFMessage objects that can be in the same
chain.

w3c/web-nfc#454 (and
https://chromium-review.googlesource.com/c/chromium/src/+/1941083 on the
implementation side) ended up creating a cycle between
NDEFRecordInit.data and NDEFMessageInit, as the former can be an
NDEFMessage, which could have one or more entries pointing to the same
NDEFRecordInit. Recursion in Web IDL dictionaries are disallowed, so
this change also fixes some invalid IDL that was present in the spec and
our IDL file.

This CL attempts to optimize or modify other parts of the code as little
as possible, but the the change ended up being a bit big mainly due to
two things:
- Since NDEFRecordInit.data's type is now `any`, we need to do more type
  conversions ourselves in NDEFRecord that we used to get for free when
  using IDL unions. This means attempting to convert a V8 value into one
  or more C++ types and accounting for conversion failures.
- In order to do the above, we need access to v8::Isolate, so several
  functions in NDEFRecord that used to take an ExecutionContext needed
  to be changed to take a ScriptState instead.

The usage of ScriptState and the need to perform multiple type
conversions also caused NDEFReadingEvent's constructor to start
passing one to NDEFMessage, which at the end causes the NDEFRecords
that may get created to contain a proper `lang` attribute rather than
null. This is a user-visible change, but I could not find anything in
the spec supporting the previous behavior.

Bug: 1242274
Change-Id: Ia4de230ea45f63f903760865bf85594f79da9eb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3169656
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/main@{#925263}

--

wpt-commits: d02695a83d483670b3cef6f2c6e492f698212700
wpt-pr: 30896
Gabisampaio pushed a commit to Gabisampaio/wpt that referenced this pull request Nov 18, 2021
Implement w3c/web-nfc#621, which adds a
hard-coded maximum of 32 NDEFMessage objects that can be in the same
chain.

w3c/web-nfc#454 (and
https://chromium-review.googlesource.com/c/chromium/src/+/1941083 on the
implementation side) ended up creating a cycle between
NDEFRecordInit.data and NDEFMessageInit, as the former can be an
NDEFMessage, which could have one or more entries pointing to the same
NDEFRecordInit. Recursion in Web IDL dictionaries are disallowed, so
this change also fixes some invalid IDL that was present in the spec and
our IDL file.

This CL attempts to optimize or modify other parts of the code as little
as possible, but the the change ended up being a bit big mainly due to
two things:
- Since NDEFRecordInit.data's type is now `any`, we need to do more type
  conversions ourselves in NDEFRecord that we used to get for free when
  using IDL unions. This means attempting to convert a V8 value into one
  or more C++ types and accounting for conversion failures.
- In order to do the above, we need access to v8::Isolate, so several
  functions in NDEFRecord that used to take an ExecutionContext needed
  to be changed to take a ScriptState instead.

The usage of ScriptState and the need to perform multiple type
conversions also caused NDEFReadingEvent's constructor to start
passing one to NDEFMessage, which at the end causes the NDEFRecords
that may get created to contain a proper `lang` attribute rather than
null. This is a user-visible change, but I could not find anything in
the spec supporting the previous behavior.

Bug: 1242274
Change-Id: Ia4de230ea45f63f903760865bf85594f79da9eb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3169656
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/main@{#925263}
bhearsum pushed a commit to mozilla-releng/staging-firefox that referenced this pull request May 1, 2025
…RecordInit#data, a=testonly

Automatic update from web-platform-tests
[webnfc] Do not use 'any' to define NDEFRecordInit#data

Use the following union type instead of 'any' to define
NDEFRecordInit#data.
"
typedef (DOMString or BufferSource or NDEFMessageInit)
  NDEFRecordDataSource
"

The spec change:
w3c/web-nfc#454

BUG=520391

Change-Id: Ic917be001d5e3502caeea29ff4a3401ff7197298
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1941083
Reviewed-by: Rijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Commit-Queue: Leon Han <leon.han@intel.com>
Cr-Commit-Position: refs/heads/master@{#720803}

--

wpt-commits: 0ac244337ec64d16f50eb9fe8202413e76ec58c1
wpt-pr: 20527
jwidar pushed a commit to jwidar/LatencyZeroGithub that referenced this pull request Sep 16, 2025
…at can be nested., a=testonly

Automatic update from web-platform-tests
nfc: Limit amount NDEFMessage objects that can be nested.

Implement w3c/web-nfc#621, which adds a
hard-coded maximum of 32 NDEFMessage objects that can be in the same
chain.

w3c/web-nfc#454 (and
https://chromium-review.googlesource.com/c/chromium/src/+/1941083 on the
implementation side) ended up creating a cycle between
NDEFRecordInit.data and NDEFMessageInit, as the former can be an
NDEFMessage, which could have one or more entries pointing to the same
NDEFRecordInit. Recursion in Web IDL dictionaries are disallowed, so
this change also fixes some invalid IDL that was present in the spec and
our IDL file.

This CL attempts to optimize or modify other parts of the code as little
as possible, but the the change ended up being a bit big mainly due to
two things:
- Since NDEFRecordInit.data's type is now `any`, we need to do more type
  conversions ourselves in NDEFRecord that we used to get for free when
  using IDL unions. This means attempting to convert a V8 value into one
  or more C++ types and accounting for conversion failures.
- In order to do the above, we need access to v8::Isolate, so several
  functions in NDEFRecord that used to take an ExecutionContext needed
  to be changed to take a ScriptState instead.

The usage of ScriptState and the need to perform multiple type
conversions also caused NDEFReadingEvent's constructor to start
passing one to NDEFMessage, which at the end causes the NDEFRecords
that may get created to contain a proper `lang` attribute rather than
null. This is a user-visible change, but I could not find anything in
the spec supporting the previous behavior.

Bug: 1242274
Change-Id: Ia4de230ea45f63f903760865bf85594f79da9eb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3169656
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/main@{#925263}

--

wpt-commits: d02695a83d483670b3cef6f2c6e492f698212700
wpt-pr: 30896
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not use 'any' to define NDEFRecordInit#data

4 participants