Bug 1169096 - Test attribute filtering r=past

This commit is contained in:
Alexandre Poirot 2015-07-21 13:24:25 -07:00
parent 288bb717cb
commit ed474802d1
2 changed files with 77 additions and 0 deletions

View File

@ -173,6 +173,7 @@ skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
skip-if = buildapp == 'mulet' || e10s # Bug 1042253 - webconsole e10s tests
[browser_console_variables_view.js]
skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_console_variables_view_filter.js]
[browser_console_variables_view_dom_nodes.js]
[browser_console_variables_view_dont_sort_non_sortable_classes_properties.js]
skip-if = buildapp == 'mulet'

View File

@ -0,0 +1,76 @@
/*
* 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);
}
let test = asyncTest(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 in search");
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");
});