Revision cdf5b3962f33d0a05af040097173d8cc827a7d73 authored by Trent Apted on 12 March 2018, 04:02:04 UTC, committed by Blink WPT Bot on 12 March 2018, 04:10:37 UTC
This reverts commit af1c15b16f99d290799c83d34c111bce52447026.

Reason for revert: suspected for persistent failures on Win7 Tests (dbg)(1)

Unexpected Failures:
* external/wpt/bluetooth/server/getPrimaryServices/blocklisted-services.https.html
* external/wpt/bluetooth/service/getCharacteristic/gen-blocklisted-characteristic.https.html
* external/wpt/bluetooth/service/getCharacteristics/blocklisted-characteristics.https.html
* external/wpt/bluetooth/service/getCharacteristics/gen-blocklisted-characteristic-with-uuid.https.html
* external/wpt/upgrade-insecure-requests/link-upgrade.sub.https.html

since

https://ci.chromium.org/buildbot/chromium.win/Win7%20Tests%20%28dbg%29%281%29/66761

errors like

15:59:42.310 5904 worker/4 external/wpt/bluetooth/service/getCharacteristics/gen-blocklisted-characteristic-with-uuid.https.html crashed, (stderr lines):
15:59:42.311 5904   CONSOLE MESSAGE: line 255: Web Bluetooth is experimental on this platform. See https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md
15:59:42.327 1300 [1691/5755] external/wpt/bluetooth/service/getCharacteristics/gen-blocklisted-characteristic-with-uuid.https.html failed unexpectedly (content_shell crashed [pid=5644])

Original change's description:
> bluetooth: Use DeviceUUID in FakeBluetooth
>
> This change refactors the Web Bluetooth test API to use the
> DeviceUUIDs helper class defined in BluetoothDevice. Additionally,
> this change finishes the implementation of SimulateGATTServicesChanged,
> and as a result, tests are updated to set the next discovery response
> before calling this interface.
>
> BUG=719826
>
> Change-Id: I0f986eb7afe6fbf7ebaa80ac4b633d46a027b80d
> Reviewed-on: https://chromium-review.googlesource.com/939984
> Commit-Queue: Ovidio Henriquez <odejesush@chromium.org>
> Reviewed-by: Giovanni Ortuño Urquidi <ortuno@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#541577}

