diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/debugger/test/mochitest/browser_dbg_variables-view-filter-03.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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-filter-03.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg_variables-view-filter-03.js | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-filter-03.js b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-filter-03.js new file mode 100644 index 000000000..cd4927e0f --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-filter-03.js @@ -0,0 +1,178 @@ +/* -*- 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/ */ + +/** + * Make sure that the variables view correctly filters nodes when triggered + * from the debugger's searchbox via an operator. + */ + +const TAB_URL = EXAMPLE_URL + "doc_with-frame.html"; + +var gTab, gPanel, gDebugger; +var gVariables, gSearchBox; + +function test() { + // Debug test slaves are a bit slow at this test. + requestLongerTimeout(2); + + let options = { + source: TAB_URL, + line: 1 + }; + initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => { + gTab = aTab; + gPanel = aPanel; + gDebugger = gPanel.panelWin; + gVariables = gDebugger.DebuggerView.Variables; + gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; + + // The first 'with' scope should be expanded by default, but the + // variables haven't been fetched yet. This is how 'with' scopes work. + promise.all([ + waitForCaretAndScopes(gPanel, 22), + waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_VARIABLES) + ]).then(prepareVariablesAndProperties) + .then(testVariablesAndPropertiesFiltering) + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) + .then(null, aError => { + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); + }); + + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); + }); +} + +function testVariablesAndPropertiesFiltering() { + let localScope = gVariables.getScopeAtIndex(0); + let withScope = gVariables.getScopeAtIndex(1); + let functionScope = gVariables.getScopeAtIndex(2); + let globalLexicalScope = gVariables.getScopeAtIndex(3); + let globalScope = gVariables.getScopeAtIndex(4); + + function testFiltered() { + is(localScope.expanded, true, + "The localScope should be expanded."); + is(withScope.expanded, true, + "The withScope should be expanded."); + is(functionScope.expanded, true, + "The functionScope should be expanded."); + is(globalLexicalScope.expanded, true, + "The globalScope should be expanded."); + is(globalScope.expanded, true, + "The globalScope should be expanded."); + + is(localScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 1, + "There should be 1 variable displayed in the local scope."); + is(withScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 0, + "There should be 0 variables displayed in the with scope."); + is(functionScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 0, + "There should be 0 variables displayed in the function scope."); + is(globalLexicalScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 0, + "There should be 0 variables displayed in the global scope."); + is(globalScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 0, + "There should be 0 variables displayed in the global scope."); + + is(localScope.target.querySelectorAll(".variables-view-property:not([unmatched])").length, 0, + "There should be 0 properties displayed in the local scope."); + is(withScope.target.querySelectorAll(".variables-view-property:not([unmatched])").length, 0, + "There should be 0 properties displayed in the with scope."); + is(functionScope.target.querySelectorAll(".variables-view-property:not([unmatched])").length, 0, + "There should be 0 properties displayed in the function scope."); + is(globalLexicalScope.target.querySelectorAll(".variables-view-property:not([unmatched])").length, 0, + "There should be 0 properties displayed in the global scope."); + is(globalScope.target.querySelectorAll(".variables-view-property:not([unmatched])").length, 0, + "There should be 0 properties displayed in the global scope."); + } + + function firstFilter() { + typeText(gSearchBox, "*alpha"); + testFiltered("alpha"); + + is(localScope.target.querySelectorAll(".variables-view-variable:not([unmatched]) > .title > .name")[0].getAttribute("value"), + "alpha", "The only inner variable displayed should be 'alpha'"); + } + + function secondFilter() { + localScope.collapse(); + withScope.collapse(); + functionScope.collapse(); + globalLexicalScope.collapse(); + globalScope.collapse(); + + is(localScope.expanded, false, + "The localScope should not be expanded."); + is(withScope.expanded, false, + "The withScope should not be expanded."); + is(functionScope.expanded, false, + "The functionScope should not be expanded."); + is(globalLexicalScope.expanded, false, + "The globalScope should not be expanded."); + is(globalScope.expanded, false, + "The globalScope should not be expanded."); + + backspaceText(gSearchBox, 6); + typeText(gSearchBox, "*beta"); + testFiltered("beta"); + + is(localScope.target.querySelectorAll(".variables-view-variable:not([unmatched]) > .title > .name")[0].getAttribute("value"), + "beta", "The only inner variable displayed should be 'beta'"); + } + + firstFilter(); + secondFilter(); +} + +function prepareVariablesAndProperties() { + let deferred = promise.defer(); + + let localScope = gVariables.getScopeAtIndex(0); + let withScope = gVariables.getScopeAtIndex(1); + let functionScope = gVariables.getScopeAtIndex(2); + let globalLexicalScope = gVariables.getScopeAtIndex(3); + let globalScope = gVariables.getScopeAtIndex(4); + + is(localScope.expanded, true, + "The localScope should be expanded."); + is(withScope.expanded, false, + "The withScope should not be expanded yet."); + is(functionScope.expanded, false, + "The functionScope should not be expanded yet."); + is(globalLexicalScope.expanded, false, + "The globalScope should not be expanded yet."); + is(globalScope.expanded, false, + "The globalScope should not be expanded yet."); + + // Wait for only two events to be triggered, because the Function scope is + // an environment to which scope arguments and variables are already attached. + waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_VARIABLES, 2).then(() => { + is(localScope.expanded, true, + "The localScope should now be expanded."); + is(withScope.expanded, true, + "The withScope should now be expanded."); + is(functionScope.expanded, true, + "The functionScope should now be expanded."); + is(globalLexicalScope.expanded, true, + "The globalScope should now be expanded."); + is(globalScope.expanded, true, + "The globalScope should now be expanded."); + + deferred.resolve(); + }); + + withScope.expand(); + functionScope.expand(); + globalLexicalScope.expand(); + globalScope.expand(); + + return deferred.promise; +} + +registerCleanupFunction(function () { + gTab = null; + gPanel = null; + gDebugger = null; + gVariables = null; + gSearchBox = null; +}); |