From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../test/browser_console_variables_view_filter.js | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 devtools/client/webconsole/test/browser_console_variables_view_filter.js (limited to 'devtools/client/webconsole/test/browser_console_variables_view_filter.js') diff --git a/devtools/client/webconsole/test/browser_console_variables_view_filter.js b/devtools/client/webconsole/test/browser_console_variables_view_filter.js new file mode 100644 index 000000000..142410839 --- /dev/null +++ b/devtools/client/webconsole/test/browser_console_variables_view_filter.js @@ -0,0 +1,80 @@ +/* -*- 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/ */ + +// Check that variables view filter feature works fine in the console. + +function props(view, prefix = "") { + // First match only the visible one, not hidden by a search + let visible = [...view].filter(([id, prop]) => prop._isMatch); + // Then flatten the list into a list of strings + // being the jsonpath of each attribute being visible in the view + return visible.reduce((list, [id, prop]) => { + list.push(prefix + id); + return list.concat(props(prop, prefix + id + ".")); + }, []); +} + +function assertAttrs(view, expected, message) { + is(props(view).join(","), expected, message); +} + +add_task(function* () { + yield loadTab("data:text/html;charset=utf-8,webconsole-filter"); + + let hud = yield openConsole(); + + let jsterm = hud.jsterm; + + let fetched = jsterm.once("variablesview-fetched"); + + yield jsterm.execute("inspect({ foo: { bar : \"baz\" } })"); + + let view = yield fetched; + let variablesView = view._variablesView; + let searchbox = variablesView._searchboxNode; + + assertAttrs(view, "foo,__proto__", + "To start with, we just see the top level foo attr"); + + fetched = jsterm.once("variablesview-fetched"); + searchbox.value = "bar"; + searchbox.doCommand(); + view = yield fetched; + + assertAttrs(view, "", + "If we don't manually expand nested attr, we don't see them"); + + fetched = jsterm.once("variablesview-fetched"); + searchbox.value = ""; + searchbox.doCommand(); + view = yield fetched; + + assertAttrs(view, "foo", + "If we reset the search, we get back to original state"); + + yield [...view][0][1].expand(); + + fetched = jsterm.once("variablesview-fetched"); + searchbox.value = "bar"; + searchbox.doCommand(); + view = yield fetched; + + assertAttrs(view, "foo,foo.bar", "Now if we expand, we see the nested attr"); + + fetched = jsterm.once("variablesview-fetched"); + searchbox.value = "baz"; + searchbox.doCommand(); + view = yield fetched; + + assertAttrs(view, "foo,foo.bar", "We can also search for attr values"); + + fetched = jsterm.once("variablesview-fetched"); + searchbox.value = ""; + searchbox.doCommand(); + view = yield fetched; + + assertAttrs(view, "foo", + "If we reset again, we get back to original state again"); +}); -- cgit v1.2.3