Skip to content

Commit

Permalink
[webnfc] NDEFReadingEvent constructor does not set NDEFRecord#lang
Browse files Browse the repository at this point in the history
Because NDEFRecord#lang is supposed to be set to the document element's
lang attribute in the original web page that constructs/writes this
record, not in the current web page trying to construct an
NDEFReadingEvent instance.

This CL adds a wpt to guarantee that.

BUG=520391

Change-Id: If609455d6411ee886b74ab7557292c37da41eed6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1930451
Reviewed-by: François Beaufort <beaufort.francois@gmail.com>
Commit-Queue: Leon Han <leon.han@intel.com>
Cr-Commit-Position: refs/heads/master@{#719855}
  • Loading branch information
Leon Han authored and chromium-wpt-export-bot committed Nov 28, 2019
1 parent fa2ed15 commit 983bb5e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions web-nfc/NDEFReadingEvent_constructor.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,24 @@
assertWebNDEFMessagesEqual(event.message, new NDEFMessage(message));
}, 'NDEFReadingEvent constructor with valid parameters');

test(() => {
const record_init = createTextRecord(test_text_data);
const event = new NDEFReadingEvent('type',
{serialNumber: '', message: createMessage([record_init])});
assert_equals(event.type, 'type', 'type');
assert_equals(event.serialNumber, '', 'serialNumber');
assert_equals(1, event.message.records.length, 'only 1 record');

const record = new NDEFRecord(record_init);
assert_equals(record.recordType, 'text', 'recordType');
assert_equals(record.mediaType, null, 'mediaType');
assert_equals(record.encoding, 'utf-8', 'encoding');
assert_equals(record.lang, 'en', 'lang');

assert_equals(event.message.records[0].recordType, 'text', 'recordType');
assert_equals(event.message.records[0].mediaType, null, 'mediaType');
assert_equals(event.message.records[0].encoding, 'utf-8', 'encoding');
assert_equals(event.message.records[0].lang, null, 'lang is not set');
}, 'NDEFReadingEvent constructor does not set NDEFRecord#lang for any text records it embeds');

</script>

0 comments on commit 983bb5e

Please sign in to comment.