diff --git a/browser/devtools/app-manager/test/browser_manifest_editor.js b/browser/devtools/app-manager/test/browser_manifest_editor.js index 434b5ab7d35..676eff6f108 100644 --- a/browser/devtools/app-manager/test/browser_manifest_editor.js +++ b/browser/devtools/app-manager/test/browser_manifest_editor.js @@ -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"); diff --git a/browser/devtools/app-manager/test/manifest.webapp b/browser/devtools/app-manager/test/manifest.webapp index 44702852c00..caa670bf470 100644 --- a/browser/devtools/app-manager/test/manifest.webapp +++ b/browser/devtools/app-manager/test/manifest.webapp @@ -2,5 +2,8 @@ "name": "My packaged app", "developer": { "name": "Foo Bar" + }, + "tester" : { + "who": "qa" } }