browser_webconsole_object_inspector_scroll.js (1657B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Check that expanding an objectInspector node doesn't alter the output scroll position. 7 const TEST_URI = 8 "data:text/html;charset=utf8,<!DOCTYPE html>test Object Inspector"; 9 10 add_task(async function () { 11 const hud = await openNewTabAndConsole(TEST_URI); 12 13 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () { 14 content.wrappedJSObject.console.log( 15 "oi-test", 16 content.wrappedJSObject.Math 17 ); 18 }); 19 20 const node = await waitFor(() => findConsoleAPIMessage(hud, "oi-test")); 21 const objectInspector = node.querySelector(".tree"); 22 23 await expandObjectInspectorNode(objectInspector.querySelector(".tree-node")); 24 25 const nodes = objectInspector.querySelectorAll(".node"); 26 const lastNode = nodes[nodes.length - 1]; 27 28 info("Scroll the last node of the ObjectInspector into view"); 29 lastNode.scrollIntoView(); 30 31 const outputContainer = hud.ui.outputNode.querySelector(".webconsole-output"); 32 ok(hasVerticalOverflow(outputContainer), "There is a vertical overflow"); 33 const scrollTop = outputContainer.scrollTop; 34 35 const onOiMutation = waitForNodeMutation(objectInspector, { 36 childList: true, 37 }); 38 39 info("Expand the last node"); 40 const view = lastNode.ownerDocument.defaultView; 41 EventUtils.synthesizeMouseAtCenter(lastNode, {}, view); 42 await onOiMutation; 43 44 is( 45 scrollTop, 46 outputContainer.scrollTop, 47 "Scroll position did not changed when expanding a node" 48 ); 49 }); 50 51 function hasVerticalOverflow(container) { 52 return container.scrollHeight > container.clientHeight; 53 }