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 /testing/web-platform/tests/svg/linking/scripted/testcommon.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 'testing/web-platform/tests/svg/linking/scripted/testcommon.js')
-rw-r--r-- | testing/web-platform/tests/svg/linking/scripted/testcommon.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/testing/web-platform/tests/svg/linking/scripted/testcommon.js b/testing/web-platform/tests/svg/linking/scripted/testcommon.js new file mode 100644 index 000000000..7d87923f5 --- /dev/null +++ b/testing/web-platform/tests/svg/linking/scripted/testcommon.js @@ -0,0 +1,42 @@ +/** + * The const var for SVG and xlink namespaces + */ +const SVGNS = 'http://www.w3.org/2000/svg'; +const XLINKNS = 'http://www.w3.org/1999/xlink'; + +/** + * Appends a svg element to the parent. + * + * @param test The testharness.js Test object. If provided, this will be used + * to register a cleanup callback to remove the div when the test + * finishes. + * @param tag The element tag name. + * @param parent The parent element of this new created svg element. + * @param attrs A dictionary object with attribute names and values to set on + * the div. + */ +function createSVGElement(test, tag, parent, attrs) { + var elem = document.createElementNS(SVGNS, tag); + if (attrs) { + for (var attrName in attrs) { + elem.setAttribute(attrName, attrs[attrName]); + } + } + parent.appendChild(elem); + test.add_cleanup(function() { + elem.remove(); + }); + return elem; +} + +/** + * Create a Promise object which resolves when a specific event fires. + * + * @param object The event target. + * @param name The event name. + */ +function waitEvent(object, name) { + return new Promise(function(resolve) { + object.addEventListener(name, resolve, { once: true }); + }); +} |