Skip to content

Commit

Permalink
Bug 1609065 [wpt PR 21157] - [webnfc] Support writing/reading local t…
Browse files Browse the repository at this point in the history
…ype records, a=testonly

Automatic update from web-platform-tests
[webnfc] Support writing/reading local type records

Some notable points:

1) Local type in WebNFC APIs is always prefixed by ':', but, the ':'
   will be omitted when it's actually written into the nfc tag.
     ":act"  --> "act" to be written as the TYPE field into the nfc tag.
     ":text" --> "text"
   The reading direction is vice versa.
     "act"  --> ":act" to be exposed as NDEFRecord#recordType.
     "text" --> ":text"

2) Only "smart-poster", external, and local type records are supposed to
   be able to carry a ndef message as payload.

3) Local type is only expected to exist inside a ndef message that is
   another ndef record's payload. Top level ndef message is not allowed
   to have a local type record.

The spec changes:
w3c/web-nfc#491
w3c/web-nfc#493
w3c/web-nfc#495
w3c/web-nfc#502
w3c/web-nfc#506

BUG=520391

Change-Id: Ic2890c031109aa583437ac93a8901ff71992af78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1996946
Reviewed-by: Daniel Cheng <dchengchromium.org>
Reviewed-by: Reilly Grant <reillygchromium.org>
Commit-Queue: Leon Han <leon.hanintel.com>
Cr-Commit-Position: refs/heads/master{#737290}

--

wpt-commits: a1652e2faab5c92db0d3a2523ef9a94003e1e8f5
wpt-pr: 21157

UltraBlame original commit: db0bf96c8b8840896e7a762605492f3f55594981
  • Loading branch information
marco-c committed Feb 12, 2020
1 parent 0d40320 commit 388b437
Show file tree
Hide file tree
Showing 4 changed files with 1,951 additions and 319 deletions.
28 changes: 28 additions & 0 deletions testing/web-platform/tests/resources/chromium/nfc-mock.js
Expand Up @@ -79,6 +79,34 @@ record
.
recordType
.
startsWith
(
'
:
'
)
)
{
nfcRecord
.
category
=
device
.
mojom
.
NDEFRecordTypeCategory
.
kLocal
;
}
else
if
(
record
.
recordType
.
search
(
'
Expand Down
151 changes: 123 additions & 28 deletions testing/web-platform/tests/web-nfc/NDEFReader_scan.https.html
Expand Up @@ -1295,9 +1295,12 @@
/
The
message
in
the
event
contains
only
an
the
external
type
record
Expand Down Expand Up @@ -1331,7 +1334,7 @@
.
com
:
payloadIsMessage
containsLocalRecord
'
'
recordType
Expand All @@ -1344,22 +1347,15 @@
external
type
record
'
s
payload
is
a
message
which
contains
only
a
text
the
local
type
record
.
const
embeddedRecords
=
assert_equals
(
event
.
message
Expand All @@ -1372,42 +1368,82 @@
toRecords
(
)
;
assert_equals
(
embeddedRecords
.
length
1
)
;
assert_equals
(
embeddedRecords
event
.
message
.
records
[
0
]
.
toRecords
(
)
[
0
]
.
recordType
'
text
:
containsTextRecord
'
'
recordType
'
)
;
/
/
The
local
type
record
contains
only
the
text
record
.
assert_equals
(
embeddedRecords
event
.
message
.
records
[
0
]
.
mediaType
null
toRecords
(
)
[
0
]
.
toRecords
(
)
[
0
]
.
recordType
'
text
'
mediaType
'
recordType
'
)
;
Expand All @@ -1425,7 +1461,25 @@
.
decode
(
embeddedRecords
event
.
message
.
records
[
0
]
.
toRecords
(
)
[
0
]
.
toRecords
(
)
[
0
]
Expand Down Expand Up @@ -1463,8 +1517,32 @@
}
)
;
/
/
An
external
type
record
-
-
contains
-
>
a
local
type
record
-
-
contains
-
>
a
text
record
.
const
payloadMessage
messageContainText
=
createMessage
(
Expand All @@ -1477,6 +1555,23 @@
)
;
const
messageContainLocal
=
createMessage
(
[
createRecord
(
'
:
containsTextRecord
'
messageContainText
)
]
)
;
const
message
=
createMessage
Expand All @@ -1489,9 +1584,9 @@
.
com
:
payloadIsMessage
containsLocalRecord
'
payloadMessage
messageContainLocal
)
]
)
Expand Down

0 comments on commit 388b437

Please sign in to comment.