browser_dbg-outline.js (4315B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ 4 5 // Tests that outline panel can sort functions alphabetically. 6 7 "use strict"; 8 9 // Test that the outline panel updates correctly when a source is selected 10 // This scenario covers the case where the outline panel always focused. 11 add_task(async function () { 12 const dbg = await initDebugger("doc-scripts.html", "simple1.js"); 13 openOutlinePanel(dbg, false); 14 is( 15 findAllElements(dbg, "outlineItems").length, 16 0, 17 " There are no outline items when no source is selected" 18 ); 19 20 await selectSource(dbg, "simple1.js", 1); 21 22 info("Wait for all the outline list to load"); 23 await waitForElementWithSelector(dbg, ".outline-list"); 24 25 assertOutlineItems(dbg, [ 26 "λmain()", 27 "λdoEval()", 28 "λevaledFunc()", 29 "λdoNamedEval()", 30 // evaledFunc is set twice 31 "λevaledFunc()", 32 "λnormalFunction(foo)", 33 "λletFunction(a)", 34 "λconstFunction(x)", 35 "λProtoClass(a)", 36 "λprotoFoo(foo)", 37 "λprotoBar(x, y)", 38 "λprotoBoo(x)", 39 "λ1234()", 40 "λmemFoo(a, b)", 41 "λarrFoo(c)", 42 "class MyClass", 43 "λconstructor(a, b)", 44 "λtest()", 45 "λ#privateFunc(a, b)", 46 "class Klass", 47 "λconstructor()", 48 "λtest()", 49 "λbar()", 50 "λboo(a)", 51 ]); 52 }); 53 54 // Test that the outline panel updates correctly when a source is selected 55 // This scenario covers the case where the outline panel gets un-selected and selected again 56 add_task(async function () { 57 const dbg = await initDebugger("doc-scripts.html", "simple1.js"); 58 59 openOutlinePanel(dbg, false); 60 61 is( 62 findAllElements(dbg, "outlineItems").length, 63 0, 64 " There are no outline items when no source is selected" 65 ); 66 is( 67 findElementWithSelector(dbg, ".outline-pane-info").innerText, 68 "No file selected", 69 "The correct message is displayed when there are no outline items" 70 ); 71 72 const sourcesTab = findElementWithSelector(dbg, ".sources-tab a"); 73 EventUtils.synthesizeMouseAtCenter(sourcesTab, {}, sourcesTab.ownerGlobal); 74 await waitForSourcesInSourceTree(dbg, [], { noExpand: true }); 75 76 await selectSource(dbg, "simple1.js", 1); 77 78 await openOutlinePanel(dbg); 79 80 assertOutlineItems(dbg, [ 81 "λmain()", 82 "λdoEval()", 83 "λevaledFunc()", 84 "λdoNamedEval()", 85 // evaledFunc is set twice 86 "λevaledFunc()", 87 "λnormalFunction(foo)", 88 "λletFunction(a)", 89 "λconstFunction(x)", 90 "λProtoClass(a)", 91 "λprotoFoo(foo)", 92 "λprotoBar(x, y)", 93 "λprotoBoo(x)", 94 "λ1234()", 95 "λmemFoo(a, b)", 96 "λarrFoo(c)", 97 "class MyClass", 98 "λconstructor(a, b)", 99 "λtest()", 100 "λ#privateFunc(a, b)", 101 "class Klass", 102 "λconstructor()", 103 "λtest()", 104 "λbar()", 105 "λboo(a)", 106 ]); 107 108 info("Sort the list"); 109 findElementWithSelector(dbg, ".outline-footer button").click(); 110 // Button becomes active to show alphabetization 111 is( 112 findElementWithSelector(dbg, ".outline-footer button").className, 113 "active", 114 "Alphabetize button is highlighted when active" 115 ); 116 117 info("Check that the list was sorted as expected"); 118 119 assertOutlineItems(dbg, [ 120 "λ1234()", 121 "λProtoClass(a)", 122 "λarrFoo(c)", 123 "λconstFunction(x)", 124 "λdoEval()", 125 "λdoNamedEval()", 126 // evaledFunc is set twice 127 "λevaledFunc()", 128 "λevaledFunc()", 129 "λletFunction(a)", 130 "λmain()", 131 "λmemFoo(a, b)", 132 "λnormalFunction(foo)", 133 "λprotoBar(x, y)", 134 "λprotoBoo(x)", 135 "λprotoFoo(foo)", 136 "class Klass", 137 "λbar()", 138 "λboo(a)", 139 "λconstructor()", 140 "λtest()", 141 "class MyClass", 142 "λ#privateFunc(a, b)", 143 "λconstructor(a, b)", 144 "λtest()", 145 ]); 146 }); 147 148 // Test empty panel when source has no function or class symbols 149 add_task(async function () { 150 const dbg = await initDebugger("doc-on-load.html", "top-level.js"); 151 await selectSource(dbg, "top-level.js", 1); 152 153 openOutlinePanel(dbg, false); 154 await waitFor( 155 () => 156 dbg.win.document.querySelector(".outline-pane-info").innerText == 157 "No functions" 158 ); 159 160 is( 161 findAllElements(dbg, "outlineItems").length, 162 0, 163 " There are no outline items when no source is selected" 164 ); 165 });