michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: // Test that markup-containers in the markup-view do flash when their michael@0: // corresponding DOM nodes mutate michael@0: michael@0: const TEST_URL = TEST_URL_ROOT + "doc_markup_flashing.html"; michael@0: // The test data contains a list of mutations to test. michael@0: // Each item is an object: michael@0: // - desc: a description of the test step, for better logging michael@0: // - mutate: a function that should make changes to the content DOM michael@0: // - shouldFlash: a function that returns the element that should be the one flashing michael@0: const TEST_DATA = [{ michael@0: desc: "Adding a new node should flash the new node", michael@0: mutate: (doc, rootNode) => { michael@0: let newLi = doc.createElement("LI"); michael@0: newLi.textContent = "new list item"; michael@0: rootNode.appendChild(newLi); michael@0: }, michael@0: shouldFlash: rootNode => rootNode.lastElementChild michael@0: }, { michael@0: desc: "Removing a node should flash its parent", michael@0: mutate: (doc, rootNode) => { michael@0: rootNode.removeChild(rootNode.lastElementChild); michael@0: }, michael@0: shouldFlash: rootNode => rootNode michael@0: }, { michael@0: desc: "Re-appending an existing node should only flash this node", michael@0: mutate: (doc, rootNode) => { michael@0: rootNode.appendChild(rootNode.firstElementChild); michael@0: }, michael@0: shouldFlash: rootNode => rootNode.lastElementChild michael@0: }, { michael@0: desc: "Adding an attribute should flash the node", michael@0: mutate: (doc, rootNode) => { michael@0: rootNode.setAttribute("name-" + Date.now(), "value-" + Date.now()); michael@0: }, michael@0: shouldFlash: rootNode => rootNode michael@0: }, { michael@0: desc: "Editing an attribute should flash the node", michael@0: mutate: (doc, rootNode) => { michael@0: rootNode.setAttribute("class", "list value-" + Date.now()); michael@0: }, michael@0: shouldFlash: rootNode => rootNode michael@0: }, { michael@0: desc: "Removing an attribute should flash the node", michael@0: mutate: (doc, rootNode) => { michael@0: rootNode.removeAttribute("class"); michael@0: }, michael@0: shouldFlash: rootNode => rootNode michael@0: }]; michael@0: michael@0: let test = asyncTest(function*() { michael@0: let {inspector} = yield addTab(TEST_URL).then(openInspector); michael@0: michael@0: info("Getting the