New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 718349 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Email to this user bounced
Closed: May 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

[webnfc]nfc.push should throw SyntaxError when NFCMessage is invalid

Reported by canx....@intel.com, May 4 2017

Issue description

Steps to reproduce the problem:
Test Case: https://thewebera.github.io/web-test-suite/web-nfc/nfc/nfc_push_exceptions.https.html
Tese Name: Test that promise is rejected with SyntaxError if NFCMessage is invalid.
1.Set invalid NFCMessage

What is the expected behavior?
SyntaxError is thrown.

What went wrong?
TypeError is thrown.

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 60.0.3087.3  Channel: canary
OS Version: Nexus 7(Android 5.1)
Flash Version: Shockwave Flash 25.0 r0

According to the spec: 10.7.1.3 Mapping empty record to NDEF(https://w3c.github.io/web-nfc/#mapping-string-to-ndef)
Description: 
If record.data is not a string or number, throw a "SyntaxError" exception and abort these steps.
If record.mediaType is not a string or starts with "text/", then throw a "SyntaxError" exception and abort these steps. In addition, UAs may check that record.mediaType is an IANA registered media type for text. If not, then the UA may throw a "SyntaxError" exception and abort these steps.
 
canx.cao@ Could you provide examples for invalid messages?
Components: Blink>NFC
Owner: alexande...@intel.com
e.g. Mapping string to NDEF, if record.mediaType is not a string or starts with "text/", then throw a "SyntaxError" exception.

'{recordType: "text", mediaType: "application/json", data: "test text data"}'

Actually, it throws "TypeError".
Status: Started (was: Unconfirmed)
We need few more fixes for map-to-ndef algorithm, I will create issue and PR for the spec.
Created https://github.com/w3c/web-nfc/issues/116 and https://github.com/w3c/web-nfc/pull/115

Will update implementation as soon as spec is updated.
Project Member

Comment 6 by bugdroid1@chromium.org, May 24 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f33e1d034eabce26a32bf9b05f3ca29a924fd237

commit f33e1d034eabce26a32bf9b05f3ca29a924fd237
Author: alexander.shalamov <alexander.shalamov@intel.com>
Date: Wed May 24 12:52:17 2017

[webnfc] Align nfc.push operation with the specification

This CL aligns error handling for nfc.push operation, with the
latest changes in the specification. Whenever invlid type is
provided, resulting promise is rejected with 'TypeError' exception.
When error happens due to the invalid sytnax or tokens, resulting
promise is rejected with 'SyntaxError' exception. Layout test
updated accordingly.

BUG= 718349 

Review-Url: https://codereview.chromium.org/2885813002
Cr-Commit-Position: refs/heads/master@{#474265}

[modify] https://crrev.com/f33e1d034eabce26a32bf9b05f3ca29a924fd237/third_party/WebKit/LayoutTests/nfc/push.html
[modify] https://crrev.com/f33e1d034eabce26a32bf9b05f3ca29a924fd237/third_party/WebKit/Source/modules/nfc/NFC.cpp
[modify] https://crrev.com/f33e1d034eabce26a32bf9b05f3ca29a924fd237/third_party/WebKit/Source/modules/nfc/NFC.h

Status: Fixed (was: Started)

Comment 8 by canx....@intel.com, Jun 1 2017

I verified this issue with Chrome 61.0.3116.0, this issue cannot reproduce.
Closed.
Status: Verified (was: Fixed)
canx.cao@ thanks for verifying

Sign in to add a comment