Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Shadow DOM] Make createDOM() function used in testing Shadow DOM mor…
…e flexible.

https://bugs.webkit.org/show_bug.cgi?id=79745

Reviewed by Dimitri Glazkov.

Replaces createDom and createShadow function defined in
LayoutTests/fast/dom/shadow/create-dom.js with more flexible
one. Now we can represent a shadow host which has both light
children and ShadowRoots in one expression.

* fast/dom/shadow/access-key.html:
* fast/dom/shadow/get-element-by-id-in-shadow-root.html:
* fast/dom/shadow/resources/create-dom.js:
(createShadowRoot):
(createDOM):
* fast/dom/shadow/shadow-boundary-events.html:


Canonical link: https://commits.webkit.org/96948@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@109191 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
hayatoito committed Feb 29, 2012
1 parent 2d55252 commit 6695179
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 41 deletions.
19 changes: 19 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,22 @@
2012-02-28 Hayato Ito <hayato@chromium.org>

[Shadow DOM] Make createDOM() function used in testing Shadow DOM more flexible.
https://bugs.webkit.org/show_bug.cgi?id=79745

Reviewed by Dimitri Glazkov.

Replaces createDom and createShadow function defined in
LayoutTests/fast/dom/shadow/create-dom.js with more flexible
one. Now we can represent a shadow host which has both light
children and ShadowRoots in one expression.

* fast/dom/shadow/access-key.html:
* fast/dom/shadow/get-element-by-id-in-shadow-root.html:
* fast/dom/shadow/resources/create-dom.js:
(createShadowRoot):
(createDOM):
* fast/dom/shadow/shadow-boundary-events.html:

2012-02-28 Kenichi Ishibashi <bashi@chromium.org>

[Chromium] Unreviewed test expectations update
Expand Down
20 changes: 11 additions & 9 deletions LayoutTests/fast/dom/shadow/access-key.html
Expand Up @@ -55,16 +55,18 @@
return element;
}

function prepareDomTree(parent)
function prepareDOMTree(parent)
{
parent.appendChild(
createDom('div', {'id': 'divA'},
createDom('input', {'id': 'inputB'}),
createShadow('div', {'id': 'shadowC', 'tabindex': 0},
createDom('input', {'id': 'inputD'}),
createDom('input', {'id': 'inputE', 'accesskey': 'a'}),
createShadow('div', {'id': 'shadowF', 'tabindex': 0},
createDom('input', {'id': 'inputG'})))));
createDOM('div', {'id': 'divA'},
createDOM('input', {'id': 'inputB'}),
createDOM('div', {'id': 'shadowC', 'tabindex': 0},
createShadowRoot(
createDOM('input', {'id': 'inputD'}),
createDOM('input', {'id': 'inputE', 'accesskey': 'a'}),
createDOM('div', {'id': 'shadowF', 'tabindex': 0},
createShadowRoot(
createDOM('input', {'id': 'inputG'})))))));

var ids = ['inputB',
'shadowC/inputD', 'shadowC/inputE',
Expand All @@ -80,7 +82,7 @@
if (window.layoutTestController)
layoutTestController.dumpAsText();

prepareDomTree(document.getElementById('sandbox'));
prepareDOMTree(document.getElementById('sandbox'));

// Please see the discussion of https://bugs.webkit.org/show_bug.cgi?id=67096.
// We don't have a clear idea how accesskey should work in regard to shadow DOM.
Expand Down
Expand Up @@ -22,10 +22,12 @@
function prepareDomTree(parent)
{
parent.appendChild(
createShadow('div', {'id': 'divA'},
createDom('input', {'id': 'inputB'}),
createShadow('div', {'id': 'divC'},
createDom('input', {'id': 'inputD'}))));
createDOM('div', {'id': 'divA'},
createShadowRoot(
createDOM('input', {'id': 'inputB'}),
createDOM('div', {'id': 'divC'},
createShadowRoot(
createDOM('input', {'id': 'inputD'}))))));
}

