DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (f5d38101ac7c)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
<!DOCTYPE html>
<title>NDEFMessage constructor</title>
<link rel="help" href="https://w3c.github.io/web-nfc/#dom-ndefmessage">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/nfc-helpers.js"></script>
<script>

  test(() => {
    assert_equals(NDEFMessage.length, 1);
    assert_throws(new TypeError, () => new NDEFMessage());
  }, 'NDEFMessage constructor without init dict');

  test(() => {
    const message = new NDEFMessage(null);
    assert_equals(message.url.length, 0, 'empty url');
    assert_equals(message.records.length, 0, 'empty records');
  }, 'NDEFMessage constructor with null init dict');

  test(() => {
    const message = new NDEFMessage(
        createMessage([createTextRecord(test_text_data)]));
    assert_equals(message.records.length, 1, 'one text record');
    assert_equals(message.records[0].recordType, 'text', 'messageType');
    assert_equals(message.records[0].mediaType, null, 'mediaType');
    assert_equals(message.records[0].encoding, 'utf-8', 'encoding');
    assert_equals(message.records[0].lang, 'en', 'lang');
    assert_true(message.records[0].data instanceof DataView,
        'data returns a DataView');
    const decoder = new TextDecoder();
    assert_equals(decoder.decode(message.records[0].data), test_text_data,
        'data contains the same text content');
  }, 'NDEFMessage constructor with a text record');

</script>