Bug 1714560 - [devtools] Remove testActor#getNodeInfo. r=jdescottes.

The methods is replaced by adhoc SpecialPowers.spawn task
or when possible with getContentPageElementProperty calls.

Depends on D117018

Differential Revision: https://phabricator.services.mozilla.com/D116964
This commit is contained in:
Nicolas Chevobbe 2021-06-07 16:12:45 +00:00
Родитель 412f5b015d
Коммит 3ac9365683
15 изменённых файлов: 178 добавлений и 211 удалений

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

@ -68,6 +68,6 @@ var TEST_DATA = [
];
add_task(async function() {
const { inspector, testActor } = await openInspectorForURL(TEST_URL);
await runEditAttributesTests(TEST_DATA, inspector, testActor);
const { inspector } = await openInspectorForURL(TEST_URL);
await runEditAttributesTests(TEST_DATA, inspector);
});

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

@ -10,19 +10,15 @@ const TEST_URL = `data:text/html,
add_task(async function() {
info("Opening the inspector on the test page");
const { inspector, testActor } = await openInspectorForURL(TEST_URL);
const { inspector } = await openInspectorForURL(TEST_URL);
info("Selecting the test node");
await focusNode("#test-div", inspector);
info("Verify attributes, only ID should be there for now");
await assertAttributes(
"#test-div",
{
id: "test-div",
},
testActor
);
await assertAttributes("#test-div", {
id: "test-div",
});
info("Focus the ID attribute and change its content");
const { editor } = await getContainerForSelector("#test-div", inspector);
@ -36,23 +32,15 @@ add_task(async function() {
await mutated;
info("Verify attributes, should have ID, class and style");
await assertAttributes(
"#test-div",
{
id: "test-div",
class: "newclass",
style: "color:green",
},
testActor
);
await assertAttributes("#test-div", {
id: "test-div",
class: "newclass",
style: "color:green",
});
info("Trying to undo the change");
await undoChange(inspector);
await assertAttributes(
"#test-div",
{
id: "test-div",
},
testActor
);
await assertAttributes("#test-div", {
id: "test-div",
});
});

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

@ -9,7 +9,7 @@ const TEST_URL = `data:text/html;charset=utf-8,
<div id='retag-me'><div id='retag-me-2'></div></div>`;
add_task(async function() {
const { inspector, testActor } = await openInspectorForURL(TEST_URL);
const { inspector } = await openInspectorForURL(TEST_URL);
await inspector.markup.expandAll();
@ -20,16 +20,19 @@ add_task(async function() {
let container = await getContainerForSelector("#retag-me", inspector);
ok(container.expanded, "The container is expanded");
let parentInfo = await testActor.getNodeInfo("#retag-me");
is(
parentInfo.tagName.toLowerCase(),
(await getContentPageElementProperty("#retag-me", "tagName")).toLowerCase(),
"div",
"We've got #retag-me element, it's a DIV"
);
is(parentInfo.numChildren, 1, "#retag-me has one child");
let childInfo = await testActor.getNodeInfo("#retag-me > *");
is(
childInfo.attributes[0].value,
await getContentPageElementProperty("#retag-me", "childElementCount"),
1,
"#retag-me has one child"
);
is(
await getContentPageElementProperty("#retag-me > *", "id"),
"retag-me-2",
"#retag-me's only child is #retag-me-2"
);
@ -46,12 +49,19 @@ add_task(async function() {
ok(container.selected, "The container is still selected");
info("Checking that the tagname change was done");
parentInfo = await testActor.getNodeInfo("#retag-me");
is(parentInfo.tagName.toLowerCase(), "p", "The #retag-me element is now a P");
is(parentInfo.numChildren, 1, "#retag-me still has one child");
childInfo = await testActor.getNodeInfo("#retag-me > *");
is(
childInfo.attributes[0].value,
(await getContentPageElementProperty("#retag-me", "tagName")).toLowerCase(),
"p",
"The #retag-me element is now a P"
);
is(
await getContentPageElementProperty("#retag-me", "childElementCount"),
1,
"#retag-me still has one child"
);
is(
await getContentPageElementProperty("#retag-me > *", "id"),
"retag-me-2",
"#retag-me's only child is #retag-me-2"
);

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

@ -80,6 +80,6 @@ var TEST_DATA = [
];
add_task(async function() {
const { inspector, testActor } = await openInspectorForURL(TEST_URL);
await runAddAttributesTests(TEST_DATA, "div", inspector, testActor);
const { inspector } = await openInspectorForURL(TEST_URL);
await runAddAttributesTests(TEST_DATA, "div", inspector);
});

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

@ -90,6 +90,6 @@ var TEST_DATA = [
];
add_task(async function() {
const { inspector, testActor } = await openInspectorForURL(TEST_URL);
await runAddAttributesTests(TEST_DATA, "div", inspector, testActor);
const { inspector } = await openInspectorForURL(TEST_URL);
await runAddAttributesTests(TEST_DATA, "div", inspector);
});

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

@ -9,12 +9,18 @@
loadHelperScript("helper_attributes_test_runner.js");
/*eslint-disable */
const LONG_ATTRIBUTE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const LONG_ATTRIBUTE_COLLAPSED = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEF\u2026UVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const DATA_URL_INLINE_STYLE='color: red; background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC");';
const DATA_URL_INLINE_STYLE_COLLAPSED='color: red; background: url("data:image/png;base64,iVBORw0KG\u2026NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC");';
const DATA_URL_ATTRIBUTE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC";
const DATA_URL_ATTRIBUTE_COLLAPSED = "data:image/png;base64,iVBORw0K\u20269/AFGGFyjOXZtQAAAAAElFTkSuQmCC";
const LONG_ATTRIBUTE =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const LONG_ATTRIBUTE_COLLAPSED =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEF\u2026UVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ-ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const DATA_URL_INLINE_STYLE =
'color: red; background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC");';
const DATA_URL_INLINE_STYLE_COLLAPSED =
'color: red; background: url("data:image/png;base64,iVBORw0KG\u2026NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC");';
const DATA_URL_ATTRIBUTE =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC";
const DATA_URL_ATTRIBUTE_COLLAPSED =
"data:image/png;base64,iVBORw0K\u20269/AFGGFyjOXZtQAAAAAElFTkSuQmCC";
/* eslint-enable */
var TEST_URL = "data:text/html,<div>markup-view attributes addition test</div>";
@ -141,6 +147,6 @@ var TEST_DATA = [
];
add_task(async function() {
const { inspector, testActor } = await openInspectorForURL(TEST_URL);
await runAddAttributesTests(TEST_DATA, "div", inspector, testActor);
const { inspector } = await openInspectorForURL(TEST_URL);
await runAddAttributesTests(TEST_DATA, "div", inspector);
});

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

@ -15,15 +15,15 @@ const LONG_ATTRIBUTE_COLLAPSED =
/* eslint-enable */
add_task(async function() {
const { inspector, testActor } = await openInspectorForURL(TEST_URL);
const { inspector } = await openInspectorForURL(TEST_URL);
await inspector.markup.expandAll();
await testCollapsedLongAttribute(inspector, testActor);
await testModifyInlineStyleWithQuotes(inspector, testActor);
await testEditingAttributeWithMixedQuotes(inspector, testActor);
await testCollapsedLongAttribute(inspector);
await testModifyInlineStyleWithQuotes(inspector);
await testEditingAttributeWithMixedQuotes(inspector);
});
async function testCollapsedLongAttribute(inspector, testActor) {
async function testCollapsedLongAttribute(inspector) {
info("Try to modify the collapsed long attribute, making sure it expands.");
info("Adding test attributes to the node");
@ -35,15 +35,11 @@ async function testCollapsedLongAttribute(inspector, testActor) {
await setContentPageElementAttribute("#node24", "data-long", LONG_ATTRIBUTE);
await onMutation;
await assertAttributes(
"#node24",
{
id: "node24",
class: "",
"data-long": LONG_ATTRIBUTE,
},
testActor
);
await assertAttributes("#node24", {
id: "node24",
class: "",
"data-long": LONG_ATTRIBUTE,
});
const { editor } = await focusNode("#node24", inspector);
const attr = editor.attrElements.get("data-long").querySelector(".editable");
@ -63,30 +59,22 @@ async function testCollapsedLongAttribute(inspector, testActor) {
.querySelector(".attr-value").textContent;
is(visibleAttrText, LONG_ATTRIBUTE_COLLAPSED);
await assertAttributes(
"#node24",
{
id: "node24",
class: "",
"data-long": LONG_ATTRIBUTE,
"data-short": "ABC",
},
testActor
);
await assertAttributes("#node24", {
id: "node24",
class: "",
"data-long": LONG_ATTRIBUTE,
"data-short": "ABC",
});
}
async function testModifyInlineStyleWithQuotes(inspector, testActor) {
async function testModifyInlineStyleWithQuotes(inspector) {
info('Modify inline style containing "');
await assertAttributes(
"#node26",
{
id: "node26",
style:
'background-image: url("moz-page-thumb://thumbnail?url=http%3A%2F%2Fwww.mozilla.org%2F");',
},
testActor
);
await assertAttributes("#node26", {
id: "node26",
style:
'background-image: url("moz-page-thumb://thumbnail?url=http%3A%2F%2Fwww.mozilla.org%2F");',
});
const onMutated = inspector.once("markupmutation");
const { editor } = await focusNode("#node26", inspector);
@ -111,28 +99,20 @@ async function testModifyInlineStyleWithQuotes(inspector, testActor) {
await onMutated;
await assertAttributes(
"#node26",
{
id: "node26",
style:
'background-image: url("moz-page-thumb://thumbnail?url=http%3A%2F%2Fwww.mozilla.com%2F");',
},
testActor
);
await assertAttributes("#node26", {
id: "node26",
style:
'background-image: url("moz-page-thumb://thumbnail?url=http%3A%2F%2Fwww.mozilla.com%2F");',
});
}
async function testEditingAttributeWithMixedQuotes(inspector, testActor) {
async function testEditingAttributeWithMixedQuotes(inspector) {
info("Modify class containing \" and '");
await assertAttributes(
"#node27",
{
id: "node27",
class: "Double \" and single '",
},
testActor
);
await assertAttributes("#node27", {
id: "node27",
class: "Double \" and single '",
});
const onMutated = inspector.once("markupmutation");
const { editor } = await focusNode("#node27", inspector);
@ -153,12 +133,8 @@ async function testEditingAttributeWithMixedQuotes(inspector, testActor) {
await onMutated;
await assertAttributes(
"#node27",
{
id: "node27",
class: "\" \" and ' '",
},
testActor
);
await assertAttributes("#node27", {
id: "node27",
class: "\" \" and ' '",
});
}

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

@ -8,16 +8,16 @@
const TEST_URL = URL_ROOT + "doc_markup_svg_attributes.html";
add_task(async function() {
const { inspector, testActor } = await openInspectorForURL(TEST_URL);
const { inspector } = await openInspectorForURL(TEST_URL);
await inspector.markup.expandAll();
await selectNode("svg", inspector);
await testWellformedMixedCase(inspector, testActor);
await testMalformedMixedCase(inspector, testActor);
await testWellformedMixedCase(inspector);
await testMalformedMixedCase(inspector);
});
async function testWellformedMixedCase(inspector, testActor) {
async function testWellformedMixedCase(inspector) {
info(
"Modifying a mixed-case attribute, " +
"expecting the attribute's case to be preserved"
@ -38,18 +38,14 @@ async function testWellformedMixedCase(inspector, testActor) {
EventUtils.sendKey("return", inspector.panelWin);
await onMutated;
await assertAttributes(
"svg",
{
viewBox: "0 0 1 1",
width: "200",
height: "200",
},
testActor
);
await assertAttributes("svg", {
viewBox: "0 0 1 1",
width: "200",
height: "200",
});
}
async function testMalformedMixedCase(inspector, testActor) {
async function testMalformedMixedCase(inspector) {
info(
"Modifying a malformed, mixed-case attribute, " +
"expecting the attribute's case to be preserved"
@ -70,13 +66,9 @@ async function testMalformedMixedCase(inspector, testActor) {
EventUtils.sendKey("return", inspector.panelWin);
await onMutated;
await assertAttributes(
"svg",
{
viewBox: "<>",
width: "200",
height: "200",
},
testActor
);
await assertAttributes("svg", {
viewBox: "<>",
width: "200",
height: "200",
});
}

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

@ -8,7 +8,7 @@
const TEST_URL = URL_ROOT + "doc_markup_whitespace.html";
add_task(async function() {
const { inspector, testActor } = await openInspectorForURL(TEST_URL);
const { inspector } = await openInspectorForURL(TEST_URL);
const { markup } = inspector;
await markup.expandAll();
@ -17,9 +17,16 @@ add_task(async function() {
// Body has 5 element children, but there are 6 text nodes in there too, they come from
// the HTML file formatting (spaces and carriage returns).
let { numNodes, numChildren } = await testActor.getNodeInfo("body");
is(numNodes, 11, "The body node has 11 child nodes (includes text nodes)");
is(numChildren, 5, "The body node has 5 child elements (only element nodes)");
is(
await getElementChildNodesCount("body"),
11,
"The body node has 11 child nodes (includes text nodes)"
);
is(
await getContentPageElementProperty("body", "childElementCount"),
5,
"The body node has 5 child elements (only element nodes)"
);
// In body, there are only block-level elements, so whitespace text nodes do not have
// layout, so they should be skipped in the markup-view.
@ -35,14 +42,13 @@ add_task(async function() {
// div#inline has 3 element children, but there are 4 text nodes in there too, like in
// body, they come from spaces and carriage returns in the HTML file.
info("Verify the number of child nodes and child elements in div#inline");
({ numNodes, numChildren } = await testActor.getNodeInfo("#inline"));
is(
numNodes,
await getElementChildNodesCount("#inline"),
7,
"The div#inline node has 7 child nodes (includes text nodes)"
);
is(
numChildren,
await getContentPageElementProperty("#inline", "childElementCount"),
3,
"The div#inline node has 3 child elements (only element nodes)"
);
@ -62,10 +68,13 @@ add_task(async function() {
// div#pre has 2 element children, but there are 3 text nodes in there too, like in
// div#inline, they come from spaces and carriage returns in the HTML file.
info("Verify the number of child nodes and child elements in div#pre");
({ numNodes, numChildren } = await testActor.getNodeInfo("#pre"));
is(numNodes, 5, "The div#pre node has 5 child nodes (includes text nodes)");
is(
numChildren,
await getElementChildNodesCount("#pre"),
5,
"The div#pre node has 5 child nodes (includes text nodes)"
);
is(
await getContentPageElementProperty("#pre", "childElementCount"),
2,
"The div#pre node has 2 child elements (only element nodes)"
);
@ -84,3 +93,12 @@ add_task(async function() {
"Both the element nodes and all text nodes are shown in the markup view"
);
});
function getElementChildNodesCount(selector) {
return SpecialPowers.spawn(gBrowser.selectedBrowser, [selector], function(
innerSelector
) {
const node = content.document.querySelector(innerSelector);
return node.childNodes.length;
});
}

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

@ -215,21 +215,19 @@ var addNewAttributes = async function(selector, text, inspector) {
* @param {String} selector The selector for the node to check.
* @param {Object} expected An object containing the attributes to check.
* e.g. {id: "id1", class: "someclass"}
* @param {TestActorFront} testActor The current TestActorFront instance.
*
* Note that node.getAttribute() returns attribute values provided by the HTML
* parser. The parser only provides unescaped entities so &amp; will return &.
*/
var assertAttributes = async function(selector, expected, testActor) {
const { attributes: actual } = await testActor.getNodeInfo(selector);
var assertAttributes = async function(selector, expected) {
const actualAttributes = await getContentPageElementAttributes(selector);
is(
actual.length,
actualAttributes.length,
Object.keys(expected).length,
"The node " + selector + " has the expected number of attributes."
);
for (const attr in expected) {
const foundAttr = actual.find(({ name }) => name === attr);
const foundAttr = actualAttributes.find(({ name }) => name === attr);
const foundValue = foundAttr ? foundAttr.value : undefined;
ok(foundAttr, "The node " + selector + " has the attribute " + attr);
is(

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

@ -18,17 +18,16 @@
* when the test starts. It will be used to add and remove attributes.
* @param {InspectorPanel} inspector The instance of InspectorPanel currently
* opened
* @param {TestActorFront} testActor The current TestActorFront instance.
* @return a promise that resolves when the tests have run
*/
function runAddAttributesTests(tests, nodeOrSelector, inspector, testActor) {
function runAddAttributesTests(tests, nodeOrSelector, inspector) {
info("Running " + tests.length + " add-attributes tests");
return (async function() {
info("Selecting the test node");
await selectNode("div", inspector);
for (const test of tests) {
await runAddAttributesTest(test, "div", inspector, testActor);
await runAddAttributesTest(test, "div", inspector);
}
})();
}
@ -51,10 +50,9 @@ function runAddAttributesTests(tests, nodeOrSelector, inspector, testActor) {
* - {InspectorPanel} The instance of the InspectorPanel opened
* @param {String} selector The node selector corresponding to the test element
* @param {InspectorPanel} inspector The instance of InspectorPanel currently
* @param {TestActorFront} testActor The current TestActorFront instance.
* opened
*/
async function runAddAttributesTest(test, selector, inspector, testActor) {
async function runAddAttributesTest(test, selector, inspector) {
if (test.setUp) {
test.setUp(inspector);
}
@ -63,7 +61,7 @@ async function runAddAttributesTest(test, selector, inspector, testActor) {
await addNewAttributes(selector, test.text, inspector);
info("Assert that the attribute(s) has/have been applied correctly");
await assertAttributes(selector, test.expectedAttributes, testActor);
await assertAttributes(selector, test.expectedAttributes);
if (test.validate) {
const container = await getContainerForSelector(selector, inspector);
@ -74,7 +72,7 @@ async function runAddAttributesTest(test, selector, inspector, testActor) {
await undoChange(inspector);
info("Assert that the attribute(s) has/have been removed correctly");
await assertAttributes(selector, {}, testActor);
await assertAttributes(selector, {});
if (test.tearDown) {
test.tearDown(inspector);
}
@ -91,17 +89,16 @@ async function runAddAttributesTest(test, selector, inspector, testActor) {
* @param {Array} tests See runEditAttributesTest for the structure
* @param {InspectorPanel} inspector The instance of InspectorPanel currently
* opened
* @param {TestActorFront} testActor The current TestActorFront instance.
* @return a promise that resolves when the tests have run
*/
function runEditAttributesTests(tests, inspector, testActor) {
function runEditAttributesTests(tests, inspector) {
info("Running " + tests.length + " edit-attributes tests");
return (async function() {
info("Expanding all nodes in the markup-view");
await inspector.markup.expandAll();
for (const test of tests) {
await runEditAttributesTest(test, inspector, testActor);
await runEditAttributesTest(test, inspector);
}
})();
}
@ -121,17 +118,16 @@ function runEditAttributesTests(tests, inspector, testActor) {
* - expectedAttributes {Object} a key/value pair object that will be
* used to check the attributes on the test element
* @param {InspectorPanel} inspector The instance of InspectorPanel currently
* @param {TestActorFront} testActor The current TestActorFront instance.
* opened
*/
async function runEditAttributesTest(test, inspector, testActor) {
async function runEditAttributesTest(test, inspector) {
info("Starting edit-attribute test: " + test.desc);
info("Selecting the test node " + test.node);
await selectNode(test.node, inspector);
info("Asserting that the node has the right attributes to start with");
await assertAttributes(test.node, test.originalAttributes, testActor);
await assertAttributes(test.node, test.originalAttributes);
info("Editing attribute " + test.name + " with value " + test.value);
@ -150,16 +146,16 @@ async function runEditAttributesTest(test, inspector, testActor) {
await nodeMutated;
info("Asserting the new attributes after edition");
await assertAttributes(test.node, test.expectedAttributes, testActor);
await assertAttributes(test.node, test.expectedAttributes);
info("Undo the change and assert that the attributes have been changed back");
await undoChange(inspector);
await assertAttributes(test.node, test.originalAttributes, testActor);
await assertAttributes(test.node, test.originalAttributes);
info(
"Redo the change and assert that the attributes have been changed " +
"again"
);
await redoChange(inspector);
await assertAttributes(test.node, test.expectedAttributes, testActor);
await assertAttributes(test.node, test.expectedAttributes);
}

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

@ -78,7 +78,11 @@ async function runEditOuterHTMLTest(test, inspector, testActor) {
selectedNodeFront,
"Original node (grabbed by selector) is selected"
);
const { outerHTML } = await testActor.getNodeInfo(test.selector);
const outerHTML = await getContentPageElementProperty(
test.selector,
"outerHTML"
);
is(outerHTML, test.newHTML, "Outer HTML has been updated");
}

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

@ -850,6 +850,26 @@ function setContentPageElementProperty(selector, propertyName, propertyValue) {
);
}
/**
* Get all the attributes for a DOM Node living in the content page.
*
* @param {String} selector The node selector
* @returns {Array<Object>} An array of {name, value} objects.
*/
async function getContentPageElementAttributes(selector) {
return SpecialPowers.spawn(
gBrowser.selectedBrowser,
[selector],
_selector => {
const node = content.document.querySelector(_selector);
return Array.from(node.attributes).map(({ name, value }) => ({
name,
value,
}));
}
);
}
/**
* Get an attribute on a DOM Node living in the content page.
*

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

@ -183,14 +183,6 @@ var testSpec = protocol.generateActorSpec({
value: RetVal("json"),
},
},
getNodeInfo: {
request: {
selector: Arg(0, "string"),
},
response: {
value: RetVal("json"),
},
},
getStyleSheetsInfoForNode: {
request: {
selector: Arg(0, "string"),
@ -536,43 +528,6 @@ var TestActor = protocol.ActorClassWithSpec(testSpec, {
return getAdjustedQuads(this.content, node)[0].bounds;
},
/**
* Get information about a DOM element, identified by a selector.
* @param {String} selector The CSS selector to get the node (can be an array
* of selectors to get elements in an iframe).
* @return {Object} data Null if selector didn't match any node, otherwise:
* - {String} tagName.
* - {String} namespaceURI.
* - {Number} numChildren The number of children in the element.
* - {Array} attributes An array of {name, value, namespaceURI} objects.
* - {String} outerHTML.
* - {String} innerHTML.
* - {String} textContent.
*/
getNodeInfo: function(selector) {
const node = this._querySelector(selector);
let info = null;
if (node) {
info = {
tagName: node.tagName,
namespaceURI: node.namespaceURI,
numChildren: node.children.length,
numNodes: node.childNodes.length,
attributes: [...node.attributes].map(
({ name, value, namespaceURI }) => {
return { name, value, namespaceURI };
}
),
outerHTML: node.outerHTML,
innerHTML: node.innerHTML,
textContent: node.textContent,
};
}
return info;
},
/**
* Get information about the stylesheets which have CSS rules that apply to a given DOM
* element, identified by a selector.

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

@ -44,7 +44,11 @@ add_task(async function() {
);
ok(true, "correct output for $0 after setting $0.textContent");
const { textContent } = await testActor.getNodeInfo("h1");
const textContent = await SpecialPowers.spawn(
gBrowser.selectedBrowser,
[],
() => content.document.querySelector("h1").textContent
);
is(textContent, newH1Content, "node successfully updated");
});