function test()
Expand Down
32 changes: 18 additions & 14 deletions LayoutTests/fast/dom/shadow/resources/create-dom.js
@@ -1,24 +1,28 @@
// This function can take optional child elements as arguments[2:].
function createShadow(tagName, attributes)
function createShadowRoot()
{
var element = document.createElement(tagName);
for (var name in attributes)
element.setAttribute(name, attributes[name]);
var shadow = internals.ensureShadowRoot(element);
var childElements = Array.prototype.slice.call(arguments, 2);
for (var i = 0; i < childElements.length; ++i)
shadow.appendChild(childElements[i]);
return element;
return {'isShadowRoot': true,
'children': Array.prototype.slice.call(arguments)};
}

// This function can take optional child elements as arguments[2:].
function createDom(tagName, attributes)
// 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)
element.appendChild(childElements[i]);
for (var i = 0; i < childElements.length; ++i) {
var child = childElements[i];
if (child.isShadowRoot) {
var shadowRoot;
if (window.WebKitShadowRoot)
shadowRoot = new WebKitShadowRoot(element);
else
shadowRoot = new internals.ensureShadowRoot(element);
for (var j = 0; j < child.children.length; ++j)
shadowRoot.appendChild(child.children[j]);
} else
element.appendChild(child);
}
return element;
}
32 changes: 18 additions & 14 deletions LayoutTests/fast/dom/shadow/shadow-boundary-events.html
Expand Up @@ -75,21 +75,25 @@
return element;
}

function prepareDomTree(parent)
function prepareDOMTree(parent)
{
parent.appendChild(
createDom('div', {'id': 'divA', 'style': 'padding-top: 40px'},
createDom('div', {'id': 'divB', 'style': 'width: 40px; height: 40px', 'tabindex': 0}),
createDom('div', {'id': 'divC', 'style': 'width: 40px; height: 40px', 'tabindex': 0}),
createShadow('div', {'id': 'shadowD', 'style': 'padding-top: 40px'},
createDom('div', {'id': 'divE', 'style': 'padding-top: 40px'},
createShadow('div', {'id': 'shadowF', 'style': 'padding-top: 40px'},
createShadow('div', {'id': 'shadowG', 'style': 'padding-top: 40px'},
createDom('div', {'id': 'divH', 'style': 'width: 40px; height: 40px', 'tabindex': 0}),
createDom('div', {'id': 'divI', 'style': 'width: 40px; height: 40px', 'tabindex': 0})))),
createDom('div', {'id': 'divJ', 'style': 'padding-top: 40px'},
createShadow('div', {'id': 'shadowK', 'style': 'padding-top: 40px'},
createDom('div', {'id': 'divL', 'style': 'width: 40px; height: 40px', 'tabindex': 0}))))));
createDOM('div', {'id': 'divA', 'style': 'padding-top: 40px'},
createDOM('div', {'id': 'divB', 'style': 'width: 40px; height: 40px', 'tabindex': 0}),
createDOM('div', {'id': 'divC', 'style': 'width: 40px; height: 40px', 'tabindex': 0}),
createDOM('div', {'id': 'shadowD', 'style': 'padding-top: 40px'},
createShadowRoot(
createDOM('div', {'id': 'divE', 'style': 'padding-top: 40px'},
createDOM('div', {'id': 'shadowF', 'style': 'padding-top: 40px'},
createShadowRoot(
createDOM('div', {'id': 'shadowG', 'style': 'padding-top: 40px'},
createShadowRoot(
createDOM('div', {'id': 'divH', 'style': 'width: 40px; height: 40px', 'tabindex': 0}),
createDOM('div', {'id': 'divI', 'style': 'width: 40px; height: 40px', 'tabindex': 0})))))),
createDOM('div', {'id': 'divJ', 'style': 'padding-top: 40px'},
createDOM('div', {'id': 'shadowK', 'style': 'padding-top: 40px'},
createShadowRoot(
createDOM('div', {'id': 'divL', 'style': 'width: 40px; height: 40px', 'tabindex': 0}))))))));

var ids = ['divA', 'divB', 'divC',
'shadowD', 'shadowD/divE', 'shadowD/shadowF', 'shadowD/shadowF/shadowG',
Expand Down Expand Up @@ -126,7 +130,7 @@
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
prepareDomTree(document.getElementById('sandbox'));
prepareDOMTree(document.getElementById('sandbox'));

// Test for mouseover/mouseout events.
moveMouse('divB', 'divC',
Expand Down

0 comments on commit 6695179

Please sign in to comment.