DXR will be turned off on Tuesday, December 29th. It will redirect to Searchfox.
See the announcement on Discourse.

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 (c68fe15a81fc)

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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
<!DOCTYPE HTML>
<html>
<head>
<head>
  <title>Test Encrypted Media Extensions</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  <script type="text/javascript" src="manifest.js"></script>
  <script type="text/javascript" src="eme.js"></script>
  <script type="text/javascript" src="eme.js"></script>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">

var tests = [
  {
    name: "One keyId",
    initDataType: 'keyids',
    initDataType: 'keyids',
    initData: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A"]}',
    expectedRequest: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A"],"type":"temporary"}',
    sessionType: 'temporary',
    expectPass: true,
  },
  },
  {
    name: "Two keyIds",
    initDataType: 'keyids',
    initData: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A", "0DdtU9od-Bh5L3xbv0Xf_A"]}',
    expectedRequest: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A","0DdtU9od-Bh5L3xbv0Xf_A"],"type":"temporary"}',
    sessionType: 'temporary',
    sessionType: 'temporary',
    expectPass: true,
  },
  {
    name: "Two keyIds, temporary session",
    initDataType: 'keyids',
    initDataType: 'keyids',
    initData: '{"type":"temporary", "kids":["LwVHf8JLtPrv2GUXFW2v_A", "0DdtU9od-Bh5L3xbv0Xf_A"]}',
    expectedRequest: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A","0DdtU9od-Bh5L3xbv0Xf_A"],"type":"temporary"}',
    sessionType: 'temporary',
    expectPass: true,
  },
  },
  {
    name: "Two keyIds, persistent session, type before kids",
    initDataType: 'keyids',
    initData: '{"type":"persistent-license", "kids":["LwVHf8JLtPrv2GUXFW2v_A", "0DdtU9od-Bh5L3xbv0Xf_A"]}',
    expectedRequest: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A","0DdtU9od-Bh5L3xbv0Xf_A"],"type":"persistent-license"}',
    expectedRequest: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A","0DdtU9od-Bh5L3xbv0Xf_A"],"type":"persistent-license"}',
    sessionType: 'persistent-license',
    expectPass: false,
  },
  {
    name: "Invalid keyId",
    name: "Invalid keyId",
    initDataType: 'keyids',
    initData: '{"kids":["0"]}',
    sessionType: 'temporary',
    expectPass: false,
    expectPass: false,
  },
  {
    name: "Empty keyId",
    initDataType: 'keyids',
    initData: '{"kids":[""]}',
    sessionType: 'temporary',
    sessionType: 'temporary',
    expectPass: false,
  },
  {
    name: "Invalid initData",
    initDataType: 'keyids',
    initDataType: 'keyids',
    initData: 'invalid initData',
    sessionType: 'temporary',
    expectPass: false,
  },
  {
  {
    name: "'webm' initDataType",
    initDataType: 'webm',
    initData: 'YAYeAX5Hfod+V9ANHtANHg==',
    expectedRequest: '{"kids":["YAYeAX5Hfod-V9ANHtANHg"],"type":"temporary"}',
    sessionType: 'temporary',
    sessionType: 'temporary',
    expectPass: true,
  },
  {
    name: "'webm' initDataType with non 16 byte keyid",
    initDataType: 'webm',
    initData: 'YAYeAX5Hfod',
    expectedRequest: '{\"kids\":[\"YAYeAX5Hfoc\"],\"type\":\"temporary\"}',
    expectedRequest: '{\"kids\":[\"YAYeAX5Hfoc\"],\"type\":\"temporary\"}',
    sessionType: 'temporary',
    expectPass: true,
  },
];

function PrepareInitData(initDataType, initData)
function PrepareInitData(initDataType, initData)
{
  if (initDataType == "keyids") {
    return new TextEncoder().encode(initData);
  } else if (initDataType == "webm") {
    return StringToArrayBuffer(atob(initData));
    return StringToArrayBuffer(atob(initData));
  }
}

function Test(test) {
  return new Promise(function(resolve, reject) {
  return new Promise(function(resolve, reject) {
    var configs = [{
      initDataTypes: [test.initDataType],
      videoCapabilities: [{contentType: 'video/mp4' }],
    }];
    navigator.requestMediaKeySystemAccess('org.w3.clearkey', configs)
    navigator.requestMediaKeySystemAccess('org.w3.clearkey', configs)
      .then((access) => access.createMediaKeys())
      .then((mediaKeys) => {
          var session = mediaKeys.createSession(test.sessionType);
          session.addEventListener("message", function(event) {
            is(event.messageType, "license-request", "'" + test.name + "' MediaKeyMessage type should be license-request.");
            is(event.messageType, "license-request", "'" + test.name + "' MediaKeyMessage type should be license-request.");
            var text = new TextDecoder().decode(event.message);
            is(text, test.expectedRequest, "'" + test.name + "' got expected response.");
            is(text == test.expectedRequest, test.expectPass,
               "'" + test.name + "' expected to " + (test.expectPass ? "pass" : "fail"));
            resolve();
            resolve();
          });
          });
          var initData = PrepareInitData(test.initDataType, test.initData);
          return session.generateRequest(test.initDataType, initData);
        }
      ).catch((x) => {
        ok(!test.expectPass, "'" + test.name + "' expected to fail.");
        ok(!test.expectPass, "'" + test.name + "' expected to fail.");
        resolve();
      });
  });
}


function beginTest() {
  Promise.all(tests.map(Test)).then(function() { SimpleTest.finish(); });
}

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
SetupEMEPref(beginTest);

</script>
</pre>
</body>
</body>
</html>