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