Bug 1635970 - Extended support for XPath expressions in Inspector search. r=jdescottes

The limitation to expressions starting with a slash was lifted in order to allow searching via other possible XPath expressions like `id("foo")` or `(//div)[2]`.

Differential Revision: https://phabricator.services.mozilla.com/D80963
This commit is contained in:
Sebastian Zartner 2020-06-25 18:32:40 +00:00
Родитель e4bc88f3e9
Коммит 63db1cbfbc
2 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -210,8 +210,7 @@ WalkerSearch.prototype = {
},
_searchXPath: function(query, options, results) {
const isXPath = query && query.startsWith("/");
if (!options.types.includes("xpath") || !isXPath) {
if (!options.types.includes("xpath")) {
return;
}

Просмотреть файл

@ -183,6 +183,18 @@ add_task(async function() {
},
],
},
{
desc: "Search using XPath grouping expression",
search: "(//*)[2]",
expected: [{ node: inspectee.querySelector("head"), type: "xpath" }],
},
{
desc: "Search using XPath function",
search: "id('arrows')",
expected: [
{ node: inspectee.querySelector("#arrows"), type: "xpath" },
],
},
];
const isDeeply = (a, b, msg) => {