summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/shadow-dom/resources/event-path-test-helpers.js
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-02-25 01:03:57 +0000
committerMoonchild <moonchild@palemoon.org>2021-02-25 01:03:57 +0000
commitceadffab6b357723981a429e11222daf6cd6dcfb (patch)
tree5603053048d6a460f79b22bdf165fb74d32d39b0 /testing/web-platform/tests/shadow-dom/resources/event-path-test-helpers.js
parent14fb2f966e9b54598c451e3cb35b4aa0480dafed (diff)
parentad5a13bd501e379517da1a944c104a11d951a3f5 (diff)
downloadUXP-RC_20210225.tar
UXP-RC_20210225.tar.gz
UXP-RC_20210225.tar.lz
UXP-RC_20210225.tar.xz
UXP-RC_20210225.zip
Merge branch 'master' into releaseRC_20210225
Diffstat (limited to 'testing/web-platform/tests/shadow-dom/resources/event-path-test-helpers.js')
-rw-r--r--testing/web-platform/tests/shadow-dom/resources/event-path-test-helpers.js93
1 files changed, 0 insertions, 93 deletions
diff --git a/testing/web-platform/tests/shadow-dom/resources/event-path-test-helpers.js b/testing/web-platform/tests/shadow-dom/resources/event-path-test-helpers.js
deleted file mode 100644
index 091bcd082..000000000
--- a/testing/web-platform/tests/shadow-dom/resources/event-path-test-helpers.js
+++ /dev/null
@@ -1,93 +0,0 @@
-
-function dispatchEventWithLog(shadow, target, event) {
- var eventPath = [];
- var relatedTargets = [];
- var pathAtTargets = [];
-
- var attachedNodes = [];
- for (var nodeKey in shadow) {
- var startingNode = shadow[nodeKey];
- for (var node = startingNode; node; node = node.parentNode) {
- if (attachedNodes.indexOf(node) >= 0)
- continue;
- attachedNodes.push(node);
- node.addEventListener(event.type, (function (event) {
- eventPath.push(this.label);
- relatedTargets.push(event.relatedTarget ? event.relatedTarget.label : null);
-
- if (!event.composedPath) // Don't fail all tests just for the lack of composedPath.
- return;
-
- pathAtTargets.push(event.composedPath().map(function (node) { return node.label; }));
- }).bind(node));
- }
- }
-
- target.dispatchEvent(event);
-
- return {eventPath: eventPath, relatedTargets: relatedTargets, pathAtTargets: pathAtTargets};
-}
-
-/*
--SR: ShadowRoot -S: Slot
-A ------------------------------- A-SR
-+ B ------------ B-SR + A1 --- A1-SR
- + C + B1 --- B1-SR + A2-S + A1a
- + D --- D-SR + B1a + B1b --- B1b-SR
- + D1 + B1c-S + B1b1
- + B1b2
-*/
-function createTestTree(mode) {
- var namedNodes = {};
-
- function element(name) {
- var element = document.createElement(name.indexOf('-S') > 0 ? 'slot' : 'div');
- element.label = name;
- namedNodes[name] = element;
- for (var i = 1; i < arguments.length; i++) {
- var item = arguments[i];
- if (typeof(item) == 'function')
- item(element);
- else
- element.appendChild(item);
- }
- return element;
- }
-
- function shadow(name) {
- var children = [];
- for (var i = 1; i < arguments.length; i++)
- children.push(arguments[i]);
- return function (element) {
- var shadowRoot = element.attachShadow({mode: mode});
- shadowRoot.label = name;
- namedNodes[name] = shadowRoot;
- for (var child of children)
- shadowRoot.appendChild(child);
- }
- }
-
- var host = element('A',
- shadow('A-SR',
- element('A1',
- shadow('A1-SR',
- element('A1a'))),
- element('A2-S')
- ),
- element('B',
- shadow('B-SR',
- element('B1',
- shadow('B1-SR',
- element('B1b',
- shadow('B1b-SR',
- element('B1b1'),
- element('B1b2'))),
- element('B1c-S')),
- element('B1a'))),
- element('C'),
- element('D',
- shadow('D-SR',
- element('D1')))));
-
- return namedNodes;
-}