michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // Test that the console output scrolls to JS eval results when there are many michael@0: // messages displayed. See bug 601352. michael@0: michael@0: function test() { michael@0: Task.spawn(runner).then(finishTest); michael@0: michael@0: function* runner() { michael@0: let {tab} = yield loadTab("data:text/html;charset=utf-8,Web Console test for bug 601352"); michael@0: let hud = yield openConsole(tab); michael@0: hud.jsterm.clearOutput(); michael@0: michael@0: let longMessage = ""; michael@0: for (let i = 0; i < 50; i++) { michael@0: longMessage += "LongNonwrappingMessage"; michael@0: } michael@0: michael@0: for (let i = 0; i < 50; i++) { michael@0: content.console.log("test1 message " + i); michael@0: } michael@0: michael@0: content.console.log(longMessage); michael@0: michael@0: for (let i = 0; i < 50; i++) { michael@0: content.console.log("test2 message " + i); michael@0: } michael@0: michael@0: yield waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: text: "test1 message 0", michael@0: }, { michael@0: text: "test1 message 49", michael@0: }, { michael@0: text: "LongNonwrappingMessage", michael@0: }, { michael@0: text: "test2 message 0", michael@0: }, { michael@0: text: "test2 message 49", michael@0: }], michael@0: }); michael@0: michael@0: let nodeDeferred = promise.defer(); michael@0: hud.jsterm.execute("1+1", (node) => { nodeDeferred.resolve(node); }); michael@0: let node = yield nodeDeferred.promise; michael@0: michael@0: let scrollNode = hud.outputNode.parentNode; michael@0: let rectNode = node.getBoundingClientRect(); michael@0: let rectOutput = scrollNode.getBoundingClientRect(); michael@0: console.debug("rectNode", rectNode, "rectOutput", rectOutput); michael@0: console.log("scrollNode scrollHeight", scrollNode.scrollHeight, "scrollTop", scrollNode.scrollTop, "clientHeight", scrollNode.clientHeight); michael@0: michael@0: isnot(scrollNode.scrollTop, 0, "scroll location is not at the top"); michael@0: michael@0: // The bounding client rect .top/left coordinates are relative to the michael@0: // console iframe. michael@0: michael@0: // Visible scroll viewport. michael@0: let height = rectOutput.height; michael@0: michael@0: // Top and bottom coordinates of the last message node, relative to the outputNode. michael@0: let top = rectNode.top - rectOutput.top; michael@0: let bottom = top + rectNode.height; michael@0: info("node top " + top + " node bottom " + bottom + " node clientHeight " + node.clientHeight); michael@0: michael@0: ok(top >= 0 && bottom <= height, "last message is visible"); michael@0: } michael@0: }