diff options
Diffstat (limited to 'devtools/server/tests/chrome/test_framerate_04.html')
-rw-r--r-- | devtools/server/tests/chrome/test_framerate_04.html | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/devtools/server/tests/chrome/test_framerate_04.html b/devtools/server/tests/chrome/test_framerate_04.html new file mode 100644 index 0000000000..6fbc0e6969 --- /dev/null +++ b/devtools/server/tests/chrome/test_framerate_04.html @@ -0,0 +1,66 @@ +<!DOCTYPE HTML> +<html> +<!-- +Bug 1023018 - Tests if the framerate actor keeps recording after navigations. +--> +<head> + <meta charset="utf-8"> + <title>Framerate actor test</title> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <script type="application/javascript" src="inspector-helpers.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> +</head> +<body> +<pre id="test"> +<script> +"use strict"; + +window.onload = async function() { + // inspector-helpers doesnt wait for explicit finish + SimpleTest.waitForExplicitFinish(); + + const TICK = 1000; + const url = document.getElementById("testContent").href; + const { target, doc } = await attachURL(url); + const contentWin = doc.defaultView; + const front = await target.getFront("framerate"); + + await front.startRecording(); + await waitFor(TICK); + const firstBatch = await front.getPendingTicks(); + await waitFor(TICK); + + const onWillNavigate = target.once("will-navigate"); + contentWin.location.reload(); + await onWillNavigate; + + await waitFor(TICK); + const secondBatch = await front.stopRecording(); + await onRecordingStopped(firstBatch, secondBatch); + target.destroy(); + SimpleTest.finish(); +}; + +// Local Helpers +function waitFor(time) { + return new Promise(resolve => setTimeout(resolve, time)); +} + +function onRecordingStopped(firstBatch, secondBatch) { + ok(firstBatch, "There should be a first batch recording available."); + ok(secondBatch, "There should be a second batch recording available."); + + const diff = secondBatch.length - firstBatch.length; + info("Difference in ticks: " + diff); + ok(diff > 0, "More ticks should be recorded in the second batch."); + + ok(firstBatch.every((e) => secondBatch.includes(e)), + "All the ticks in the first batch should be in the second batch as well."); + ok(secondBatch.every((e, i, array) => i < array.length - 1 ? e < array[i + 1] : true), + "All the ticks in the final batch should be ascending in value."); +} +</script> +</pre> +<a id="testContent" target="_blank" href="inspector_getImageData.html">Test Document</a> +</body> +</html> |