summaryrefslogtreecommitdiffstats
path: root/devtools/client/memory/test/unit/test_action-take-snapshot.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/client/memory/test/unit/test_action-take-snapshot.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/client/memory/test/unit/test_action-take-snapshot.js')
-rw-r--r--devtools/client/memory/test/unit/test_action-take-snapshot.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/devtools/client/memory/test/unit/test_action-take-snapshot.js b/devtools/client/memory/test/unit/test_action-take-snapshot.js
new file mode 100644
index 000000000..c05583b22
--- /dev/null
+++ b/devtools/client/memory/test/unit/test_action-take-snapshot.js
@@ -0,0 +1,54 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests the async reducer responding to the action `takeSnapshot(front)`
+ */
+
+let actions = require("devtools/client/memory/actions/snapshot");
+let { snapshotState: states } = require("devtools/client/memory/constants");
+
+function run_test() {
+ run_next_test();
+}
+
+add_task(function* () {
+ let front = new StubbedMemoryFront();
+ yield front.attach();
+ let store = Store();
+
+ let unsubscribe = store.subscribe(checkState);
+
+ let foundPendingState = false;
+ let foundDoneState = false;
+
+ function checkState() {
+ let { snapshots } = store.getState();
+ let lastSnapshot = snapshots[snapshots.length - 1];
+
+ if (lastSnapshot.state === states.SAVING) {
+ foundPendingState = true;
+ ok(foundPendingState, "Got state change for pending heap snapshot request");
+ ok(!lastSnapshot.path, "Snapshot does not yet have a path");
+ ok(!lastSnapshot.census, "Has no census data when loading");
+ }
+ else if (lastSnapshot.state === states.SAVED) {
+ foundDoneState = true;
+ ok(foundDoneState, "Got state change for completed heap snapshot request");
+ ok(foundPendingState, "SAVED state occurs after SAVING state");
+ ok(lastSnapshot.path, "Snapshot fetched with a path");
+ ok(snapshots.every(s => s.selected === (s.id === lastSnapshot.id)),
+ "Only recent snapshot is selected");
+ }
+ }
+
+ for (let i = 0; i < 4; i++) {
+ store.dispatch(actions.takeSnapshot(front));
+ yield waitUntilState(store, () => foundPendingState && foundDoneState);
+
+ // reset state trackers
+ foundDoneState = foundPendingState = false;
+ }
+
+ unsubscribe();
+});