1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/markupview/test/browser_markupview_pagesize_02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 1.4 +/* vim: set ts=2 et sw=2 tw=80: */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +// Tests that the markup view loads only as many nodes as specified 1.11 +// by the devtools.markup.pagesize preference and that pressing the "show all nodes" 1.12 +// actually shows the nodes 1.13 + 1.14 +const TEST_URL = TEST_URL_ROOT + "doc_markup_pagesize_02.html"; 1.15 + 1.16 +// Make sure nodes are hidden when there are more than 5 in a row 1.17 +Services.prefs.setIntPref("devtools.markup.pagesize", 5); 1.18 + 1.19 +let test = asyncTest(function*() { 1.20 + let {inspector} = yield addTab(TEST_URL).then(openInspector); 1.21 + 1.22 + info("Selecting the UL node"); 1.23 + yield clickContainer("ul", inspector); 1.24 + info("Reloading the page with the UL node selected will expand its children"); 1.25 + yield reloadPage(inspector); 1.26 + yield inspector.markup._waitForChildren(); 1.27 + 1.28 + info("Click on the 'show all nodes' button in the UL's list of children"); 1.29 + yield showAllNodes(inspector); 1.30 + 1.31 + assertAllNodesAreVisible(inspector); 1.32 +}); 1.33 + 1.34 +function showAllNodes(inspector) { 1.35 + let container = getContainerForRawNode("ul", inspector); 1.36 + let button = container.elt.querySelector("button"); 1.37 + ok(button, "All nodes button is here"); 1.38 + let win = button.ownerDocument.defaultView; 1.39 + 1.40 + EventUtils.sendMouseEvent({type: "click"}, button, win); 1.41 + return inspector.markup._waitForChildren(); 1.42 +} 1.43 + 1.44 +function assertAllNodesAreVisible(inspector) { 1.45 + let ul = getNode("ul"); 1.46 + let container = getContainerForRawNode(ul, inspector); 1.47 + ok(!container.elt.querySelector("button"), "All nodes button isn't here anymore"); 1.48 + is(container.children.childNodes.length, ul.children.length); 1.49 +}