|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 // Test that the console output scrolls to JS eval results when there are many |
|
6 // messages displayed. See bug 601352. |
|
7 |
|
8 function test() { |
|
9 Task.spawn(runner).then(finishTest); |
|
10 |
|
11 function* runner() { |
|
12 let {tab} = yield loadTab("data:text/html;charset=utf-8,Web Console test for bug 601352"); |
|
13 let hud = yield openConsole(tab); |
|
14 hud.jsterm.clearOutput(); |
|
15 |
|
16 let longMessage = ""; |
|
17 for (let i = 0; i < 50; i++) { |
|
18 longMessage += "LongNonwrappingMessage"; |
|
19 } |
|
20 |
|
21 for (let i = 0; i < 50; i++) { |
|
22 content.console.log("test1 message " + i); |
|
23 } |
|
24 |
|
25 content.console.log(longMessage); |
|
26 |
|
27 for (let i = 0; i < 50; i++) { |
|
28 content.console.log("test2 message " + i); |
|
29 } |
|
30 |
|
31 yield waitForMessages({ |
|
32 webconsole: hud, |
|
33 messages: [{ |
|
34 text: "test1 message 0", |
|
35 }, { |
|
36 text: "test1 message 49", |
|
37 }, { |
|
38 text: "LongNonwrappingMessage", |
|
39 }, { |
|
40 text: "test2 message 0", |
|
41 }, { |
|
42 text: "test2 message 49", |
|
43 }], |
|
44 }); |
|
45 |
|
46 let nodeDeferred = promise.defer(); |
|
47 hud.jsterm.execute("1+1", (node) => { nodeDeferred.resolve(node); }); |
|
48 let node = yield nodeDeferred.promise; |
|
49 |
|
50 let scrollNode = hud.outputNode.parentNode; |
|
51 let rectNode = node.getBoundingClientRect(); |
|
52 let rectOutput = scrollNode.getBoundingClientRect(); |
|
53 console.debug("rectNode", rectNode, "rectOutput", rectOutput); |
|
54 console.log("scrollNode scrollHeight", scrollNode.scrollHeight, "scrollTop", scrollNode.scrollTop, "clientHeight", scrollNode.clientHeight); |
|
55 |
|
56 isnot(scrollNode.scrollTop, 0, "scroll location is not at the top"); |
|
57 |
|
58 // The bounding client rect .top/left coordinates are relative to the |
|
59 // console iframe. |
|
60 |
|
61 // Visible scroll viewport. |
|
62 let height = rectOutput.height; |
|
63 |
|
64 // Top and bottom coordinates of the last message node, relative to the outputNode. |
|
65 let top = rectNode.top - rectOutput.top; |
|
66 let bottom = top + rectNode.height; |
|
67 info("node top " + top + " node bottom " + bottom + " node clientHeight " + node.clientHeight); |
|
68 |
|
69 ok(top >= 0 && bottom <= height, "last message is visible"); |
|
70 } |
|
71 } |