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/shared/test/browser_filter-editor-04.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/shared/test/browser_filter-editor-04.js')
-rw-r--r-- | devtools/client/shared/test/browser_filter-editor-04.js | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/devtools/client/shared/test/browser_filter-editor-04.js b/devtools/client/shared/test/browser_filter-editor-04.js new file mode 100644 index 000000000..c1c8f4380 --- /dev/null +++ b/devtools/client/shared/test/browser_filter-editor-04.js @@ -0,0 +1,87 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Tests the Filter Editor Widget's drag-drop re-ordering + +const {CSSFilterEditorWidget} = require("devtools/client/shared/widgets/FilterWidget"); +const {getClientCssProperties} = require("devtools/shared/fronts/css-properties"); +const LIST_ITEM_HEIGHT = 32; + +const TEST_URI = `data:text/html,<div id="filter-container" />`; + +add_task(function* () { + let [,, doc] = yield createHost("bottom", TEST_URI); + const cssIsValid = getClientCssProperties().getValidityChecker(doc); + + const container = doc.querySelector("#filter-container"); + const initialValue = "blur(2px) contrast(200%) brightness(200%)"; + let widget = new CSSFilterEditorWidget(container, initialValue, cssIsValid); + + const filters = widget.el.querySelector("#filters"); + function first() { + return filters.children[0]; + } + function mid() { + return filters.children[1]; + } + function last() { + return filters.children[2]; + } + + info("Test re-ordering neighbour filters"); + widget._mouseDown({ + target: first().querySelector("i"), + pageY: 0 + }); + widget._mouseMove({ pageY: LIST_ITEM_HEIGHT }); + + // Element re-ordering should be instant + is(mid().querySelector("label").textContent, "blur", + "Should reorder elements correctly"); + + widget._mouseUp(); + + is(widget.getCssValue(), "contrast(200%) blur(2px) brightness(200%)", + "Should reorder filters objects correctly"); + + info("Test re-ordering first and last filters"); + widget._mouseDown({ + target: first().querySelector("i"), + pageY: 0 + }); + widget._mouseMove({ pageY: LIST_ITEM_HEIGHT * 2 }); + + // Element re-ordering should be instant + is(last().querySelector("label").textContent, "contrast", + "Should reorder elements correctly"); + widget._mouseUp(); + + is(widget.getCssValue(), "brightness(200%) blur(2px) contrast(200%)", + "Should reorder filters objects correctly"); + + info("Test dragging first element out of list"); + const boundaries = filters.getBoundingClientRect(); + + widget._mouseDown({ + target: first().querySelector("i"), + pageY: 0 + }); + widget._mouseMove({ pageY: -LIST_ITEM_HEIGHT * 5 }); + ok(first().getBoundingClientRect().top >= boundaries.top, + "First filter should not move outside filter list"); + + widget._mouseUp(); + + info("Test dragging last element out of list"); + widget._mouseDown({ + target: last().querySelector("i"), + pageY: 0 + }); + widget._mouseMove({ pageY: -LIST_ITEM_HEIGHT * 5 }); + ok(last().getBoundingClientRect().bottom <= boundaries.bottom, + "Last filter should not move outside filter list"); + + widget._mouseUp(); +}); |