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: // Tests that the markup view loads only as many nodes as specified by the michael@0: // devtools.markup.pagesize preference. michael@0: michael@0: Services.prefs.setIntPref("devtools.markup.pagesize", 5); michael@0: michael@0: const TEST_URL = TEST_URL_ROOT + "doc_markup_pagesize_01.html"; michael@0: const TEST_DATA = [{ michael@0: desc: "Select the last item", michael@0: selector: "#z", michael@0: expected: "*more*vwxyz" michael@0: }, { michael@0: desc: "Select the first item", michael@0: selector: "#a", michael@0: expected: "abcde*more*" michael@0: }, { michael@0: desc: "Select the last item", michael@0: selector: "#z", michael@0: expected: "*more*vwxyz" michael@0: }, { michael@0: desc: "Select an already-visible item", michael@0: selector: "#v", michael@0: // Because "v" was already visible, we shouldn't have loaded michael@0: // a different page. michael@0: expected: "*more*vwxyz" michael@0: }, { michael@0: desc: "Verify childrenDirty reloads the page", michael@0: selector: "#w", michael@0: forceReload: true, michael@0: // But now that we don't already have a loaded page, selecting michael@0: // w should center around w. michael@0: expected: "*more*uvwxy*more*" 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("Start iterating through the test data"); michael@0: for (let step of TEST_DATA) { michael@0: info("Start test: " + step.desc); michael@0: michael@0: if (step.forceReload) { michael@0: forceReload(inspector); michael@0: } michael@0: info("Selecting the node that corresponds to " + step.selector); michael@0: yield selectNode(step.selector, inspector); michael@0: michael@0: info("Checking that the right nodes are shwon"); michael@0: assertChildren(step.expected, inspector); michael@0: } michael@0: michael@0: info("Checking that clicking the more button loads everything"); michael@0: clickShowMoreNodes(inspector); michael@0: yield inspector.markup._waitForChildren(); michael@0: assertChildren("abcdefghijklmnopqrstuvwxyz", inspector); michael@0: }); michael@0: michael@0: function assertChildren(expected, inspector) { michael@0: let container = getContainerForRawNode("body", inspector); michael@0: let found = ""; michael@0: for (let child of container.children.children) { michael@0: if (child.classList.contains("more-nodes")) { michael@0: found += "*more*"; michael@0: } else { michael@0: found += child.container.node.getAttribute("id"); michael@0: } michael@0: } michael@0: is(found, expected, "Got the expected children."); michael@0: } michael@0: michael@0: function forceReload(inspector) { michael@0: let container = getContainerForRawNode("body", inspector); michael@0: container.childrenDirty = true; michael@0: } michael@0: michael@0: function clickShowMoreNodes(inspector) { michael@0: let container = getContainerForRawNode("body", inspector); michael@0: let button = container.elt.querySelector("button"); michael@0: let win = button.ownerDocument.defaultView; michael@0: EventUtils.sendMouseEvent({type: "click"}, button, win); michael@0: }