summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/browser/browser_perf-samples-01.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/server/tests/browser/browser_perf-samples-01.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/server/tests/browser/browser_perf-samples-01.js')
-rw-r--r--devtools/server/tests/browser/browser_perf-samples-01.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/devtools/server/tests/browser/browser_perf-samples-01.js b/devtools/server/tests/browser/browser_perf-samples-01.js
new file mode 100644
index 000000000..f8f4bf393
--- /dev/null
+++ b/devtools/server/tests/browser/browser_perf-samples-01.js
@@ -0,0 +1,63 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests if the retrieved profiler data samples are correctly filtered and
+ * normalized before passed to consumers.
+ */
+
+const WAIT_TIME = 1000; // ms
+
+const { PerformanceFront } = require("devtools/shared/fronts/performance");
+
+add_task(function* () {
+ let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
+ let doc = browser.contentDocument;
+
+ initDebuggerServer();
+ let client = new DebuggerClient(DebuggerServer.connectPipe());
+ let form = yield connectDebuggerClient(client);
+ let front = PerformanceFront(client, form);
+ yield front.connect();
+
+ // Perform the first recording...
+
+ let firstRecording = yield front.startRecording();
+ let firstRecordingStartTime = firstRecording._startTime;
+ info("Started profiling at: " + firstRecordingStartTime);
+
+ busyWait(WAIT_TIME); // allow the profiler module to sample some cpu activity
+
+ yield front.stopRecording(firstRecording);
+
+ ok(firstRecording.getDuration() >= WAIT_TIME,
+ "The first recording duration is correct.");
+
+ // Perform the second recording...
+
+ let secondRecording = yield front.startRecording();
+ let secondRecordingStartTime = secondRecording._startTime;
+ info("Started profiling at: " + secondRecordingStartTime);
+
+ busyWait(WAIT_TIME); // allow the profiler module to sample more cpu activity
+
+ yield front.stopRecording(secondRecording);
+ let secondRecordingProfile = secondRecording.getProfile();
+ let secondRecordingSamples = secondRecordingProfile.threads[0].samples.data;
+
+ ok(secondRecording.getDuration() >= WAIT_TIME,
+ "The second recording duration is correct.");
+
+ const TIME_SLOT = secondRecordingProfile.threads[0].samples.schema.time;
+ ok(secondRecordingSamples[0][TIME_SLOT] < secondRecordingStartTime,
+ "The second recorded sample times were normalized.");
+ ok(secondRecordingSamples[0][TIME_SLOT] > 0,
+ "The second recorded sample times were normalized correctly.");
+ ok(!secondRecordingSamples.find(e => e[TIME_SLOT] + secondRecordingStartTime <= firstRecording.getDuration()),
+ "There should be no samples from the first recording in the second one, " +
+ "even though the total number of frames did not overflow.");
+
+ yield front.destroy();
+ yield client.close();
+ gBrowser.removeCurrentTab();
+});