Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* vim: set ts=2 et sw=2 tw=80: */
2 /* Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/ */
5 "use strict";
7 // Tests that the markup view loads only as many nodes as specified by the
8 // devtools.markup.pagesize preference.
10 Services.prefs.setIntPref("devtools.markup.pagesize", 5);
12 const TEST_URL = TEST_URL_ROOT + "doc_markup_pagesize_01.html";
13 const TEST_DATA = [{
14 desc: "Select the last item",
15 selector: "#z",
16 expected: "*more*vwxyz"
17 }, {
18 desc: "Select the first item",
19 selector: "#a",
20 expected: "abcde*more*"
21 }, {
22 desc: "Select the last item",
23 selector: "#z",
24 expected: "*more*vwxyz"
25 }, {
26 desc: "Select an already-visible item",
27 selector: "#v",
28 // Because "v" was already visible, we shouldn't have loaded
29 // a different page.
30 expected: "*more*vwxyz"
31 }, {
32 desc: "Verify childrenDirty reloads the page",
33 selector: "#w",
34 forceReload: true,
35 // But now that we don't already have a loaded page, selecting
36 // w should center around w.
37 expected: "*more*uvwxy*more*"
38 }];
40 let test = asyncTest(function*() {
41 let {inspector} = yield addTab(TEST_URL).then(openInspector);
43 info("Start iterating through the test data");
44 for (let step of TEST_DATA) {
45 info("Start test: " + step.desc);
47 if (step.forceReload) {
48 forceReload(inspector);
49 }
50 info("Selecting the node that corresponds to " + step.selector);
51 yield selectNode(step.selector, inspector);
53 info("Checking that the right nodes are shwon");
54 assertChildren(step.expected, inspector);
55 }
57 info("Checking that clicking the more button loads everything");
58 clickShowMoreNodes(inspector);
59 yield inspector.markup._waitForChildren();
60 assertChildren("abcdefghijklmnopqrstuvwxyz", inspector);
61 });
63 function assertChildren(expected, inspector) {
64 let container = getContainerForRawNode("body", inspector);
65 let found = "";
66 for (let child of container.children.children) {
67 if (child.classList.contains("more-nodes")) {
68 found += "*more*";
69 } else {
70 found += child.container.node.getAttribute("id");
71 }
72 }
73 is(found, expected, "Got the expected children.");
74 }
76 function forceReload(inspector) {
77 let container = getContainerForRawNode("body", inspector);
78 container.childrenDirty = true;
79 }
81 function clickShowMoreNodes(inspector) {
82 let container = getContainerForRawNode("body", inspector);
83 let button = container.elt.querySelector("button");
84 let win = button.ownerDocument.defaultView;
85 EventUtils.sendMouseEvent({type: "click"}, button, win);
86 }