Commit fd304d96 authored by Leon Han's avatar Leon Han Committed by Commit Bot

[webnfc] Fix a bug for mock nfc impl

In js, "enum_value ? x : y;" will get y if enum_value is 0, but x is
what we actually want to get in such a case. The correct code should
be "enum_value != null ? x : y".

BUG=520391

Change-Id: Ibe3771d0dc0ece3cd6659aec298306f694a8f0e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037106
Commit-Queue: Rijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Reviewed-by: default avatarRijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Cr-Commit-Position: refs/heads/master@{#739339}
parent 72d89aec
...@@ -132,7 +132,7 @@ function matchesWatchOptions(message, options) { ...@@ -132,7 +132,7 @@ function matchesWatchOptions(message, options) {
function createNDEFError(type) { function createNDEFError(type) {
return { return {
error: type ? error: type != null ?
new device.mojom.NDEFError({errorType: type, errorMessage: ''}) : new device.mojom.NDEFError({errorType: type, errorMessage: ''}) :
null null
}; };
......
This is a testharness.js-based test.
PASS Test that promise is rejected with TypeError if NDEFMessageSource is invalid.
PASS Test that promise is rejected with SyntaxError if NDEFMessageSource contains invalid records.
PASS NDEFWriter.write should fail if user permission is not granted.
PASS NDEFWriter.write should fail if no implementation for NFC Mojo interface is available.
PASS NDEFWriter.write should fail if abort write request before write happends.
PASS NDEFWriter.write should fail if signal's aborted flag is set.
PASS NDEFWriter.write should fail if signal is not an AbortSignal.
PASS Synchronously signaled abort.
PASS NDEFWriter.write should fail when NFC HW is disabled.
PASS NDEFWriter.write should fail when NFC HW is not supported.
PASS Test that WebNFC API is not accessible from iframe context.
PASS NDEFWriter.write should succeed when NFC HW is enabled
PASS NDEFWriter.write NDEFMessage containing text, mime, unknown, url, absolute-url and external records with default NDEFWriteOptions.
PASS NDEFWriter.write NDEFMessage containing embedded records.
PASS Test that NDEFWriter.write succeeds when message is DOMString.
PASS Test that NDEFWriter.write succeeds when message is ArrayBuffer.
PASS Test that NDEFWriter.write succeeds when message is ArrayBufferView.
PASS NDEFWriter.write with 'empty' record should succeed.
PASS Check that default NDEFWriteOptions values are correctly set.
PASS Check that provided NDEFWriteOptions values are correctly converted.
PASS NDEFWriter.write should read data when ignoreRead is false.
PASS NDEFWriter.write should ignore reading data when ignoreRead is true.
PASS NDEFWriter.write should replace all previously configured write operations.
PASS Test that mediaType should be set to 'application/octet-stream' if NDEFRecordInit.record's recordType is 'mime' and NDEFRecordInit.record's mediaType is undefined.
PASS NDEFWriter.write should fail when the NFC device coming up does not expose NDEF technology.
PASS NDEFWriter.write should succeed to write data to an unformatted NFC device when the NDEFWriteOptions.overwrite is false.
PASS NDEFWriter.write should succeed to overwrite the existing data when the NDEFWriteOptions.overwrite is true.
FAIL NDEFWriter.write should fail when there are NDEF records on the NFC device and NDEFWriteOptions.overwrite is false. assert_unreached: Should have rejected: undefined Reached unreachable code
PASS NDEFWriter.write should fail with NetworkError when NFC data transfer fails.
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment