Closed Bug 997075 Opened 9 years ago Closed 9 years ago

NFC: a is undefined in nfc_util.js line 208

Categories

(Firefox OS Graveyard :: NFC, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(blocking-b2g:2.0+, b2g-v2.0 fixed)

RESOLVED FIXED
2.0 S1 (9may)
blocking-b2g 2.0+
Tracking Status
b2g-v2.0 --- fixed

People

(Reporter: allstars.chh, Assigned: allstars.chh)

References

Details

(Whiteboard: [p=1])

Attachments

(1 file)

This is found out by QA, but without debug enabled, so only error log is captured.

E/GeckoConsole(  177): [JavaScript Error: "a is undefined" {file: "app://system.gaiamobile.org/shared/js/nfc_utils.js" line: 208}]
E/GeckoConsole(  177): [JavaScript Error: "NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS: [JavaScript Error: "a is undefined" {file: "app://system.gaiamobile.org/shared/js/nfc_utils.js" line: 208}]'[JavaScript Error: "a is undefined" {file: "app://system.gaiamobile.org/shared/js/nfc_utils.js" line: 208}]' when calling method: [nsIDOMSystemMessageCallback::handleMessage]" {file: "null" line: 0}]
Reproduction steps/scenario would be useful, even if no debug. It was probably actually passed a undefined value as stated...
But even without the log we should ask ourself:
What should the function return when the argument is undefined or null?
Sure, return null, or a throw to the caller. Why an undefined is an argument to a utility function is a good question to answer too.
We can not expect the caller would be careful to use utility functions, I wonder if we could have some methods to tell caller there are something wrong. Or this error is already enough.

Alison, do you have reproduction steps or scenarios? Thanks.
Flags: needinfo?(ashiue)
It's easy to add 
if (!a) {
  return null;
}
to that function,

and it's fairly easy to find out the many callers to use NfcUtils.toUTF8(record.type);
in which type could be null from NDEF spec.
Assignee: nobody → allstars.chh
Flags: needinfo?(ashiue)
Attached file Pull Request
Attachment #8409551 - Flags: review?(alive)
blocking-b2g: --- → 2.0?
Whiteboard: [p=1]
Target Milestone: --- → 1.4 S6 (25apr)
blocking-b2g: 2.0? → 2.0+
Attachment #8409551 - Flags: review?(alive) → review+
Target Milestone: 1.4 S6 (25apr) → 2.0 S1 (9may)
You need to log in before you can comment on or make changes to this bug.