browser_dbg-fission-project-search.js (1856B)
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 "use strict"; 6 7 const TEST_COM_URI = `${URL_ROOT_COM_SSL}examples/doc_dbg-fission-frame-sources.html`; 8 9 // Testing project search for remote frames. 10 add_task(async function () { 11 // Load page and wait for sources. simple.js is loaded from 12 // the top-level document in the dot com domain, while simple2.js 13 // is loaded from the remote frame in the dot org domain 14 const dbg = await initDebuggerWithAbsoluteURL( 15 TEST_COM_URI, 16 "simple1.js", 17 "simple2.js" 18 ); 19 20 pressKey(dbg, "projectSearch"); 21 type(dbg, "foo"); 22 pressKey(dbg, "Enter"); 23 24 await waitForSearchResults(dbg, 2); 25 26 const fileResults = findAllElements(dbg, "projectSearchFileResults"); 27 const matches = findAllElements(dbg, "projectSearchExpandedResults"); 28 29 is(fileResults.length, 2, "Two results found"); 30 is(matches.length, 11, "Total no of matches found"); 31 32 // Asserts that we find a matches in the js file included in the top-level document 33 assertFileResult("simple1.js", 10); 34 // Asserts that we find the match in the js file included 35 assertFileResult("simple2.js", 1); 36 37 function assertFileResult(fileMatched, noOfMatches) { 38 // The results can be out of order so let find it from the collection 39 const match = [...fileResults].find(result => 40 result.querySelector(".file-path").innerText.includes(fileMatched) 41 ); 42 43 ok(match, `Matches were found in ${fileMatched} file.`); 44 45 const matchText = noOfMatches > 1 ? "matches" : "match"; 46 is( 47 match.querySelector(".matches-summary").innerText.trim(), 48 `(${noOfMatches} ${matchText})`, 49 `${noOfMatches} ${matchText} were found in ${fileMatched} file.` 50 ); 51 } 52 });