tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_MediaSource_memory_reporting.html (1381B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>MSE: memory reporting</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <script type="text/javascript" src="mediasource.js"></script>
      7  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      8 </head>
      9 <body>
     10 <pre id="test">
     11 <script class="testbody" type="text/javascript">
     12 
     13 SimpleTest.waitForExplicitFinish();
     14 
     15 runWithMSE(async (ms, v) => {
     16  // Load a webm video and play it.
     17  await once(ms, "sourceopen");
     18  const sb = ms.addSourceBuffer("video/webm");
     19  await fetchAndLoad(sb, "seek", [""], ".webm");
     20  const p = once(v, "ended");
     21  ms.endOfStream();
     22  v.play();
     23  await p;
     24 
     25  // Test that memory reporting works once we've played a video.
     26  // Grab a memory report.
     27  const mgr = SpecialPowers.Cc["@mozilla.org/memory-reporter-manager;1"]
     28      .getService(SpecialPowers.Ci.nsIMemoryReporterManager);
     29 
     30  let amount;
     31  const handleReport = (aProcess, aPath, aKind, aUnits, aAmount) => {
     32    if (aPath == "explicit/media/resources") {
     33      amount = (amount || 0) + aAmount;
     34    }
     35  };
     36 
     37  await new Promise(r => mgr.getReports(handleReport, null, r, null, /* anonymized = */ false));
     38  ok(true, "Yay didn't crash!");
     39  ok(amount !== undefined, "Got media resources amount");
     40  ok(amount > 0, "Non-zero amount reported for media resources");
     41  SimpleTest.finish();
     42 });
     43 
     44 </script>
     45 </pre>
     46 </body>
     47 </html>