Revision ac4966fa4dcda8e22ade19e03ed6690de7b9cece authored by Henrik Boström on 28 March 2018, 15:48:04 UTC, committed by Chromium WPT Sync on 28 March 2018, 15:48:04 UTC
This exposes RTCRtpSender.getStats() in JavaScript (behind flag) which
implements the stats selection algorithm[1] for senders.

[1] https://w3c.github.io/webrtc-pc/#dfn-stats-selection-algorithm

Bug: 680172
Change-Id: I8117c87f475d1c78fa3301fc2d821f0c3a21281f
Reviewed-on: https://chromium-review.googlesource.com/975306
Commit-Queue: Henrik Boström <hbos@chromium.org>
Reviewed-by: Philip Jägenstedt <foolip@chromium.org>
Reviewed-by: Harald Alvestrand <hta@chromium.org>
Reviewed-by: Taylor Brandstetter <deadbeef@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546493}
1 parent f9c1a50
Raw File
idbobjectstore_getAllKeys.html
<!DOCTYPE html>
<title>IndexedDB: Test IDBObjectStore.getAllKeys.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>

var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');

function getall_test(func, name) {
  indexeddb_test(
    function(t, connection, tx) {
      var store = connection.createObjectStore('generated',
            {autoIncrement: true, keyPath: 'id'});
      alphabet.forEach(function(letter) {
        store.put({ch: letter});
      });

      store = connection.createObjectStore('out-of-line', null);
      alphabet.forEach(function(letter) {
        store.put('value-' + letter, letter);
      });

      store = connection.createObjectStore('empty', null);
    },
    func,
    name
  );
}

function createGetAllKeysRequest(t, storeName, connection, range, maxCount) {
    var transaction = connection.transaction(storeName, 'readonly');
    var store = transaction.objectStore(storeName);
    var req = store.getAllKeys(range, maxCount);
    req.onerror = t.unreached_func('getAllKeys request should succeed');
    return req;
}

getall_test(function(t, connection) {
      var req = createGetAllKeysRequest(t, 'out-of-line', connection, 'c');
      req.onsuccess = t.step_func(function(evt) {
          assert_array_equals(evt.target.result, ['c']);
          t.done();
      });
    }, 'Single item get');

getall_test(function(t, connection) {
      var req = createGetAllKeysRequest(t, 'generated', connection, 3);
      req.onsuccess = t.step_func(function(evt) {
          var data = evt.target.result;
          assert_true(Array.isArray(data));
          assert_array_equals(data, [3]);
          t.done();
      });
    }, 'Single item get (generated key)');

getall_test(function(t, connection) {
      var req = createGetAllKeysRequest(t, 'empty', connection);
      req.onsuccess = t.step_func(function(evt) {
          assert_array_equals(evt.target.result, [],
              'getAllKeys() on empty object store should return an empty ' +
                  'array');
          t.done();
      });
    }, 'getAllKeys on empty object store');

getall_test(function(t, connection) {
      var req = createGetAllKeysRequest(t, 'out-of-line', connection);
      req.onsuccess = t.step_func(function(evt) {
          assert_array_equals(evt.target.result, alphabet);
          t.done();
      });
    }, 'Get all values');

getall_test(function(t, connection) {
      var req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined,
                                    10);
      req.onsuccess = t.step_func(function(evt) {
          assert_array_equals(evt.target.result, 'abcdefghij'.split(''));
          t.done();
      });
    }, 'Test maxCount');

getall_test(function(t, connection) {
      var req = createGetAllKeysRequest(t, 'out-of-line', connection,
                                    IDBKeyRange.bound('g', 'm'));
      req.onsuccess = t.step_func(function(evt) {
          assert_array_equals(evt.target.result, 'ghijklm'.split(''));
          t.done();
      });
    }, 'Get bound range');

getall_test(function(t, connection) {
      var req = createGetAllKeysRequest(t, 'out-of-line', connection,
                                    IDBKeyRange.bound('g', 'm'), 3);
      req.onsuccess = t.step_func(function(evt) {
          assert_array_equals(evt.target.result, ['g', 'h', 'i']);
          t.done();
      });
    }, 'Get bound range with maxCount');

getall_test(function(t, connection) {
      var req = createGetAllKeysRequest(t, 'out-of-line', connection,
                                    IDBKeyRange.bound('g', 'k', false, true));
      req.onsuccess = t.step_func(function(evt) {
          assert_array_equals(evt.target.result, ['g', 'h', 'i', 'j']);
          t.done();
      });
    }, 'Get upper excluded');

getall_test(function(t, connection) {
      var req = createGetAllKeysRequest(t, 'out-of-line', connection,
                                    IDBKeyRange.bound('g', 'k', true, false));
      req.onsuccess = t.step_func(function(evt) {
          assert_array_equals(evt.target.result, ['h', 'i', 'j', 'k']);
          t.done();
      });
    }, 'Get lower excluded');

getall_test(function(t, connection) {
      var req = createGetAllKeysRequest(t, 'generated', connection,
                                    IDBKeyRange.bound(4, 15), 3);
      req.onsuccess = t.step_func(function(evt) {
          var data = evt.target.result;
          assert_true(Array.isArray(data));
          assert_array_equals(data, [4, 5, 6]);
          t.done();
      });
    }, 'Get bound range (generated) with maxCount');

getall_test(function(t, connection) {
      var req = createGetAllKeysRequest(t, 'out-of-line', connection,
                                    "Doesn't exist");
      req.onsuccess = t.step_func(function(evt) {
          assert_array_equals(evt.target.result, [],
              'getAllKeys() using a nonexistent key should return an ' +
                  'empty array');
          t.done();
      });
      req.onerror = t.unreached_func('getAllKeys request should succeed');
    }, 'Non existent key');

getall_test(function(t, connection) {
      var req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined,
          0);
      req.onsuccess = t.step_func(function(evt) {
          assert_array_equals(evt.target.result, alphabet);
          t.done();
      });
    }, 'zero maxCount');

</script>
back to top