TBR=cco3@chromium.org,ortuno@chromium.org,odejesush@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 719826
Change-Id: I02bb7066c6f1282191f7a24e91b3d2c5614b8104
Reviewed-on: https://chromium-review.googlesource.com/958741
Reviewed-by: Trent Apted <tapted@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542421}
1 parent 9c9d8f2
Raw File
RTCDTMFSender-ontonechange.https.html
<!doctype html>
<meta charset=utf-8>
<title>RTCDTMFSender.prototype.ontonechange</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script src="RTCDTMFSender-helper.js"></script>
<script>
  'use strict';

  // Test is based on the following editor draft:
  // https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html

  // The following helper functions are called from RTCPeerConnection-helper.js
  //   generateAnswer

  // The following helper functions are called from RTCDTMFSender-helper.js
  //   test_tone_change_events
  //   getTransceiver

  /*
    7.  Peer-to-peer DTMF
      partial interface RTCRtpSender {
        readonly attribute RTCDTMFSender? dtmf;
      };

      interface RTCDTMFSender : EventTarget {
        void insertDTMF(DOMString tones,
                        optional unsigned long duration = 100,
                        optional unsigned long interToneGap = 70);
                 attribute EventHandler ontonechange;
        readonly attribute DOMString    toneBuffer;
      };

      [Constructor(DOMString type, RTCDTMFToneChangeEventInit eventInitDict)]
      interface RTCDTMFToneChangeEvent : Event {
        readonly attribute DOMString tone;
      };
   */

  /*
    7.2.  insertDTMF
      11. If a Playout task is scheduled to be run; abort these steps; otherwise queue
          a task that runs the following steps (Playout task):
        3.  If toneBuffer is an empty string, fire an event named tonechange with an
            empty string at the RTCDTMFSender object and abort these steps.
        4.  Remove the first character from toneBuffer and let that character be tone.
        6.  Queue a task to be executed in duration + interToneGap ms from now that
            runs the steps labelled Playout task.
        7.  Fire an event named tonechange with a string consisting of tone at the
            RTCDTMFSender object.
   */
  test_tone_change_events((t, dtmfSender) => {
    dtmfSender.insertDTMF('123');
  }, [
    ['1', '23', 0],
    ['2', '3', 170],
    ['3', '', 170],
    ['', '', 170]
  ], 'insertDTMF() with default duration and intertoneGap should fire tonechange events at the expected time');

  test_tone_change_events((t, dtmfSender) => {
    dtmfSender.insertDTMF('abc', 100, 70);
  }, [
    ['A', 'BC', 0],
    ['B', 'C', 170],
    ['C', '', 170],
    ['', '', 170]
  ], 'insertDTMF() with explicit duration and intertoneGap should fire tonechange events at the expected time');

  /*
    7.2.  insertDTMF
      10. If toneBuffer is an empty string, abort these steps.
   */
  async_test(t => {
    createDtmfSender()
    .then(dtmfSender => {
      dtmfSender.addEventListener('tonechange',
        t.unreached_func('Expect no tonechange event to be fired'));

      dtmfSender.insertDTMF('', 100, 70);

      t.step_timeout(t.step_func_done(), 300);
    })
    .catch(t.step_func(err => {
      assert_unreached(`Unexpected promise rejection: ${err}`);
    }));
  }, `insertDTMF('') should not fire any tonechange event, including for '' tone`);

  /*
    7.2.  insertDTMF
      8. If the value of the duration parameter is less than 40, set it to 40.
         If, on the other hand, the value is greater than 6000, set it to 6000.
   */
  test_tone_change_events((t, dtmfSender) => {
      dtmfSender.insertDTMF('ABC', 10, 70);
  }, [
    ['A', 'BC', 0],
    ['B', 'C', 110],
    ['C', '', 110],
    ['', '', 110]
  ], 'insertDTMF() with duration less than 40 should be clamped to 40');

  /*
    7.2.  insertDTMF
      9. If the value of the interToneGap parameter is less than 30, set it to 30.
   */
  test_tone_change_events((t, dtmfSender) => {
    dtmfSender.insertDTMF('ABC', 100, 10);
  }, [
    ['A', 'BC', 0],
    ['B', 'C', 130],
    ['C', '', 130],
    ['', '', 130]
  ],
  'insertDTMF() with interToneGap less than 30 should be clamped to 30');

  /*
    [w3c/webrtc-pc#1373]
    This step is added to handle the "," character correctly. "," supposed to delay the next
    tonechange event by 2000ms.

    7.2.  insertDTMF
      11.5. If tone is "," delay sending tones for 2000 ms on the associated RTP media
            stream, and queue a task to be executed in 2000 ms from now that runs the
            steps labelled Playout task.
   */
  test_tone_change_events((t, dtmfSender) => {
    dtmfSender.insertDTMF('A,B', 100, 70);

  }, [
    ['A', ',B', 0],
    [',', 'B', 170],
    ['B', '', 2000],
    ['', '', 170]
  ], 'insertDTMF with comma should delay next tonechange event for a constant 2000ms');

  /*
    7.2.  insertDTMF
      11.1. If transceiver.stopped is true, abort these steps.
   */
  test_tone_change_events((t, dtmfSender, pc) => {
    const transceiver = getTransceiver(pc);
    dtmfSender.addEventListener('tonechange', ev => {
      if(ev.tone === 'B') {
        transceiver.stop();
      }
    });

    dtmfSender.insertDTMF('ABC', 100, 70);
  }, [
    ['A', 'BC', 0],
    ['B', 'C', 170]
  ], 'insertDTMF() with transceiver stopped in the middle should stop future tonechange events from firing');

  /*
    7.2.  insertDTMF
      3.  If a Playout task is scheduled to be run, abort these steps;
          otherwise queue a task that runs the following steps (Playout task):
   */
  test_tone_change_events((t, dtmfSender) => {
    dtmfSender.addEventListener('tonechange', ev => {
      if(ev.tone === 'B') {
        // Set a timeout to make sure the toneBuffer
        // is changed after the tonechange event listener
        // by test_tone_change_events is called.
        // This is to correctly test the expected toneBuffer.
        t.step_timeout(() => {
          dtmfSender.insertDTMF('12', 100, 70);
        }, 10);
      }
    });

    dtmfSender.insertDTMF('ABC', 100, 70);
  }, [
    ['A', 'BC', 0],
    ['B', 'C', 170],
    ['1', '2', 170],
    ['2', '', 170],
    ['', '', 170]
  ], 'Calling insertDTMF() in the middle of tonechange events should cause future tonechanges to be updated to new tones');


  /*
    7.2.  insertDTMF
      3.  If a Playout task is scheduled to be run, abort these steps;
          otherwise queue a task that runs the following steps (Playout task):
   */
  test_tone_change_events((t, dtmfSender) => {
    dtmfSender.addEventListener('tonechange', ev => {
      if(ev.tone === 'B') {
        t.step_timeout(() => {
          dtmfSender.insertDTMF('12', 100, 70);
          dtmfSender.insertDTMF('34', 100, 70);
        }, 10);
      }
    });

    dtmfSender.insertDTMF('ABC', 100, 70);
  }, [
    ['A', 'BC', 0],
    ['B', 'C', 170],
    ['3', '4', 170],
    ['4', '', 170],
    ['', '', 170]
  ], 'Calling insertDTMF() multiple times in the middle of tonechange events should cause future tonechanges to be updated the last provided tones');

  /*
    7.2.  insertDTMF
      3.  If a Playout task is scheduled to be run, abort these steps;
          otherwise queue a task that runs the following steps (Playout task):
   */
  test_tone_change_events((t, dtmfSender) => {
    dtmfSender.addEventListener('tonechange', ev => {
      if(ev.tone === 'B') {
        t.step_timeout(() => {
          dtmfSender.insertDTMF('');
        }, 10);
      }
    });

    dtmfSender.insertDTMF('ABC', 100, 70);
  }, [
    ['A', 'BC', 0],
    ['B', 'C', 170],
    ['', '', 170]
  ], `Calling insertDTMF('') in the middle of tonechange events should stop future tonechange events from firing`);

  /*
    7.2.  insertDTMF
      11.2.  If transceiver.currentDirection is recvonly or inactive, abort these steps.
   */
  async_test(t => {
    const pc = new RTCPeerConnection();
    const transceiver = pc.addTransceiver('audio', { direction: 'sendrecv' });
    const dtmfSender = transceiver.sender.dtmf;

    // Since setRemoteDescription happens in parallel with tonechange event,
    // We use a flag and allow tonechange events to be fired as long as
    // the promise returned by setRemoteDescription is not yet resolved.
    let remoteDescriptionIsSet = false;

    // We only do basic tone verification and not check timing here
    let expectedTones = ['A', 'B', 'C', 'D', ''];

    const onToneChange = t.step_func(ev => {
      assert_false(remoteDescriptionIsSet,
        'Expect no tonechange event to be fired after currentDirection is changed to recvonly');

      const { tone } = ev;
      const expectedTone = expectedTones.shift();
      assert_equals(tone, expectedTone,
        `Expect fired event.tone to be ${expectedTone}`);

      // Only change transceiver.currentDirection after the first
      // tonechange event, to make sure that tonechange is triggered
      // then stopped
      if(tone === 'A') {
        transceiver.setDirection('recvonly');

        pc.createOffer()
        .then(offer =>
          pc.setLocalDescription(offer)
          .then(() => generateAnswer(offer)))
        .then(answer => pc.setRemoteDescription(answer))
        .then(() => {
          assert_equals(transceiver.currentDirection, 'recvonly');
          remoteDescriptionIsSet = true;

          // Pass the test if no further tonechange event is
          // fired in the next 300ms
          t.step_timeout(t.step_func_done(), 300);
        })
        .catch(t.step_func(err => {
          assert_unreached(`Unexpected promise rejection: ${err}`);
        }));
      }
    });

    dtmfSender.addEventListener('tonechange', onToneChange);
    dtmfSender.insertDTMF('ABCD', 100, 70);

  }, `Setting transceiver.currentDirection to recvonly in the middle of tonechange events should stop future tonechange events from firing`);

</script>
back to top