summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-map-set.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/debugger/test/mochitest/browser_dbg_variables-view-map-set.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/debugger/test/mochitest/browser_dbg_variables-view-map-set.js')
-rw-r--r--devtools/client/debugger/test/mochitest/browser_dbg_variables-view-map-set.js117
1 files changed, 117 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-map-set.js b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-map-set.js
new file mode 100644
index 000000000..0c301c683
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-map-set.js
@@ -0,0 +1,117 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Test that Map and Set and their Weak friends are displayed in variables view.
+ */
+
+"use strict";
+
+const TAB_URL = EXAMPLE_URL + "doc_map-set.html";
+
+var test = Task.async(function* () {
+ let options = {
+ source: TAB_URL,
+ line: 1
+ };
+ const [tab,, panel] = yield initDebugger(TAB_URL, options);
+
+ const scopes = waitForCaretAndScopes(panel, 37);
+ callInTab(tab, "startTest");
+ yield scopes;
+
+ const variables = panel.panelWin.DebuggerView.Variables;
+ ok(variables, "Should get the variables view.");
+
+ const scope = variables.getScopeAtIndex(0);
+ ok(scope, "Should get the current function's scope.");
+
+ /* Test the maps */
+ for (let varName of ["map", "weakMap"]) {
+ const mapVar = scope.get(varName);
+ ok(mapVar, `Retrieved the '${varName}' variable from the scope`);
+
+ info(`Expanding '${varName}' variable`);
+ yield mapVar.expand();
+
+ const entries = mapVar.get("<entries>");
+ ok(entries, `Retrieved the '${varName}' entries`);
+
+ info(`Expanding '${varName}' entries`);
+ yield entries.expand();
+
+ // Check the entries. WeakMap returns its entries in a nondeterministic
+ // order, so we make our job easier by not testing the exact values.
+ let i = 0;
+ for (let [ name, entry ] of entries) {
+ is(name, i, `The '${varName}' entry's property name is correct`);
+ ok(entry.displayValue.startsWith("Object \u2192 "),
+ `The '${varName}' entry's property value is correct`);
+ yield entry.expand();
+
+ let key = entry.get("key");
+ ok(key, `The '${varName}' entry has the 'key' property`);
+ yield key.expand();
+
+ let keyProperty = key.get("a");
+ ok(keyProperty,
+ `The '${varName}' entry's 'key' has the correct property`);
+
+ let value = entry.get("value");
+ ok(value, `The '${varName}' entry has the 'value' property`);
+
+ i++;
+ }
+
+ is(i, 2, `The '${varName}' entry count is correct`);
+
+ // Check the extra property on the object
+ let extraProp = mapVar.get("extraProp");
+ ok(extraProp, `Retrieved the '${varName}' extraProp`);
+ is(extraProp.displayValue, "true",
+ `The '${varName}' extraProp's value is correct`);
+ }
+
+ /* Test the sets */
+ for (let varName of ["set", "weakSet"]) {
+ const setVar = scope.get(varName);
+ ok(setVar, `Retrieved the '${varName}' variable from the scope`);
+
+ info(`Expanding '${varName}' variable`);
+ yield setVar.expand();
+
+ const entries = setVar.get("<entries>");
+ ok(entries, `Retrieved the '${varName}' entries`);
+
+ info(`Expanding '${varName}' entries`);
+ yield entries.expand();
+
+ // Check the entries. WeakSet returns its entries in a nondeterministic
+ // order, so we make our job easier by not testing the exact values.
+ let i = 0;
+ for (let [ name, entry ] of entries) {
+ is(name, i, `The '${varName}' entry's property name is correct`);
+ is(entry.displayValue, "Object",
+ `The '${varName}' entry's property value is correct`);
+ yield entry.expand();
+
+ let entryProperty = entry.get("a");
+ ok(entryProperty,
+ `The '${varName}' entry's value has the correct property`);
+
+ i++;
+ }
+
+ is(i, 2, `The '${varName}' entry count is correct`);
+
+ // Check the extra property on the object
+ let extraProp = setVar.get("extraProp");
+ ok(extraProp, `Retrieved the '${varName}' extraProp`);
+ is(extraProp.displayValue, "true",
+ `The '${varName}' extraProp's value is correct`);
+ }
+
+ resumeDebuggerThenCloseAndFinish(panel);
+});