Commit 8221e18e authored by Mason Freed's avatar Mason Freed Committed by Commit Bot

Move distributed node tests to web components v0 folder

This is part of a multi-CL set that will move all "Web Components v0
only" tests into a separate folder. This will make landing the eventual
removal of WCv0 easier, because this entire folder can simply be skipped
rather than requiring file-by-file changes. There should not be any
tests in this folder that are needed for testing Web Components
VERSION 1 features.

While this CL does not change any behavior or testing now, care should
be taken in reviewing the list of tests, since when WCv0 is removed,
all of these tests will be deleted. So any tests being moved here that
are required for testing a non-WCv0 feature should *not* be included in
this move.

This set should only include tests of the (Shadow DOM v0 specific)
distributed nodes concept.

Bug: 937746
Change-Id: Ia5c38f31cd999dcd96aa116183a1fa99920c152a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2209594
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770367}
parent 7de3846d
......@@ -107,7 +107,6 @@ editing/selection/select_all/select_all_overflow_hidden_table.html
editing/selection/selection-forces-unrooted-repaint.html
editing/selection/set_base_and_extent/set_base_and_extent_uneditable_table.html
editing/shadow/505092-fieldset-is-not-ua-shadow-crash.html
editing/shadow/delete-characters-in-distributed-node-crash.html
editing/shadow/getRangeAt-end-of-text-node.html
editing/style/apply-style-atomic.html
editing/style/block-styles-007.html
......
......@@ -3860,7 +3860,6 @@ crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/shadow-eleme
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/shadowhost-keyframes.html [ Skip ]
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/shadowroot-keyframes.html [ Skip ]
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/transition-on-shadow-host-createshadowroot.html [ Skip ]
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/transition-on-shadow-host-with-distributed-node.html [ Skip ]
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/gc-treescope.html [ Skip ]
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/StyleSheet/css-insert-import-rule-to-shadow-stylesheets.html [ Skip ]
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/content-pseudo-element-dynamic-class.html [ Skip ]
......@@ -3893,7 +3892,6 @@ crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/content-whit
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/custom-pseudo-scope.html [ Skip ]
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/dynamically-created-shadow-root.html [ Skip ]
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/new-fallback.html [ Skip ]
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/no-style-sharing-with-distributed-nodes.html [ Skip ]
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/shadow-content-crash.html [ Skip ]
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/shadow-on-image.html [ Skip ]
crbug.com/937746 virtual/web-components-v0-disabled/fast/dom/shadow/shadowdom-for-button-complex-shadow.html [ Skip ]
......
var defaultPaddingSize = 40;
function moveMouseOver(element)
{
if (!window.eventSender || !window.internals)
return;
var rect = element.getBoundingClientRect();
var x = rect.left + rect.width / 2;
var y;
if (element.hasChildNodes() || internals.shadowRoot(element))
y = rect.top + defaultPaddingSize / 2;
else
y = rect.top + rect.height / 2;
eventSender.mouseMoveTo(x, y);
}
function touchLocation(node)
{
var rect = node.getBoundingClientRect();
var x = rect.left + 5;
var y = rect.top + defaultPaddingSize + 5;
eventSender.addTouchPoint(x, y);
eventSender.touchStart();
eventSender.leapForward(100);
eventSender.touchEnd();
eventSender.cancelTouchPoint(0);
}
function selectTextNode(node)
{
getSelection().setBaseAndExtent(node, 0, node, node.length);
}
function dragMouse(node)
{
var rect = node.getBoundingClientRect();
var x = rect.left + 5;
var y = rect.top + defaultPaddingSize + 5;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.leapForward(100);
eventSender.mouseMoveTo(x + 100, y + 100);
eventSender.mouseUp();
eventSender.mouseMoveTo(x, y);
}
function scrollMouseWheel(node)
{
var rect = node.getBoundingClientRect();
var x = rect.left + 5;
var y = rect.top + defaultPaddingSize + 5;
eventSender.mouseMoveTo(x, y);
eventSender.mouseScrollBy(0, 120);
}
var eventRecords = {};
function clearEventRecords()
{
eventRecords = {};
}
function dispatchedEvent(eventType)
{
var events = eventRecords[eventType];
if (!events)
return [];
return events;
}
function recordEvent(event)
{
var eventType = event.type;
if (!eventRecords[eventType]) {
eventRecords[eventType] = [];
}
var eventString = '';
if (event.currentTarget)
eventString += ' @' + (event.currentTarget.id || event.currentTarget);
if (event.target)
eventString += ' (target: ' + event.target.id + ')';
if (event.relatedTarget)
eventString += ' (related: ' + event.relatedTarget.id + ')';
if (event.touches)
eventString += ' (touches: ' + dumpTouchList(event.touches) + ')';
if (event.targetTouches)
eventString += ' (targetTouches: ' + dumpTouchList(event.targetTouches) + ')';
if (event.changedTouches)
eventString += ' (changedTouches: ' + dumpTouchList(event.changedTouches) + ')';
if (event.eventPhase == 1)
eventString += '(capturing phase)';
if (event.target && event.currentTarget && event.target.id == event.currentTarget.id)
shouldBe("event.eventPhase", "2", true);
eventRecords[eventType].push(eventString);
}
function dumpNode(node)
{
var output = node.nodeName + "\t";
if (node.id)
output += ' id=' + node.id;
if (node.className)
output += ' class=' + node.className;
return output;
}
function dumpTouchList(touches) {
var ids = [];
for (var i = 0; i < touches.length; ++i) {
if (touches.item(i).target && touches.item(i).target.id)
ids.push(touches.item(i).target.id);
}
ids.sort();
var result = '';
for (i = 0; i < ids.length; ++i) {
result += ids[i];
if (i != ids.length - 1)
result += ', ';
}
return result;
}
function addEventListeners(nodes)
{
for (var i = 0; i < nodes.length; ++i) {
addEventListenersToNode(getNodeInComposedTree(nodes[i]));
}
}
function addEventListenersToNode(node)
{
node.addEventListener('click', recordEvent, false);
node.addEventListener('dragstart', recordEvent, false);
node.addEventListener('mouseout', recordEvent, false);
node.addEventListener('mouseover', recordEvent, false);
node.addEventListener('mousewheel', recordEvent, false);
node.addEventListener('touchstart', recordEvent, false);
node.addEventListener('gesturetap', recordEvent, false);
// <content> might be an inactive insertion point, so style it also.
if (node.tagName == 'DIV' || node.tagName == 'DETAILS' || node.tagName == 'SUMMARY' || node.tagName == 'CONTENT')
node.setAttribute('style', 'padding-top: ' + defaultPaddingSize + 'px;');
}
function debugDispatchedEvent(eventType)
{
debug('\n ' + eventType);
var events = dispatchedEvent(eventType);
for (var i = 0; i < events.length; ++i)
debug(' ' + events[i])
}
function sortDispatchedEvent(eventType)
{
dispatchedEvent(eventType).sort();
}
function moveMouse(oldElementId, newElementId)
{
clearEventRecords();
debug('\n' + 'Moving mouse from ' + oldElementId + ' to ' + newElementId);
moveMouseOver(getNodeInComposedTree(oldElementId));
clearEventRecords();
moveMouseOver(getNodeInComposedTree(newElementId));
debugDispatchedEvent('mouseout');
debugDispatchedEvent('mouseover');
}
function clickElement(elementId)
{
clearEventRecords();
debug('\n' + 'Click ' + elementId);
var clickEvent = document.createEvent("MouseEvents");
clickEvent.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
getNodeInComposedTree(elementId).dispatchEvent(clickEvent);
debugDispatchedEvent('click');
}
function showSandboxTree()
{
var sandbox = document.getElementById('sandbox');
sandbox.clientLeft;
debug('\n\nFlat Tree will be:\n' + dumpFlatTree(sandbox));
}
// TODO(yuzus): These two functions below need cleaning up. They are currently
// from js-test.js.
function getOrCreateTestElement(id, tagName)
{
var element = document.getElementById(id);
if (element)
return element;
element = document.createElement(tagName);
element.id = id;
var refNode;
var parent = document.body || document.documentElement;
if (id == "description")
refNode = getOrCreateTestElement("console", "div");
else
refNode = parent.firstChild;
parent.insertBefore(element, refNode);
return element;
}
function debug(msg)
{
if (self._lazyTestResults) {
self._lazyTestResults.push(msg);
} else {
var span = document.createElement("span");
// insert it first so XHTML knows the namespace;
getOrCreateTestElement("console", "div").appendChild(span);
span.innerHTML = msg + '<br />';
};
}
function createShadowRoot()
{
var children = Array.prototype.slice.call(arguments);
if ((children[0] instanceof Object) && !(children[0] instanceof Node))
return attachShadow.apply(null, children);
return {'isShadowRoot': true,
'children': children};
}
// TODO(kochi): This is not pure attachShadow wrapper, but also handles createShadowRoot()
// with attributes.
function attachShadow()
{
var children = Array.prototype.slice.call(arguments);
var attributes = {};
var parameter = {};
for (var key in children[0]) {
if (key == 'mode' || key == 'delegatesFocus')
parameter[key] = children[0][key];
else
attributes[key] = children[0][key];
}
return {'isShadowRoot': true,
'parameter': parameter,
'attributes': attributes,
'children': children.slice(1)};
}
function createUserAgentShadowRoot()
{
var shadowRoot = createShadowRoot.apply(null, arguments);
shadowRoot.isUserAgentShadowRoot = true;
return shadowRoot;
}
// This function can take optional child elements, which might be a result of createShadowRoot(), as arguments[2:].
function createDOM(tagName, attributes)
{
var element = document.createElement(tagName);
for (var name in attributes)
element.setAttribute(name, attributes[name]);
var childElements = Array.prototype.slice.call(arguments, 2);
for (var i = 0; i < childElements.length; ++i) {
var child = childElements[i];
if (child.isShadowRoot) {
var shadowRoot;
if (child.isUserAgentShadowRoot) {
shadowRoot = internals.createUserAgentShadowRoot(element);
} else {
if (child.parameter && Object.keys(child.parameter).length > 0)
shadowRoot = element.attachShadow(child.parameter);
else
shadowRoot = element.createShadowRoot();
}
if (child.attributes) {
for (var attribute in child.attributes) {
// Shadow Root does not have setAttribute.
shadowRoot[attribute] = child.attributes[attribute];
}
}
for (var j = 0; j < child.children.length; ++j)
shadowRoot.appendChild(child.children[j]);
} else
element.appendChild(child);
}
return element;
}
function isShadowHost(node)
{
return internals.shadowRoot(node);
}
function isShadowRoot(node)
{
return node instanceof window.ShadowRoot;
}
function isIframeElement(element)
{
return element && element.nodeName == 'IFRAME';
}
function getNodeInComposedTree(path)
{
var ids = path.split('/');
var node = document.getElementById(ids[0]);
for (var i = 1; node != null && i < ids.length; ++i) {
if (isIframeElement(node)) {
node = node.contentDocument.getElementById(ids[i]);
continue;
}
if (internals.shadowRoot(node))
node = internals.shadowRoot(node);
else
return null;
if (ids[i] != '')
node = node.getElementById(ids[i]);
}
return node;
}
function dumpNode(node)
{
if (!node)
return 'null';
if (node.id)
return '#' + node.id;
return '' + node;
}
function dumpNodeList(nodeList) {
var result = "";
var length = nodeList.length;
for (var i = 0; i < length; i++)
result += dumpNode(nodeList[i]) + ", ";
result += "length: " + length;
return result;
}
function shouldBeEqualAsArray(nodeList, expectedNodes)
{
// FIXME: Avoid polluting the global namespace.
window.nodeList = nodeList;
window.expectedNodes = expectedNodes;
shouldBe("nodeList.length", "expectedNodes.length");
for (var i = 0; i < nodeList.length; ++i) {
shouldBe("nodeList.item(" + i + ")", "expectedNodes[" + i + "]");
}
}
function innermostActiveElement(element)
{
element = element || document.activeElement;
if (isIframeElement(element)) {
if (element.contentDocument.activeElement)
return innermostActiveElement(element.contentDocument.activeElement);
return element;
}
if (isShadowHost(element)) {
var shadowRoot = internals.shadowRoot(element);
if (shadowRoot) {
if (shadowRoot.activeElement)
return innermostActiveElement(shadowRoot.activeElement);
}
}
return element;
}
function isInnermostActiveElement(id)
{
var element = getNodeInComposedTree(id);
if (!element) {
debug('FAIL: There is no such element with id: '+ id);
return false;
}
if (element == innermostActiveElement())
return true;
debug('Expected innermost activeElement is ' + id + ', but actual innermost activeElement is ' + dumpNode(innermostActiveElement()));
return false;
}
function shouldNavigateFocus(from, to, direction)
{
debug('Should move from ' + from + ' to ' + to + ' in ' + direction);
var fromElement = getNodeInComposedTree(from);
if (!fromElement) {
debug('FAIL: There is no such element with id: '+ from);
return;
}
fromElement.focus();
if (!isInnermostActiveElement(from)) {
debug('FAIL: Can not be focused: '+ from);
return;
}
if (direction == 'forward')
navigateFocusForward();
else
navigateFocusBackward();
if (isInnermostActiveElement(to))
debug('PASS');
else
debug('FAIL');
return isInnermostActiveElement(to);
}
function navigateFocusForward()
{
eventSender.keyDown('\t');
}
function navigateFocusBackward()
{
eventSender.keyDown('\t', ['shiftKey']);
}
function testFocusNavigationForward(elements)
{
for (var i = 0; i + 1 < elements.length; ++i)
shouldNavigateFocus(elements[i], elements[i + 1], 'forward');
}
function testFocusNavigationBackward(elements)
{
for (var i = 0; i + 1 < elements.length; ++i)
shouldNavigateFocus(elements[i], elements[i + 1], 'backward');
}
function dumpFlatTree(node, indent)
{
indent = indent || "";
var output = indent + dumpNode(node) + "\n";
var child;
for (child = internals.firstChildInFlatTree(node); child; child = internals.nextSiblingInFlatTree(child))
output += dumpFlatTree(child, indent + "\t");
return output;
}
function lastNodeInFlatTree(root)
{
var lastNode = root;
while (internals.lastChildInFlatTree(lastNode))
lastNode = internals.lastChildInFlatTree(lastNode);
return lastNode;
}
function showFlatTreeByTraversingInForward(root)
{
var node = root;
var last = lastNodeInFlatTree(root);
while (node) {
debug(dumpNode(node));
if (node == last)
break;
node = internals.nextInFlatTree(node);
}
}
function showFlatTreeByTraversingInBackward(root)
{
var node = lastNodeInFlatTree(root);
while (node) {
debug(dumpNode(node));
if (node == root)
break;
node = internals.previousInFlatTree(node);
}
}
function showFlatTree(node)
{
debug('Flat Tree:');
debug(dumpFlatTree(node));
debug('Traverse in forward.');
showFlatTreeByTraversingInForward(node);
debug('Traverse in backward.');
showFlatTreeByTraversingInBackward(node);
debug('');
}
function showNextNode(node)
{
var next = internals.nextInFlatTree(node);
debug('Next node of [' + dumpNode(node) + '] is [' + dumpNode(next) + ']');
}
function backgroundColorOf(selector)
{
return window.getComputedStyle(getNodeInComposedTree(selector)).backgroundColor;
}
function backgroundColorShouldBe(selector, expected)
{
shouldBeEqualToString('backgroundColorOf(\'' + selector + '\')', expected);
}
function backgroundColorShouldNotBe(selector, color)
{
var text = 'backgroundColorOf(\'' + selector + '\')';
var unevaledString = '"' + color.replace(/\\/g, "\\\\").replace(/"/g, "\"") + '"';
shouldNotBe(text, unevaledString);
}
function getElementByIdConsideringShadowDOM(root, id) {
function iter(root, id) {
if (!root)
return null;
if (root.id == id)
return root;
// We don't collect div having a shadow root, since we cannot point it correctly.
// Such div should have an inner div to be pointed correctly.
for (var child = root.firstChild; child; child = child.nextSibling) {
var node = iter(child, id);
if (node != null)
return node;
}
if (root.nodeType != 1)
return null;
var shadowRoot = internals.shadowRoot(root);
if (shadowRoot) {
var node = iter(shadowRoot, id);
if (node != null)
return node;
}
return null;
};
if (!window.internals)
return null;
return iter(root, id);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment