Bug 1568114 [wpt PR 17410] - [webnfc] Introduce IDLs for NFCReadingEvent and NFCReadingEventInit., a=testonly

Automatic update from web-platform-tests
[webnfc] Introduce IDLs for NFCReadingEvent and NFCReadingEventInit.

This CL introduces IDLs for NFCReadingEvent and NFCReadingEventInit
interfaces, and updates the baseline of relevant wpt tests.
http://w3c.github.io/web-nfc/#dom-nfcreadingevent

The corresponding spec changes were introduced in
https://github.com/w3c/web-nfc/pull/179
https://github.com/w3c/web-nfc/pull/227

BUG=520391

Change-Id: If2090d73ce746208a9e535fe31b6d52a9940d2fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1655092
Commit-Queue: Leon Han <leon.han@intel.com>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Rijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#679910}

--

wpt-commits: 239561ebf7630cd4419dc8cea83606f27062bf87
wpt-pr: 17410
This commit is contained in:
Leon Han 2019-07-30 17:52:34 +00:00 коммит произвёл moz-wptsync-bot
Родитель b22ef3a053
Коммит 26ce814bdc
2 изменённых файлов: 27 добавлений и 9 удалений

Просмотреть файл

@ -11,12 +11,30 @@
assert_throws(new TypeError, () => new NFCReadingEvent('message'));
}, 'NFCReadingEvent constructor without init dict');
test(() => {
const message = createMessage([createJsonRecord(test_json_data)]);
const event = new NFCReadingEvent('type', {serialNumber: null, message: message});
assert_equals(event.serialNumber, '', 'serialNumber');
}, 'NFCReadingEvent constructor with null serialNumber');
test(() => {
const message = createMessage([createJsonRecord(test_json_data)]);
const event = new NFCReadingEvent('type', {message: message});
assert_equals(event.serialNumber, '', 'serialNumber');
}, 'NFCReadingEvent constructor with serialNumber not present');
test(() => {
const event = new NFCReadingEvent('type', {serialNumber: '', message: null});
assert_equals(0, event.message.records.length, 'no records');
assert_equals(0, event.message.url.length, 'empty url');
}, 'NFCReadingEvent constructor with null message');
test(() => {
const message = createMessage([createJsonRecord(test_json_data)]);
const event = new NFCReadingEvent('type', {serialNumber: '', message: message});
assert_equals(event.type, 'type', 'type');
assert_equals(event.serialNumber, '', 'serialNumber');
assertWebNDEFMessagesEqual(event.message, message, 'message');
assertWebNDEFMessagesEqual(event.message, new NDEFMessage(message), 'message');
}, 'NFCReadingEvent constructor with valid parameters');
</script>

Просмотреть файл

@ -56,14 +56,14 @@ function assertWebNDEFMessagesEqual(a, b) {
let recordB = b.records[i];
assert_equals(recordA.recordType, recordB.recordType);
assert_equals(recordA.mediaType, recordB.mediaType);
if (recordA.data instanceof ArrayBuffer) {
assert_array_equals(new Uint8Array(recordA.data),
new Uint8Array(recordB.data));
} else if (typeof recordA.data === 'object') {
assert_object_equals(recordA.data, recordB.data);
} else if (typeof recordA.data === 'number'
|| typeof recordA.data === 'string') {
assert_true(recordA.data == recordB.data);
if (recordA.data() instanceof ArrayBuffer) {
assert_array_equals(new Uint8Array(recordA.data()),
new Uint8Array(recordB.data()));
} else if (typeof recordA.data() === 'object') {
assert_object_equals(recordA.data(), recordB.data());
} else if (typeof recordA.data() === 'number'
|| typeof recordA.data() === 'string') {
assert_true(recordA.data() == recordB.data());
}
}
}