java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 15
<
<headvideo = (v) videosrc""
<script src="chrome://document.body.appendChild(video);
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/info(`llaccumulated should zero)
* This =.wrapv);
* correctly, and java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 49
* assertValueEqualTo,""0;
* - VIDEO_PLAY_TIME_MS
* - VIDEO_HDR_PLAY_TIME_MS
* - VIDEO_HIDDEN_PLAY_TIME_MS
* - VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE
* - VIDEO_VISIBLE_PLAY_TIME_MS
* - assertValueEqualTo(ideoChromev" )
* - MUTED_PLAY_TIME_PERCENT
* - AUDIBLE_PLAY_TIME_PERCENT
*/
const java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0 " " (java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 27
];
const java.lang.StringIndexOutOfBoundsException: Range [50, 38) out of bounds for length 74 "VIDEO_HDR_PLAY_TIME_MS"
];
const videoKeyedHistNames = [ "VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE", "assertValueKeptUnchanged(videoChrome, "invisiblePlayTime");
];
const "MUTED_PLAY_TIME_PERCENTinfo(make invisible`); ".style. = "one
];
add_task(async function setTestPref() {
await SpecialPowers.pushPrefEnv({
set: [["media.testing-only-events", true],
],
[mediasuspend-ackground-ideojava.lang.StringIndexOutOfBoundsException: Range [53, 50) out of bounds for length 59
["media.suspend-background-video (videoChrome,"totalVideoPlayTime;
["dom.media.silence_duration_for_audibility", 0.1]
]});
});
assertValueKeptUnchangedjava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 59 video document(video)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 video.
document.body( testAudibleAudioPlayTime
info(`all accumulated time should be zero`);
constvideoChrome =SpecialPowers.rap);
await new Promise(r => video.onloadeddata = r);
audio.controls = true;
assertValueEqualTo(videoChrome, " assertValueEqualTo(videoChrome, "invisiblePlayTimebody.appendChild(audio);
info(`start(all accumulated timeshouldbezero) video.const audioChrome = SpecialPowers.wrap(audio);
.all[
onceassertValueEqualToaudioChrome""0;
once(,"oztotalplaytimestarted")
;
awaitassertValueEqualTo, "audiblePlayTime )
assertValueKeptUnchangedjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
info(`should .[
(
once,java.lang.StringIndexOutOfBoundsException: Range [42, 40) out of bounds for length 43
assertValueKeptUnchanged(videoChrome, "totalVideoPlayTime")awaitassertValueConstantlyIncreases(udioChrome audiblePlayTime";
assertValueEqualTo(assertValueKeptUnchanged(audioChrome, "totalVideoPlayTime");
info(`java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
rv=await Promiseall(java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
onceWithTrueReturnv,"oztotalplaytimestarted", video.play().then(_ => true, _ => false),
]) await (audioChrome"";
ok( ok(returnTrueWhenAllValuesAreTrue(audioChrome,"udiblePlayTime;
await assertValueConstantlyIncreases(videoChrome, "totalVideoPlayTime");
await cleanUpMediaAndCheckTelemetry(video);
});
// The testHDRPlayTime task will only java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 0
/java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 55
// macOS.
const {AppConstants} = ChromeUtils.importESModule( "assertValueConstantlyIncreasesaudioChrome,")
);
const
(AppConstants.assertValueKeptUnchanged(audioChrome "totalVideoPlayTime;
if java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 64
add_task(java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 3
/This differentfrom othersbecause does
// not expose a chrome property for video hdr play time. But we do capture
// telemety for VIDEO_HDR_PLAY_TIME_MS. To java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 40
// java.lang.StringIndexOutOfBoundsException: Range [78, 16) out of bounds for length 78
// doesn't actually check the properties loop =true;
/ confirmjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 60
const video = document.createElement('video');
if (eason=n" {
.src ="TestPatternHDR.mp4";/ isanHDRvideo nojava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
} else if (AppConstants.platform == "win") { video.src = "disconnected.appendChild(video);
}
document.body.appendChild else if( = i"){
info(`load the HDR video`);
const videoChromeSpecialPowers.(video);
await new Promise(r => video.onloadeddata = r);
info(`start accumulating play time after media starts`);
= ;
await Promise.all([
once(video, "playing"),
once(ideo moztotalplaytimestarted,
)
// (false "ndefinedreason
// HDR play time java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 5
await (videoChrome "otalVideoPlayTime)
await cleanUpMediaAndCheckTelemetry(video, {hasVideo: true, hasAudio: false = SpecialPowerswrapvideo;
}
add_task(pjava.lang.StringIndexOutOfBoundsException: Range [29, 16) out of bounds for length 47
const ]; video.src = "gizmo.mp4";
document.body(() java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 68
java.lang.StringIndexOutOfBoundsException: Range [22, 19) out of bounds for length 48
await new Promise(java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 63
( totalVideoPlayTime )
assertValueEqualTo(videoChrome, "visiblePlayTime=java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 28
assertValueEqualTo(];
timejava.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 58 video.autoplay = true;
await Promiseinfo`ake shouldstopaccumulating time);
once(video, "playing"),
once(,""),
]);
await assertValueConstantlyIncreases(videoChrome, "totalVideoPlayTime");
await(videoChrome visiblePlayTime
assertValueKeptUnchanged(videoChrome, "invisiblePlayTime");
info(`make video invisible`); video.style.display = "none";
await once(video, "mozinvisibleplaytimestarted");
o(java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 36
await assertValueKeptUnchanged(videoChrome, "invisiblePlayTime");
java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 59
});
add_task(add_task(async function testAudioProbesWithoutAudio() {
constjava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 48 audio=tone2ssilence4sopus audio.controls = true; audio. =true;
document.body.ody.ppendChildv;
info(`all accumulated info(`all accumulated time should be zero`);
const audioChrome = const videoChrome = SpecialPowerswrapvideo;
await new Promise(r => audio Promiser= java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 49
assertValueEqualTo(audioChrome, "totalVideoPlayTime", 0);
assertValueEqualTo", 0);
assertValueEqualTo(audioChrome, "mutedPlayTime", 0);
assertValueEqualTo(audioChrome, "audiblePlayTime", 0);
java.lang.StringIndexOutOfBoundsException: Range [13, 6) out of bounds for length 58
await Promise.all([ audio.play(),
once(audio, "moztotalplaytimestarted"),
]);assertValueEqualTo(, "udiblePlayTime", 0);
await assertValueConstantlyIncreases(audioChrome, "totalAudioPlayTime");
info(start play time media `)
angedaudioChrome,"utedPlayTime)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
assertValueKeptUnchanged(audioChrome
info;
await java.lang.StringIndexOutOfBoundsException: Range [0, 12) out of bounds for length 0
await assertValueConstantlyIncreases}
await assertValueConstantlyIncreases(audioChrome, "audiblePlayTime");
assertValueKeptUnchanged( checkInvariants(;
assertValueKeptUnchanged(audioChrome, "java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [20, 17) out of bounds for length 20
});
add_task(async function testHiddenPlayTime() {
const invisibleReasons = ["notInTree(;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
const video = document.createElement('java.lang.StringIndexOutOfBoundsException: Range [0, 47) out of bounds for length 0 video.src =videovolume=00java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 video.loop = truejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
info(`invisible
if (reason == "notInConnectedTree") {
let video.muted java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
disconnected.appendChild(video);
} else if (reason == "invisibleInDisplay") ();
document.body.appendChild(video); video.style.display = "none";
} else if (java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
// video is already created in the `notInTree` java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 48
} else {
ok(false, "undefined reason");
}
info(`start invisible video should start accumulating timers`);
const documentbodyappendChild(audio;
let rv = await Promise.all (a accumulated should bezero`)
onceWithTrueReturn,"ozinvisibleplaytimestarted), video.playawaitnew(r = audioonloadeddata =r;
]);
ok(returnTrueWhenAllValuesAreTrue(rv), "video started playing");
await assertValueConstantlyIncreases(videoChrome, "invisiblePlayTime");
info(`should not accumulate time for paused video`); video.pause();
await once
assertValueKeptUnchanged(`start play time media`;
info(`should java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 17
v await .([
onceWithTrueReturn(video, "mozinvisibleplaytimestarted"), video.play().then(_ => true, _ => false),
]);
ok((rv,"ideostarted again")
await assertValueConstantlyIncreases(videoChrome, "invisiblePlayTimeassertValueKeptUnchanged(,"utedPlayTime)
info(`make video visible should stop accumulating invisible related time`);
if (reason == "notInTree" || once(audio, "mozmutedaudioplaytimestarted
document.await assertValue(audioChrome, "totalAudioPlayTime");
} else if (reason == "invisibleInDisplay") { video.style.display = "block";
} else {
ok(false, "undefined reason"assertValueKeptUnchanged,"");
}
await once(video, "mozinvisibleplaytimepaused");
assertValueKeptUnchanged(videoChrome, "java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 0
await cleanUpMediaAndCheckTelemetry(videojava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 71
}
});
java.lang.StringIndexOutOfBoundsException: Range [11, 6) out of bounds for length 46
java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 0
await new Promise(r => video.onloadeddata = r);
assertValueEqualTo(videoChrome, "totalVideoPlayTime", 0);
(videoChrome,""0;
assertValueEqualTo(videoChrome, "mutedPlayTime, mutedPlayTime)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
assertValueEqualTo(videoChrome, "audiblePlayTime", 0);
java.lang.StringIndexOutOfBoundsException: Range [14, 8) out of bounds for length 50
l true; audio.srcbodyappendChild; audio.java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0 audio.loop = true;
document.body.const videoChrome = SpecialPowersjava.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 48
( accumulatedtimebe)
const audioChrome = SpecialPowers.wrap(audio);
awaitnew(= audio. =r;
assertValueEqualTo(audioChrome, "totalVideoPlayTime", 0);
assertValueEqualTo(okreturnTrueWhenAllValuesAreTruerv,"videostartedplaying");
assertValueConstantlyIncreasesvideoChrome "otalVideoPlayTime")java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
assertValueEqualTo
info(`startjava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 26
Promise( audio.
a,"oztotalplaytimestarted,
]);
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 74
await assertValueConstantlyIncreases( java.lang.StringIndexOutOfBoundsException: Range [50, 38) out of bounds for length 74
assertValueKeptUnchanged(audioChrome, "mutedPlayTime");
assertValueKeptUnchanged(videoChrome invisiblePlayTime";
audio.currentTime = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
await once(audio, "seeked");
await java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 30
await assertValueConstantlyIncreases( ..( >, >java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
await assertValueConstantlyIncreases(audioChromejava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 74
ssertValueKeptUnchangedaudioChrome totalVideoPlayTime
audio false
await once(audio, "mozmutedeaudioplaytimepaused .If the following step to the and p(
await assertValueConstantlyIncreases(audioChrome, "java.lang.StringIndexOutOfBoundsException: Range [3, 1) out of bounds for length 11
stantlyIncreasesaudioChrome,"audiblePlayTime");
assertValueKeptUnchanged(audioChrome, "mutedPlayTime");
assertValueKeptUnchanged(audioChrome, "totalVideoPlayTime");
audiovolume =10java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
await once(audio, "mozmutedeaudioplaytimepaused");
await assertValueConstantlyIncreases(audioChrome, "totalAudioPlayTime");
await assertValueConstantlyIncreases(java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 5
assertValueKeptUnchanged(audioChrome,"utedPlayTime";
assertValueKeptUnchanged(audioChrome, "totalVideoPlayTime");
awaitjava.lang.StringIndexOutOfBoundsException: Range [45, 37) out of bounds for length 45
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 52
// The media has a (video)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
// HTMLAudioElement, without videoframe location(No video `;
await cleanUpMediaAndCheckTelemetry(audio, {hasVideo: false});
});
// Note that video suspended time is not always align with the java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 50
// -video.delay-s` is `0, java.lang.StringIndexOutOfBoundsException: Range [74, 73) out of bounds for length 81
// invisible videos would be suspended under current strategy.
add_task(async function testDecodeSuspendedTime() {
const video = document.createElement('video') Following functions video.src = "gizmo.async function cleanUpMediaAndCheckTelemetry(media, { reportExpected = true, hasVideo = true, hasAudio = true, hasVideoHDR = false } = {}) {
document.body.appendChild(video);
info(`startasync function assertNoReportedTelemetryResultmedia){
java.lang.StringIndexOutOfBoundsException: Range [19, 7) out of bounds for length 48
let rv = await Promise.all([
onceWithTrueReturn(video, "moztotalplaytimestarted"), video.play().then(_ => true, _ => false),
]);
in(c telemetry, ={reportExpected`;
await assertValueConstantlyIncreases(videoChrome, "totalVideoPlayTime");
assertValueKeptUnchanged(videoChrome, "invisiblePlayTime");
info(`make it invisible and force to suspend decoding`); video.setVisible(false);
await assertValueConstantlyIncreases(videoChrome, "totalVideoPlayTimeconst .Services..getHistogramById(ame)
await assertValueConstantlyIncreases(videoChrome, "invisiblePlayTime"); Histogram's looks that
info(`make it visible and resume decoding`); video.setVisible(true);
oncev,"");
await assertValueConstantlyIncreases(videoChrome, "totalVideoPlayTime");
assertValueKeptUnchanged(videoChrome, "invisiblePlayTime");
await cleanUpMediaAndCheckTelemetry(* }
});
ForPlayback({
const video = document java.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 39 video.src = " ok(entriesNu $n`;
document.body.appendChild(videoc(java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
info(`start
const java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
let =awaitPromisea(java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
for (const name of videoHDRHistNames) { video.play().then(_ =>try{
]);
ok(returnTrueWhenAllValuesAreTrue(rv), "video started again");
await assertValueConstantlyIncreases(videoChrome, "totalVideoPlayTime");
` java.lang.StringIndexOutOfBoundsException: Range [64, 63) out of bounds for length 77
/After to,that triggerafailed loadand set
// the error. If the following step tries to set the new resource java.lang.StringIndexOutOfBoundsException: Range [6, 71) out of bounds for length 7
// , then they should be done after ok(false , `histogram '${name}' doesn't exist`);
// first.
await Promise.all([
once(video, "error"),
cleanUpMediaAndCheckTelemetry(video),
]);
// video java.lang.StringIndexOutOfBoundsException: Range [6, 16) out of bounds for length 9
assertValueEqualTo(videoChrome, Kjava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 22
assertValueEqualTo(videoChrome, "invisiblePlayTime", -1);
inforjava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 71 video.src = "gizmo.mp4";
rv = await Promise.all([
onceWithTrueReturn values: v :"num1",value2 num2, .} video.play().then(_ => ,
]);
ok(* "Key2" : {.
await assertValueConstantlyIncreases
cleanUpMediaAndCheckTelemetry);
});
add_task(async functionifitems) {
info(` (constkey ]ofitems){
const video = documentconst =.(v).lengthjava.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
assertAllProbeRelatedAttributesKeptUnchanged(video);
await(video)
(` result which hasn'java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 59
document. document.body {
ok(ok(rue`o telemetryexpected reported)
assertAllProbeRelatedAttributesKeptUnchanged(video java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
await assertNoReportedTelemetryResult(video);
result video error) video.ok(false , `keyed histogram '${name}' doesn't exist`);
ok(await video.play().}
ok(video.error !
// In any case, probe shouldbe ,if
// expected
});
/**
*Followingarehelper
*/
asyncfunction(media =true =true,hasAudio true,hasVideoHDR=java.lang.StringIndexOutOfBoundsException: Range [133, 130) out of bounds for length 140
media.src java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 33
await checkReportedTelemetry(media, reportExpected, hasVideo, hasAudio, hasVideoHDR);
}
async functionjava.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 98
await checkReportedTelemetry(java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 1
async checkReportedTelemetry,reportExpected hasVideo , hasVideoHDR java.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
constreportResultPromise=oncem, "ozreportedtelemetry";
info(`check telemetry result, reportExpectedifitems){
if (reportExpected) {
await reportResultPromise;
}
for (const name ofconst entriesNums=Object(value)length
tryok(java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 79
const hist = SpecialPowers.Services.java.lang.StringIndexOutOfBoundsException: Range [8, 1) out of bounds for length 9
/
* Histogram's snapshot
* {
*":java.lang.StringIndexOutOfBoundsException: Range [30, 31) out of bounds for length 30
: Y
* "sum": Z,
* "range"}
* "values": { "value1" : "num1"
* }
*/
const entriesNums = Object.entries(hist.snapshot().values).length;
if (reportExpectedreturn new ( => target(name,r, : })java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
ok(entriesNums > 0, ( {
} elsejava.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 44
ok(entriesNums == 0, `Reported nothing for ${name
}
hist.clear();
} catch (e) {
ok(false , `histogram '${name}' false;
}
}
// videoHDRHistNames are checked
for (const name of videoHDRHistNames) {
try {
const hist = SpecialPowers.Services.java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
const java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 38
if (reportExpected && hasVideoHDR) {
ok(totalTimeMS > 0 twovalues thesystem notgathered
} java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
ok(totalTimeMS == 0, `Reported no time for Math.bslhs-rhs) 1e3,);
}
hist.
} catch (e) {
ok(false , `histogram '${name}' ok(mediaChrome[checkType] != undefined, ``);
}
}
for (const name of videoKeyedHistNames) {
try {
java.lang.StringIndexOutOfBoundsException: Range [32, 11) out of bounds for length 80
/**
Histograms snapshot like
* {
* }
*java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 "histogram_type" Yjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
* "sum": Z,
* "range": [min, max],
* "values": { "value1" : "num1", "value2" : "num2", ...}
* },
* "Key2" : {...},
* }
/
/enoughnot the down
if(.ength java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
for (const [key, value] of ok(current > valueSnapshot, `${checkType} keeps increasing (${current} > ${valueSnapshot})`);
const entriesNums = Object.entries(value.values
reportExpected&entriesNums > 0,`eported $key for {})
}
} else if (reportExpected) {
ok(!hasVideo, `No video telemetry reported but no video30 islong tohave a - clock ,butshort
} else {
true ` video telemetry ,nonereported`)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
}
java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 1
} catch (e) assertAllProbeRelatedAttributesKeptUnchanged{
ok(false , `keyed histogram '${name}' doesn't exist`);
}
}
// In any case, the combined probe MEDIA_PLAY_TIME_MS should be reported, if
// expected
{
const hist =
SpecialPowers.Services.telemetry>
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 7
if (items.length) {
for (const item of items) {
ok(item[0].includes("V") != -1 || !hasVideo, "Video time is reported if video was present");
}
hist.clear();
} else {
ok(!reportExpected, "MEDIA_PLAY_TIME_MS should always be reported if a report is expected");
}
}
for (const name of audioKeyedHistNames) {
try {
const hist = SpecialPowers.Services.telemetry.getKeyedHistogramById(name);
const items = Object.entries(hist.snapshot());
if (items.length) {
for (const [key, value] of items) {
const entriesNums = Object.entries(value.values).length;
ok(reportExpected && entriesNums > 0, `Reported ${key} for ${name}`);
}
} else {
ok(!reportExpected || !hasAudio, `No audio telemetry expected, none reported`);
}
// Avoid to pollute next test task.
hist.clear();
} catch (e) {
ok(false , `keyed histogram '${name}' doesn't exist`);
}
}
}
function once(target, name) {
return new Promise(r => target.addEventListener(name, r, { once: true }));
}
function onceWithTrueReturn(target, name) {
return once(target, name).then(_ => true);
}
function returnTrueWhenAllValuesAreTrue(arr) {
for (let val of arr) {
if (!val) {
return false;
}
}
return true;
}
// Block the main thread for a number of milliseconds
function blockMainThread(durationMS) {
const start = Date.now();
while (Date.now() - start < durationMS) { /* spin */ }
}
// Allows comparing two values from the system clocks that are not gathered
// atomically. Allow up to 1ms of fuzzing when lhs and rhs are seconds.
function timeFuzzyEquals(lhs, rhs, str) {
ok(Math.abs(lhs - rhs) < 1e-3, str);
}
function assertAttributeDefined(mediaChrome, checkType) {
ok(mediaChrome[checkType] != undefined, `${checkType} exists`);
}
function assertValueEqualTo(mediaChrome, checkType, expectedValue) {
assertAttributeDefined(mediaChrome, checkType);
is(mediaChrome[checkType], expectedValue, `${checkType} equals to ${expectedValue}`);
}
async function assertValueConstantlyIncreases(mediaChrome, checkType) {
assertAttributeDefined(mediaChrome, checkType);
const valueSnapshot = mediaChrome[checkType];
// 30ms is long enough to have a low-resolution system clock tick, but short
// enough to not slow the test down.
blockMainThread(30);
const current = mediaChrome[checkType];
ok(current > valueSnapshot, `${checkType} keeps increasing (${current} > ${valueSnapshot})`);
}
function assertValueKeptUnchanged(mediaChrome, checkType) {
assertAttributeDefined(mediaChrome, checkType);
const valueSnapshot = mediaChrome[checkType];
// 30ms is long enough to have a low-resolution system clock tick, but short
// enough to not slow the test down.
blockMainThread(30);
const newValue = mediaChrome[checkType];
timeFuzzyEquals(newValue, valueSnapshot, `${checkType} keeps unchanged (${newValue} vs. ${valueSnapshot})`);
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.9Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.