browser_glean_first_frame_loaded_time.js (2979B)
1 "use strict"; 2 3 /** 4 * This test is used to ensure that Glean probe 'first_frame_loaded' can be 5 * recorded correctly in different situations. 6 */ 7 8 const testCases = [ 9 { 10 expected: { 11 playback_type: "Non-MSE playback", 12 video_codec: "video/vp9", 13 resolution: "AV,240<h<=480", 14 key_system: undefined, 15 decoder_name: "ffvpx video decoder", 16 is_hdr: false, 17 }, 18 async run(tab) { 19 await loadVideo(tab, { extraEvent: "mozfirstframeloadedprobe" }); 20 }, 21 }, 22 { 23 expected: { 24 playback_type: "Non-MSE playback", 25 video_codec: "video/vp9", 26 resolution: "V,576<h<=720", 27 key_system: undefined, 28 decoder_name: "ffvpx video decoder", 29 is_hdr: true, 30 }, 31 async run(tab) { 32 await loadVideo(tab, { 33 extraEvent: "mozfirstframeloadedprobe", 34 loadHDR: true, 35 }); 36 }, 37 }, 38 { 39 expected: { 40 playback_type: "MSE playback", 41 video_codec: "video/vp9", 42 resolution: "V,240<h<=480", 43 key_system: undefined, 44 decoder_name: "ffvpx video decoder", 45 is_hdr: false, 46 }, 47 async run(tab) { 48 await loadMseVideo(tab, "mozfirstframeloadedprobe"); 49 }, 50 }, 51 { 52 expected: { 53 playback_type: "EME playback", 54 video_codec: "video/vp9", 55 resolution: "V,240<h<=480", 56 key_system: "org.w3.clearkey", 57 decoder_name: "ffvpx video decoder", 58 is_hdr: false, 59 }, 60 async run(tab) { 61 await loadEmeVideo(tab, "mozfirstframeloadedprobe"); 62 }, 63 }, 64 ]; 65 66 add_task(async function setTestPref() { 67 await SpecialPowers.pushPrefEnv({ 68 set: [["media.testing-only-events", true]], 69 }); 70 }); 71 72 add_task(async function testGleanMediaPlayackFirstFrameLoaded() { 73 for (let test of testCases) { 74 Services.fog.testResetFOG(); 75 76 const expected = test.expected; 77 info(`running test for '${expected.playback_type}'`); 78 const tab = await openTab(); 79 await test.run(tab); 80 81 info(`waiting until glean probe is ready on the parent process`); 82 await Services.fog.testFlushAllChildren(); 83 84 info("checking the collected results"); 85 const extra = Glean.mediaPlayback.firstFrameLoaded.testGetValue()[0].extra; 86 Assert.greater( 87 parseInt(extra.first_frame_loaded_time), 88 0, 89 `Loading time (${extra.first_frame_loaded_time}) is correct` 90 ); 91 is( 92 extra.playback_type, 93 expected.playback_type, 94 `${extra.playback_type} is correct` 95 ); 96 is( 97 extra.video_codec, 98 expected.video_codec, 99 `${extra.video_codec} is correct` 100 ); 101 is(extra.resolution, expected.resolution, `${extra.resolution} is correct`); 102 is(extra.key_system, expected.key_system, `${extra.key_system} is correct`); 103 ok( 104 extra.decoder_name.startsWith(expected.decoder_name), 105 `${extra.decoder_name} is correct` 106 ); 107 is( 108 extra.is_hdr === "true", 109 expected.is_hdr, 110 `HDR (${extra.is_hdr}) is correct` 111 ); 112 113 BrowserTestUtils.removeTab(tab); 114 } 115 });