зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1714010 - [devtools] Remove testActor#setProperty. r=jdescottes.
The method is replaced by an helper in shared-head that uses SpecialPowers.spawn to access the element. Depends on D116556 Differential Revision: https://phabricator.services.mozilla.com/D116557
This commit is contained in:
Родитель
28ba5d4a26
Коммит
3f3226c8d7
|
@ -16,7 +16,7 @@ const TEST_URL = URL_ROOT + "doc_markup_mutation.html";
|
|||
const TEST_DATA = [
|
||||
{
|
||||
desc: "Adding an attribute",
|
||||
test: async function(testActor) {
|
||||
test: async function() {
|
||||
const browser = gBrowser.selectedBrowser;
|
||||
await setAttributeInBrowser(browser, "#node1", "newattr", "newattrval");
|
||||
},
|
||||
|
@ -36,7 +36,7 @@ const TEST_DATA = [
|
|||
},
|
||||
{
|
||||
desc: "Removing an attribute",
|
||||
test: async function(testActor) {
|
||||
test: async function() {
|
||||
const browser = gBrowser.selectedBrowser;
|
||||
await removeAttributeInBrowser(browser, "#node1", "newattr");
|
||||
},
|
||||
|
@ -52,7 +52,7 @@ const TEST_DATA = [
|
|||
},
|
||||
{
|
||||
desc: "Re-adding an attribute",
|
||||
test: async function(testActor) {
|
||||
test: async function() {
|
||||
const browser = gBrowser.selectedBrowser;
|
||||
await setAttributeInBrowser(browser, "#node1", "newattr", "newattrval");
|
||||
},
|
||||
|
@ -97,7 +97,7 @@ const TEST_DATA = [
|
|||
},
|
||||
{
|
||||
desc: "Adding another attribute does not rerender unchanged attributes",
|
||||
test: async function(testActor, inspector) {
|
||||
test: async function(inspector) {
|
||||
const { editor } = await getContainerForSelector("#node1", inspector);
|
||||
|
||||
// This test checks the impact on the markup-view nodes after setting attributes on
|
||||
|
@ -144,7 +144,7 @@ const TEST_DATA = [
|
|||
{
|
||||
desc: "Adding ::after element",
|
||||
numMutations: 2,
|
||||
test: async function(testActor) {
|
||||
test: async function() {
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
|
||||
const node1 = content.document.querySelector("#node1");
|
||||
node1.classList.add("pseudo");
|
||||
|
@ -162,7 +162,7 @@ const TEST_DATA = [
|
|||
{
|
||||
desc: "Removing ::after element",
|
||||
numMutations: 2,
|
||||
test: async function(testActor) {
|
||||
test: async function() {
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
|
||||
const node1 = content.document.querySelector("#node1");
|
||||
node1.classList.remove("pseudo");
|
||||
|
@ -175,8 +175,8 @@ const TEST_DATA = [
|
|||
},
|
||||
{
|
||||
desc: "Updating the text-content",
|
||||
test: async function(testActor) {
|
||||
await testActor.setProperty("#node1", "textContent", "newtext");
|
||||
test: async function() {
|
||||
await setContentPageElementProperty("#node1", "textContent", "newtext");
|
||||
},
|
||||
check: async function(inspector) {
|
||||
const container = await getContainerForSelector("#node1", inspector);
|
||||
|
@ -192,7 +192,7 @@ const TEST_DATA = [
|
|||
},
|
||||
{
|
||||
desc: "Adding a second text child",
|
||||
test: async function(testActor) {
|
||||
test: async function() {
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
|
||||
const node1 = content.document.querySelector("#node1");
|
||||
const newText = node1.ownerDocument.createTextNode("more");
|
||||
|
@ -211,8 +211,8 @@ const TEST_DATA = [
|
|||
},
|
||||
{
|
||||
desc: "Go from 2 to 1 text child",
|
||||
test: async function(testActor) {
|
||||
await testActor.setProperty("#node1", "textContent", "newtext");
|
||||
test: async function() {
|
||||
await setContentPageElementProperty("#node1", "textContent", "newtext");
|
||||
},
|
||||
check: async function(inspector) {
|
||||
const container = await getContainerForSelector("#node1", inspector);
|
||||
|
@ -228,8 +228,8 @@ const TEST_DATA = [
|
|||
},
|
||||
{
|
||||
desc: "Removing an only text child",
|
||||
test: async function(testActor) {
|
||||
await testActor.setProperty("#node1", "innerHTML", "");
|
||||
test: async function() {
|
||||
await setContentPageElementProperty("#node1", "innerHTML", "");
|
||||
},
|
||||
check: async function(inspector) {
|
||||
const container = await getContainerForSelector("#node1", inspector);
|
||||
|
@ -243,8 +243,8 @@ const TEST_DATA = [
|
|||
},
|
||||
{
|
||||
desc: "Go from 0 to 1 text child",
|
||||
test: async function(testActor) {
|
||||
await testActor.setProperty("#node1", "textContent", "newtext");
|
||||
test: async function() {
|
||||
await setContentPageElementProperty("#node1", "textContent", "newtext");
|
||||
},
|
||||
check: async function(inspector) {
|
||||
const container = await getContainerForSelector("#node1", inspector);
|
||||
|
@ -261,8 +261,8 @@ const TEST_DATA = [
|
|||
|
||||
{
|
||||
desc: "Updating the innerHTML",
|
||||
test: async function(testActor) {
|
||||
await testActor.setProperty(
|
||||
test: async function() {
|
||||
await setContentPageElementProperty(
|
||||
"#node2",
|
||||
"innerHTML",
|
||||
"<div><span>foo</span></div>"
|
||||
|
@ -285,7 +285,7 @@ const TEST_DATA = [
|
|||
},
|
||||
{
|
||||
desc: "Removing child nodes",
|
||||
test: async function(testActor) {
|
||||
test: async function() {
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
|
||||
const node4 = content.document.querySelector("#node4");
|
||||
while (node4.firstChild) {
|
||||
|
@ -300,7 +300,7 @@ const TEST_DATA = [
|
|||
},
|
||||
{
|
||||
desc: "Appending a child to a different parent",
|
||||
test: async function(testActor) {
|
||||
test: async function() {
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
|
||||
const node17 = content.document.querySelector("#node17");
|
||||
const node2 = content.document.querySelector("#node2");
|
||||
|
@ -336,7 +336,7 @@ const TEST_DATA = [
|
|||
// node21
|
||||
// node18
|
||||
// node19
|
||||
test: async function(testActor) {
|
||||
test: async function() {
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
|
||||
const node18 = content.document.querySelector("#node18");
|
||||
const node20 = content.document.querySelector("#node20");
|
||||
|
@ -383,7 +383,7 @@ const TEST_DATA = [
|
|||
];
|
||||
|
||||
add_task(async function() {
|
||||
const { inspector, testActor } = await openInspectorForURL(TEST_URL);
|
||||
const { inspector } = await openInspectorForURL(TEST_URL);
|
||||
|
||||
info("Expanding all markup-view nodes");
|
||||
await inspector.markup.expandAll();
|
||||
|
@ -413,7 +413,7 @@ add_task(async function() {
|
|||
}
|
||||
});
|
||||
});
|
||||
await test(testActor, inspector);
|
||||
await test(inspector);
|
||||
await promise;
|
||||
|
||||
info("Expanding all markup-view nodes to make sure new nodes are imported");
|
||||
|
|
|
@ -52,7 +52,11 @@ add_task(async function() {
|
|||
await testActor.isNodeCorrectlyHighlighted("iframe", is);
|
||||
|
||||
info("Scrolling the document");
|
||||
await testActor.setProperty("iframe", "style", "margin-bottom: 2000px");
|
||||
await setContentPageElementProperty(
|
||||
"iframe",
|
||||
"style",
|
||||
"margin-bottom: 2000px"
|
||||
);
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () =>
|
||||
content.scrollBy(0, 40)
|
||||
);
|
||||
|
|
|
@ -26,7 +26,7 @@ add_task(async function() {
|
|||
"was selected"
|
||||
);
|
||||
|
||||
await testActor.setProperty("p", "textContent", "dary!!!!");
|
||||
await setContentPageElementProperty("p", "textContent", "dary!!!!");
|
||||
isVisible = await testActor.isHighlighting();
|
||||
ok(isVisible, "the highlighter is still visible");
|
||||
});
|
||||
|
|
|
@ -815,3 +815,23 @@ function getContentPageElementProperty(selector, propertyName) {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the property of an element in the content page
|
||||
*
|
||||
* @param {string} selector: The selector to get the element we want to set the property on
|
||||
* @param {string} propertyName: The name of the property we want to set
|
||||
* @param {string} propertyValue: The value that is going to be assigned to the property
|
||||
* @returns {Promise}
|
||||
*/
|
||||
function setContentPageElementProperty(selector, propertyName, propertyValue) {
|
||||
return SpecialPowers.spawn(
|
||||
gBrowser.selectedBrowser,
|
||||
[selector, propertyName, propertyValue],
|
||||
function(innerSelector, innerPropertyName, innerPropertyValue) {
|
||||
content.document.querySelector(innerSelector)[
|
||||
innerPropertyName
|
||||
] = innerPropertyValue;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -167,14 +167,6 @@ var testSpec = protocol.generateActorSpec({
|
|||
value: RetVal("json"),
|
||||
},
|
||||
},
|
||||
setProperty: {
|
||||
request: {
|
||||
selector: Arg(0, "string"),
|
||||
property: Arg(1, "string"),
|
||||
value: Arg(2, "string"),
|
||||
},
|
||||
response: {},
|
||||
},
|
||||
reload: {
|
||||
request: {},
|
||||
response: {},
|
||||
|
@ -540,17 +532,6 @@ var TestActor = protocol.ActorClassWithSpec(testSpec, {
|
|||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Set a JS property on a DOM Node.
|
||||
* @param {String} selector The node selector
|
||||
* @param {String} property The property name
|
||||
* @param {String} value The attribute value
|
||||
*/
|
||||
setProperty: function(selector, property, value) {
|
||||
const node = this._querySelector(selector);
|
||||
node[property] = value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Reload the content window.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче