diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/inspector/markup/test/browser_markup_events-overflow.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/inspector/markup/test/browser_markup_events-overflow.js')
-rw-r--r-- | devtools/client/inspector/markup/test/browser_markup_events-overflow.js | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/devtools/client/inspector/markup/test/browser_markup_events-overflow.js b/devtools/client/inspector/markup/test/browser_markup_events-overflow.js new file mode 100644 index 000000000..3e73921f4 --- /dev/null +++ b/devtools/client/inspector/markup/test/browser_markup_events-overflow.js @@ -0,0 +1,91 @@ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +const TEST_URL = URL_ROOT + "doc_markup_events-overflow.html"; +const TEST_DATA = [ + { + desc: "editor overflows container", + // scroll to bottom + initialScrollTop: -1, + // last header + headerToClick: 49, + alignBottom: true, + alignTop: false, + }, + { + desc: "header overflows the container", + initialScrollTop: 2, + headerToClick: 0, + alignBottom: false, + alignTop: true, + }, + { + desc: "neither header nor editor overflows the container", + initialScrollTop: 2, + headerToClick: 5, + alignBottom: false, + alignTop: false, + }, +]; + +add_task(function* () { + let { inspector } = yield openInspectorForURL(TEST_URL); + + let markupContainer = yield getContainerForSelector("#events", inspector); + let evHolder = markupContainer.elt.querySelector(".markupview-events"); + let tooltip = inspector.markup.eventDetailsTooltip; + + info("Clicking to open event tooltip."); + EventUtils.synthesizeMouseAtCenter(evHolder, {}, + inspector.markup.doc.defaultView); + yield tooltip.once("shown"); + info("EventTooltip visible."); + + let container = tooltip.panel; + let containerRect = container.getBoundingClientRect(); + let headers = container.querySelectorAll(".event-header"); + + for (let data of TEST_DATA) { + info("Testing scrolling when " + data.desc); + + if (data.initialScrollTop < 0) { + info("Scrolling container to the bottom."); + let newScrollTop = container.scrollHeight - container.clientHeight; + data.initialScrollTop = container.scrollTop = newScrollTop; + } else { + info("Scrolling container by " + data.initialScrollTop + "px"); + container.scrollTop = data.initialScrollTop; + } + + is(container.scrollTop, data.initialScrollTop, "Container scrolled."); + + info("Clicking on header #" + data.headerToClick); + let header = headers[data.headerToClick]; + + let ready = tooltip.once("event-tooltip-ready"); + EventUtils.synthesizeMouseAtCenter(header, {}, header.ownerGlobal); + yield ready; + + info("Event handler expanded."); + + // Wait for any scrolling to finish. + yield promiseNextTick(); + + if (data.alignTop) { + let headerRect = header.getBoundingClientRect(); + + is(Math.round(headerRect.top), Math.round(containerRect.top), + "Clicked header is aligned with the container top."); + } else if (data.alignBottom) { + let editorRect = header.nextElementSibling.getBoundingClientRect(); + + is(Math.round(editorRect.bottom), Math.round(containerRect.bottom), + "Clicked event handler code is aligned with the container bottom."); + } else { + is(container.scrollTop, data.initialScrollTop, + "Container did not scroll, as expected."); + } + } +}); |