Revision b55e29597d92ab89063673f031151e2bdb4b9479 authored by Joe Downing on 22 March 2018, 07:35:35 UTC, committed by Chromium WPT Sync on 22 March 2018, 07:35:35 UTC
This change moves the KeyboardLock API methods to a 'keyboard'
namespace on the Navigator object.  We are doing this work now as
there has been a request for additional keyboard functionality that
would also be placed on the new keyboard object and we wanted to
move the KeyboardLock methods there for consistency before we launch.

KeyboardLock API Spec is here:
https://w3c.github.io/keyboard-lock/#API

Old calling pattern:
Navigator.keyboardLock();
Navigator.keyboardUnlock();

New calling pattern:
Navigator.keyboard.lock();
Navigator.keyboard.unlock();

Note: The main logic in the KeyboardLock.cpp class and tests is the
same as it was, however the file changed enough that git does not
recognize it as a file move.

BUG=680809

Change-Id: I234b2ab12d5ecd44c894ed5103863fd96fd548d4
Reviewed-on: https://chromium-review.googlesource.com/969656
Reviewed-by: Philip Jägenstedt <foolip@chromium.org>
Reviewed-by: Gary Kacmarcik <garykac@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544996}
1 parent 1a8c195
Raw File
RTCTrackEvent-constructor.html
<!doctype html>
<meta charset=utf-8>
<title>RTCTrackEvent constructor</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
  'use strict';

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

  /*
    5.7.  RTCTrackEvent
      [Constructor(DOMString type, RTCTrackEventInit eventInitDict)]
      interface RTCTrackEvent : Event {
        readonly attribute RTCRtpReceiver           receiver;
        readonly attribute MediaStreamTrack         track;
        [SameObject]
        readonly attribute FrozenArray<MediaStream> streams;
        readonly attribute RTCRtpTransceiver        transceiver;
      };

      dictionary RTCTrackEventInit : EventInit {
        required RTCRtpReceiver        receiver;
        required MediaStreamTrack      track;
                 sequence<MediaStream> streams = [];
        required RTCRtpTransceiver     transceiver;
      };
   */

  test(t => {
    const pc = new RTCPeerConnection();
    const transceiver = pc.addTransceiver('audio');
    const { receiver } = transceiver;
    const { track } = receiver;

    const trackEvent = new RTCTrackEvent('track', {
      receiver, track, transceiver
    });

    assert_equals(trackEvent.receiver, receiver);
    assert_equals(trackEvent.track, track);
    assert_array_equals(trackEvent.streams, []);
    assert_equals(trackEvent.streams, trackEvent.streams); // [SameObject]
    assert_equals(trackEvent.transceiver, transceiver);

    assert_equals(trackEvent.type, 'track');
    assert_false(trackEvent.bubbles);
    assert_false(trackEvent.cancelable);

  }, `new RTCTrackEvent() with valid receiver, track, transceiver should succeed`);

  test(t => {
    const pc = new RTCPeerConnection();
    const transceiver = pc.addTransceiver('audio');
    const { receiver } = transceiver;
    const { track } = receiver;

    const stream = new MediaStream([track]);

    const trackEvent = new RTCTrackEvent('track', {
      receiver, track, transceiver,
      streams: [stream]
    });

    assert_equals(trackEvent.receiver, receiver);
    assert_equals(trackEvent.track, track);
    assert_array_equals(trackEvent.streams, [stream]);
    assert_equals(trackEvent.transceiver, transceiver);

  }, `new RTCTrackEvent() with valid receiver, track, streams, transceiver should succeed`);

  test(t => {
    const pc = new RTCPeerConnection();
    const transceiver = pc.addTransceiver('audio');
    const { receiver } = transceiver;
    const { track } = receiver;

    const stream1 = new MediaStream([track]);
    const stream2 = new MediaStream([track]);

    const trackEvent = new RTCTrackEvent('track', {
      receiver, track, transceiver,
      streams: [stream1, stream2]
    });

    assert_equals(trackEvent.receiver, receiver);
    assert_equals(trackEvent.track, track);
    assert_array_equals(trackEvent.streams, [stream1, stream2]);
    assert_equals(trackEvent.transceiver, transceiver);

  }, `new RTCTrackEvent() with valid receiver, track, multiple streams, transceiver should succeed`);

  test(t => {
    const pc = new RTCPeerConnection();
    const transceiver = pc.addTransceiver('audio');
    const receiver = pc.addTransceiver('audio').receiver;
    const track =  pc.addTransceiver('audio').receiver.track;

    const stream = new MediaStream();

    const trackEvent = new RTCTrackEvent('track', {
      receiver, track, transceiver,
      streams: [stream]
    });

    assert_equals(trackEvent.receiver, receiver);
    assert_equals(trackEvent.track, track);
    assert_array_equals(trackEvent.streams, [stream]);
    assert_equals(trackEvent.transceiver, transceiver);

  }, `new RTCTrackEvent() with unrelated receiver, track, streams, transceiver should succeed`);

  test(t => {
    const pc = new RTCPeerConnection();
    const transceiver = pc.addTransceiver('audio');
    const { receiver } = transceiver;
    const { track } = receiver;

    assert_throws(new TypeError(), () =>
      new RTCTrackEvent('track', {
        receiver, track
      }));

  }, `new RTCTrackEvent() with no transceiver should throw TypeError`);

  test(t => {
    const pc = new RTCPeerConnection();
    const transceiver = pc.addTransceiver('audio');
    const { receiver } = transceiver;

    assert_throws(new TypeError(), () =>
      new RTCTrackEvent('track', {
        receiver, transceiver
      }));

  }, `new RTCTrackEvent() with no track should throw TypeError`);

  test(t => {
    const pc = new RTCPeerConnection();
    const transceiver = pc.addTransceiver('audio');
    const { receiver } = transceiver;
    const { track } = receiver;

    assert_throws(new TypeError(), () =>
      new RTCTrackEvent('track', {
        track, transceiver
      }));

  }, `new RTCTrackEvent() with no receiver should throw TypeError`);

  /*
    Coverage Report
      Interface tests are counted as 1 trivial test

      Tested         1
      Total          1
   */
</script>
back to top