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-03.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-03.js')
-rw-r--r-- | devtools/client/shared/test/browser_filter-editor-03.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/devtools/client/shared/test/browser_filter-editor-03.js b/devtools/client/shared/test/browser_filter-editor-03.js new file mode 100644 index 000000000..67d36b6b2 --- /dev/null +++ b/devtools/client/shared/test/browser_filter-editor-03.js @@ -0,0 +1,65 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Tests the Filter Editor Widget add, removeAt, updateAt, getValueAt methods + +const {CSSFilterEditorWidget} = require("devtools/client/shared/widgets/FilterWidget"); +const {getClientCssProperties} = require("devtools/shared/fronts/css-properties"); +const GRAYSCALE_MAX = 100; +const INVERT_MIN = 0; + +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"); + let widget = new CSSFilterEditorWidget(container, "none", cssIsValid); + + info("Test add method"); + const blur = widget.add("blur", "10.2px"); + is(widget.getCssValue(), "blur(10.2px)", + "Should add filters"); + + const url = widget.add("url", "test.svg"); + is(widget.getCssValue(), "blur(10.2px) url(test.svg)", + "Should add filters in order"); + + info("Test updateValueAt method"); + widget.updateValueAt(url, "test2.svg"); + widget.updateValueAt(blur, 5); + is(widget.getCssValue(), "blur(5px) url(test2.svg)", + "Should update values correctly"); + + info("Test getValueAt method"); + is(widget.getValueAt(blur), "5px", + "Should return value + unit"); + is(widget.getValueAt(url), "test2.svg", + "Should return value for string-type filters"); + + info("Test removeAt method"); + widget.removeAt(url); + is(widget.getCssValue(), "blur(5px)", + "Should remove the specified filter"); + + info("Test add method applying filter range to value"); + const grayscale = widget.add("grayscale", GRAYSCALE_MAX + 1); + is(widget.getValueAt(grayscale), `${GRAYSCALE_MAX}%`, + "Shouldn't allow values higher than max"); + + const invert = widget.add("invert", INVERT_MIN - 1); + is(widget.getValueAt(invert), `${INVERT_MIN}%`, + "Shouldn't allow values less than INVERT_MIN"); + + info("Test updateValueAt method applying filter range to value"); + widget.updateValueAt(grayscale, GRAYSCALE_MAX + 1); + is(widget.getValueAt(grayscale), `${GRAYSCALE_MAX}%`, + "Shouldn't allow values higher than max"); + + widget.updateValueAt(invert, INVERT_MIN - 1); + is(widget.getValueAt(invert), `${INVERT_MIN}%`, + "Shouldn't allow values less than INVERT_MIN"); +}); |