Bug 1146566 - 2 - Avoid using CPOWs in test browser_markupview_tag_edit_03.js; r=bgrins

This change updates the browser_markupview_tag_edit_03.js test by making use of the
getDomElementInfo message listener to retrieve information about the tested nodes
without having to go through CPOWs.

--HG--
extra : rebase_source : 550d6fdf0baa4557be024e42de1e9b7f03652b0b
extra : histedit_source : 65f0bdbdb1b315783b101eb54b2f405c03a1f79d
This commit is contained in:
Patrick Brosset 2015-03-24 10:55:02 +01:00
parent 9900719f1f
commit 618f4cbb94
2 changed files with 32 additions and 12 deletions

View File

@ -14,26 +14,37 @@ add_task(function*() {
yield inspector.markup.expandAll();
info("Selecting the test node");
let node = content.document.querySelector("#retag-me");
let child = content.document.querySelector("#retag-me-2");
yield selectNode("#retag-me", inspector);
info("Getting the markup-container for the test node");
let container = yield getContainerForSelector("#retag-me", inspector);
is(node.tagName, "DIV", "We've got #retag-me element, it's a DIV");
ok(container.expanded, "It is expanded");
is(child.parentNode, node, "Child #retag-me-2 is inside #retag-me");
ok(container.expanded, "The container is expanded");
info("Changing the tagname");
let parentInfo = yield getNodeInfo("#retag-me");
is(parentInfo.tagName.toLowerCase(), "div",
"We've got #retag-me element, it's a DIV");
is(parentInfo.numChildren, 1, "#retag-me has one child");
let childInfo = yield getNodeInfo("#retag-me > *");
is(childInfo.attributes[0].value, "retag-me-2",
"#retag-me's only child is #retag-me-2");
info("Changing #retag-me's tagname in the markup-view");
let mutated = inspector.once("markupmutation");
let tagEditor = container.editor.tag;
setEditableFieldValue(tagEditor, "p", inspector);
yield mutated;
info("Checking that the tagname change was done");
node = content.document.querySelector("#retag-me");
info("Checking that the markup-container exists and is correct");
container = yield getContainerForSelector("#retag-me", inspector);
is(node.tagName, "P", "We've got #retag-me, it should now be a P");
ok(container.expanded, "It is still expanded");
ok(container.selected, "It is still selected");
is(child.parentNode, node, "Child #retag-me-2 is still inside #retag-me");
ok(container.expanded, "The container is still expanded");
ok(container.selected, "The container is still selected");
info("Checking that the tagname change was done");
parentInfo = yield 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 = yield getNodeInfo("#retag-me > *");
is(childInfo.attributes[0].value, "retag-me-2",
"#retag-me's only child is #retag-me-2");
});

View File

@ -200,6 +200,15 @@ function getNodeFront(selector, {walker}) {
return walker.querySelector(walker.rootNode, selector);
}
/**
* Get information about a DOM element, identified by its selector.
* @param {String} selector.
* @return {Promise} a promise that resolves to the element's information.
*/
function getNodeInfo(selector) {
return executeInContent("devtools:test:getDomElementInfo", {selector});
}
/**
* Highlight a node and set the inspector's current selection to the node or
* the first match of the given css selector.