Bug 983636 - Update tests to support testing of adding duplicate properties. r=jryans

This commit is contained in:
Mihaela Velimiroviciu 2014-08-01 15:32:01 +03:00
parent d3551f8f02
commit 2cb26ed54d
2 changed files with 21 additions and 9 deletions

View File

@ -23,6 +23,13 @@ function test() {
yield changeManifestValue("name", "the best app");
yield changeManifestValueBad("name", "the worst app");
yield addNewManifestProperty("developer", "foo", "bar");
// add duplicate property in the same parent doesn't create duplicates
yield addNewManifestProperty("developer", "foo", "bar2");
// add propery with same key in other parent is allowed
yield addNewManifestProperty("tester", "foo", "new");
yield addNewManifestPropertyBad("developer", "blob", "bob");
yield removeManifestProperty("developer", "foo");
gManifestWindow = null;
@ -94,15 +101,14 @@ function changeManifestValueBad(key, value) {
}
function addNewManifestProperty(parent, key, value) {
info("Adding new property - parent: " + parent + "; key: " + key + "; value: " + value + "\n\n");
return Task.spawn(function() {
let parentElem = gManifestWindow.document
.querySelector("[id ^= '" + parent + "']");
ok(parentElem,
"Found parent element");
let addPropertyElem = parentElem
.querySelector(".variables-view-add-property");
ok(addPropertyElem,
"Found add-property button");
ok(parentElem, "Found parent element: " + parentElem.id);
let addPropertyElem = parentElem.querySelector(".variables-view-add-property");
ok(addPropertyElem, "Found add-property button");
EventUtils.sendMouseEvent({ type: "mousedown" }, addPropertyElem, gManifestWindow);
@ -116,10 +122,13 @@ function addNewManifestProperty(parent, key, value) {
yield waitForUpdate();
let newElem = gManifestWindow.document.querySelector("[id ^= '" + key + "']");
parentElem = gManifestWindow.document.querySelector("[id ^= '" + parent + "']");
let elems = parentElem.querySelectorAll("[id ^= '" + key + "']");
is(elems.length, 1, "No duplicate property is added");
let newElem = elems[0];
let nameElem = newElem.querySelector(".name");
is(nameElem.value, key,
"Key doesn't match expected Key");
is(nameElem.value, key, "Key doesn't match expected Key");
ok(key in gManifestEditor.manifest[parent],
"Manifest doesn't contain expected key");

View File

@ -2,5 +2,8 @@
"name": "My packaged app",
"developer": {
"name": "Foo Bar"
},
"tester" : {
"who": "qa"
}
}