зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 963933) for causing devtools failures on browser_inspector_search-03.js
CLOSED TREE Backed out changeset d33b655d9fab (bug 963933) Backed out changeset ed3f61f1c32c (bug 963933) --HG-- extra : rebase_source : 4cf04bc52117beaf023151fb14601cd8cb3df35b
This commit is contained in:
Родитель
d5dc8413cf
Коммит
86c980eba4
|
@ -200,7 +200,6 @@ fail-if = fission # The selected node is in #iframe-1
|
||||||
[browser_inspector_search-06.js]
|
[browser_inspector_search-06.js]
|
||||||
[browser_inspector_search-07.js]
|
[browser_inspector_search-07.js]
|
||||||
[browser_inspector_search-08.js]
|
[browser_inspector_search-08.js]
|
||||||
[browser_inspector_search-09.js]
|
|
||||||
[browser_inspector_search-clear.js]
|
[browser_inspector_search-clear.js]
|
||||||
[browser_inspector_search-filter_context-menu.js]
|
[browser_inspector_search-filter_context-menu.js]
|
||||||
skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
|
skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
|
||||||
|
|
|
@ -1,110 +0,0 @@
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
requestLongerTimeout(2);
|
|
||||||
|
|
||||||
// Test that searching for XPaths via the search field actually selects the
|
|
||||||
// matching nodes.
|
|
||||||
|
|
||||||
const TEST_URL = URL_ROOT + "doc_inspector_search.html";
|
|
||||||
|
|
||||||
// The various states of the inspector: [key, id, isTextNode, isValid]
|
|
||||||
// [
|
|
||||||
// what key to press,
|
|
||||||
// what id should be selected after the keypress,
|
|
||||||
// is the selected node a text node,
|
|
||||||
// is the searched text valid selector
|
|
||||||
// ]
|
|
||||||
const KEY_STATES = [
|
|
||||||
["/", "b1", false, true], // /
|
|
||||||
["*", "b1", false, true], // /*
|
|
||||||
["VK_RETURN", "root", false, true], // /*
|
|
||||||
["VK_BACK_SPACE", "root", false, true], // /
|
|
||||||
["/", "root", false, true], // //
|
|
||||||
["d", "root", false, true], // //d
|
|
||||||
["i", "root", false, true], // //di
|
|
||||||
["v", "root", false, true], // //div
|
|
||||||
["VK_RETURN", "d1", false, true], // //div
|
|
||||||
["VK_RETURN", "d2", false, true], // //div
|
|
||||||
["VK_RETURN", "d1", false, true], // //div
|
|
||||||
["VK_BACK_SPACE", "d1", false, true], // //di
|
|
||||||
["VK_BACK_SPACE", "d1", false, true], // //d
|
|
||||||
["VK_BACK_SPACE", "d1", false, true], // //
|
|
||||||
["s", "d1", false, true], // //s
|
|
||||||
["p", "d1", false, true], // //sp
|
|
||||||
["a", "d1", false, true], // //spa
|
|
||||||
["n", "d1", false, true], // //span
|
|
||||||
["/", "d1", false, true], // //span/
|
|
||||||
["t", "d1", false, true], // //span/t
|
|
||||||
["e", "d1", false, true], // //span/te
|
|
||||||
["x", "d1", false, true], // //span/tex
|
|
||||||
["t", "d1", false, true], // //span/text
|
|
||||||
["(", "d1", false, true], // //span/text(
|
|
||||||
[")", "d1", false, true], // //span/text()
|
|
||||||
["VK_RETURN", "s1", false, true], // //span/text()
|
|
||||||
["VK_RETURN", "s2", true, true], // //span/text()
|
|
||||||
];
|
|
||||||
|
|
||||||
add_task(async function() {
|
|
||||||
const { inspector } = await openInspectorForURL(TEST_URL);
|
|
||||||
const { searchBox } = inspector;
|
|
||||||
|
|
||||||
await selectNode("#b1", inspector);
|
|
||||||
await focusSearchBoxUsingShortcut(inspector.panelWin);
|
|
||||||
|
|
||||||
let index = 0;
|
|
||||||
for (const [key, id, isTextNode, isValid] of KEY_STATES) {
|
|
||||||
info(index + ": Pressing key " + key + " to get id " + id + ".");
|
|
||||||
EventUtils.synthesizeKey(
|
|
||||||
key,
|
|
||||||
{ shiftKey: key === "*" },
|
|
||||||
inspector.panelWin
|
|
||||||
);
|
|
||||||
info("Got processing-done event");
|
|
||||||
|
|
||||||
if (key === "VK_RETURN") {
|
|
||||||
info("Waiting for " + (isValid ? "NO " : "") + "results");
|
|
||||||
await inspector.search.once("search-result");
|
|
||||||
}
|
|
||||||
|
|
||||||
info("Waiting for search query to complete");
|
|
||||||
await inspector.searchSuggestions._lastQuery;
|
|
||||||
|
|
||||||
if (isTextNode) {
|
|
||||||
info(
|
|
||||||
"Text node of " +
|
|
||||||
inspector.selection.nodeFront.parentNode.id +
|
|
||||||
" is selected with text " +
|
|
||||||
searchBox.value
|
|
||||||
);
|
|
||||||
|
|
||||||
is(
|
|
||||||
inspector.selection.nodeFront.nodeType,
|
|
||||||
Node.TEXT_NODE,
|
|
||||||
"Correct node is selected for state " + index
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
info(
|
|
||||||
inspector.selection.nodeFront.id +
|
|
||||||
" is selected with text " +
|
|
||||||
searchBox.value
|
|
||||||
);
|
|
||||||
|
|
||||||
const nodeFront = await getNodeFront("#" + id, inspector);
|
|
||||||
is(
|
|
||||||
inspector.selection.nodeFront,
|
|
||||||
nodeFront,
|
|
||||||
"Correct node is selected for state " + index
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
is(
|
|
||||||
!searchBox.parentNode.classList.contains("devtools-searchbox-no-match"),
|
|
||||||
isValid,
|
|
||||||
"Correct searchbox result state for state " + index
|
|
||||||
);
|
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -1,5 +1,5 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en" id="root">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Inspector Search Box Test</title>
|
<title>Inspector Search Box Test</title>
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<!-- This is a list of 2 span elements -->
|
<!-- This is a list of 2 span elements -->
|
||||||
<span id="s1">Hello, I'm a span</span>
|
<span id="s1">Hello, I'm a span</span>
|
||||||
<span class="c1" id="s2">And I am also a span but I contain more text than the other one.</span>
|
<span class="c1" id="s2">And me</span>
|
||||||
|
|
||||||
<!-- This is a collection of various things that match only once -->
|
<!-- This is a collection of various things that match only once -->
|
||||||
<p class="c1" id="p1">.someclass</p>
|
<p class="c1" id="p1">.someclass</p>
|
||||||
|
|
|
@ -546,7 +546,6 @@ async function getBackgroundColor({ rawNode: node, walker }) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
allAnonymousContentTreeWalkerFilter,
|
allAnonymousContentTreeWalkerFilter,
|
||||||
isWhitespaceTextNode,
|
|
||||||
findGridParentContainerForNode,
|
findGridParentContainerForNode,
|
||||||
getBackgroundColor,
|
getBackgroundColor,
|
||||||
getClosestBackgroundColor,
|
getClosestBackgroundColor,
|
||||||
|
|
|
@ -1268,46 +1268,6 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
|
||||||
return new NodeListActor(this, this._multiFrameQuerySelectorAll(selector));
|
return new NodeListActor(this, this._multiFrameQuerySelectorAll(selector));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of nodes that match the given XPath in all known frames of
|
|
||||||
* the current content page.
|
|
||||||
* @param {String} xPath.
|
|
||||||
* @return {Array}
|
|
||||||
*/
|
|
||||||
_multiFrameXPath: function(xPath) {
|
|
||||||
const nodes = [];
|
|
||||||
|
|
||||||
for (const window of this.targetActor.windows) {
|
|
||||||
const document = window.document;
|
|
||||||
try {
|
|
||||||
const result = document.evaluate(
|
|
||||||
xPath,
|
|
||||||
document.documentElement,
|
|
||||||
null,
|
|
||||||
window.XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
|
|
||||||
null
|
|
||||||
);
|
|
||||||
|
|
||||||
for (let i = 0; i < result.snapshotLength; i++) {
|
|
||||||
nodes.push(result.snapshotItem(i));
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// Bad XPath. Do nothing as the XPath can come from a searchbox.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nodes;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a NodeListActor with all nodes that match the given XPath in all
|
|
||||||
* frames of the current content page.
|
|
||||||
* @param {String} xPath
|
|
||||||
*/
|
|
||||||
multiFrameXPath: function(xPath) {
|
|
||||||
return new NodeListActor(this, this._multiFrameXPath(xPath));
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search the document for a given string.
|
* Search the document for a given string.
|
||||||
* Results will be searched with the walker-search module (searches through
|
* Results will be searched with the walker-search module (searches through
|
||||||
|
|
|
@ -4,13 +4,6 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
loader.lazyRequireGetter(
|
|
||||||
this,
|
|
||||||
"isWhitespaceTextNode",
|
|
||||||
"devtools/server/actors/inspector/utils",
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The walker-search module provides a simple API to index and search strings
|
* The walker-search module provides a simple API to index and search strings
|
||||||
* and elements inside a given document.
|
* and elements inside a given document.
|
||||||
|
@ -209,29 +202,13 @@ WalkerSearch.prototype = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_searchXPath: function(query, options, results) {
|
|
||||||
const isXPath = query && query.startsWith("/");
|
|
||||||
if (!options.types.includes("xpath") || !isXPath) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const nodes = this.walker._multiFrameXPath(query);
|
|
||||||
for (const node of nodes) {
|
|
||||||
// Exclude text nodes that only contain whitespace
|
|
||||||
// because they are not displayed in the Inspector.
|
|
||||||
if (!isWhitespaceTextNode(node)) {
|
|
||||||
this._addResult(node, "xpath", results);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search the document
|
* Search the document
|
||||||
* @param {String} query What to search for
|
* @param {String} query What to search for
|
||||||
* @param {Object} options The following options are accepted:
|
* @param {Object} options The following options are accepted:
|
||||||
* - searchMethod {String} one of WalkerSearch.SEARCH_METHOD_*
|
* - searchMethod {String} one of WalkerSearch.SEARCH_METHOD_*
|
||||||
* defaults to WalkerSearch.SEARCH_METHOD_CONTAINS (does not apply to
|
* defaults to WalkerSearch.SEARCH_METHOD_CONTAINS (does not apply to
|
||||||
* selector and XPath search types)
|
* selector search type)
|
||||||
* - types {Array} a list of things to search for (tag, text, attributes, etc)
|
* - types {Array} a list of things to search for (tag, text, attributes, etc)
|
||||||
* defaults to WalkerSearch.ALL_RESULTS_TYPES
|
* defaults to WalkerSearch.ALL_RESULTS_TYPES
|
||||||
* @return {Array} An array is returned with each item being an object like:
|
* @return {Array} An array is returned with each item being an object like:
|
||||||
|
@ -259,9 +236,6 @@ WalkerSearch.prototype = {
|
||||||
// Search with querySelectorAll
|
// Search with querySelectorAll
|
||||||
this._searchSelectors(query, options, results);
|
this._searchSelectors(query, options, results);
|
||||||
|
|
||||||
// Search with XPath
|
|
||||||
this._searchXPath(query, options, results);
|
|
||||||
|
|
||||||
// Concatenate all results into an Array to return
|
// Concatenate all results into an Array to return
|
||||||
const resultList = [];
|
const resultList = [];
|
||||||
for (const [node, matches] of results) {
|
for (const [node, matches] of results) {
|
||||||
|
@ -308,7 +282,6 @@ WalkerSearch.ALL_RESULTS_TYPES = [
|
||||||
"attributeName",
|
"attributeName",
|
||||||
"attributeValue",
|
"attributeValue",
|
||||||
"selector",
|
"selector",
|
||||||
"xpath",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
exports.WalkerSearch = WalkerSearch;
|
exports.WalkerSearch = WalkerSearch;
|
||||||
|
|
|
@ -152,37 +152,6 @@ add_task(async function() {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
desc: "Search for XPath with one result",
|
|
||||||
search: "//strong",
|
|
||||||
expected: [
|
|
||||||
{ node: inspectee.querySelector("strong"), type: "xpath" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
desc: "Search for XPath with multiple results",
|
|
||||||
search: "//h2",
|
|
||||||
expected: [
|
|
||||||
{ node: inspectee.querySelectorAll("h2")[0], type: "xpath" },
|
|
||||||
{ node: inspectee.querySelectorAll("h2")[1], type: "xpath" },
|
|
||||||
{ node: inspectee.querySelectorAll("h2")[2], type: "xpath" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
desc: "Search for XPath via containing text",
|
|
||||||
search: "//*[contains(text(), 'p tag')]",
|
|
||||||
expected: [{ node: inspectee.querySelector("p"), type: "xpath" }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
desc: "Search for XPath matching text node",
|
|
||||||
search: "//strong/text()",
|
|
||||||
expected: [
|
|
||||||
{
|
|
||||||
node: inspectee.querySelector("strong").firstChild,
|
|
||||||
type: "xpath",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const isDeeply = (a, b, msg) => {
|
const isDeeply = (a, b, msg) => {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче