Changeset 109191 in webkit


Ignore:
Timestamp:
Feb 28, 2012 10:09:22 PM (12 years ago)
Author:
hayato@chromium.org
Message:

[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:
Location:
trunk/LayoutTests
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r109187 r109191  
     12012-02-28  Hayato Ito  <hayato@chromium.org>
     2
     3        [Shadow DOM] Make createDOM() function used in testing Shadow DOM more flexible.
     4        https://bugs.webkit.org/show_bug.cgi?id=79745
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Replaces createDom and createShadow function defined in
     9        LayoutTests/fast/dom/shadow/create-dom.js with more flexible
     10        one. Now we can represent a shadow host which has both light
     11        children and ShadowRoots in one expression.
     12
     13        * fast/dom/shadow/access-key.html:
     14        * fast/dom/shadow/get-element-by-id-in-shadow-root.html:
     15        * fast/dom/shadow/resources/create-dom.js:
     16        (createShadowRoot):
     17        (createDOM):
     18        * fast/dom/shadow/shadow-boundary-events.html:
     19
    1202012-02-28  Kenichi Ishibashi  <bashi@chromium.org>
    221
  • trunk/LayoutTests/fast/dom/shadow/access-key.html

    r98407 r109191  
    5656}
    5757
    58 function prepareDomTree(parent)
     58function prepareDOMTree(parent)
    5959{
    6060    parent.appendChild(
    61         createDom('div', {'id': 'divA'},
    62                   createDom('input', {'id': 'inputB'}),
    63                   createShadow('div', {'id': 'shadowC', 'tabindex': 0},
    64                                createDom('input', {'id': 'inputD'}),
    65                                createDom('input', {'id': 'inputE', 'accesskey': 'a'}),
    66                                createShadow('div', {'id': 'shadowF', 'tabindex': 0},
    67                                             createDom('input', {'id': 'inputG'})))));
     61        createDOM('div', {'id': 'divA'},
     62                  createDOM('input', {'id': 'inputB'}),
     63                  createDOM('div', {'id': 'shadowC', 'tabindex': 0},
     64                            createShadowRoot(
     65                                createDOM('input', {'id': 'inputD'}),
     66                                createDOM('input', {'id': 'inputE', 'accesskey': 'a'}),
     67                                createDOM('div', {'id': 'shadowF', 'tabindex': 0},
     68                                          createShadowRoot(
     69                                              createDOM('input', {'id': 'inputG'})))))));
    6870
    6971    var ids = ['inputB',
     
    8183        layoutTestController.dumpAsText();
    8284
    83     prepareDomTree(document.getElementById('sandbox'));
     85    prepareDOMTree(document.getElementById('sandbox'));
    8486
    8587    // Please see the discussion of https://bugs.webkit.org/show_bug.cgi?id=67096.
  • trunk/LayoutTests/fast/dom/shadow/get-element-by-id-in-shadow-root.html

    r98407 r109191  
    2323{
    2424    parent.appendChild(
    25         createShadow('div', {'id': 'divA'},
    26                      createDom('input', {'id': 'inputB'}),
    27                      createShadow('div', {'id': 'divC'},
    28                                   createDom('input', {'id': 'inputD'}))));
     25        createDOM('div', {'id': 'divA'},
     26                  createShadowRoot(
     27                      createDOM('input', {'id': 'inputB'}),
     28                      createDOM('div', {'id': 'divC'},
     29                                createShadowRoot(
     30                                    createDOM('input', {'id': 'inputD'}))))));
    2931}
    3032
  • trunk/LayoutTests/fast/dom/shadow/resources/create-dom.js

    r92124 r109191  
    1 // This function can take optional child elements as arguments[2:].
    2 function createShadow(tagName, attributes)
     1function createShadowRoot()
    32{
    4     var element = document.createElement(tagName);
    5     for (var name in attributes)
    6         element.setAttribute(name, attributes[name]);
    7     var shadow = internals.ensureShadowRoot(element);
    8     var childElements = Array.prototype.slice.call(arguments, 2);
    9     for (var i = 0; i < childElements.length; ++i)
    10         shadow.appendChild(childElements[i]);
    11     return element;
     3    return {'isShadowRoot': true,
     4            'children': Array.prototype.slice.call(arguments)};
    125}
    136
    14 // This function can take optional child elements as arguments[2:].
    15 function createDom(tagName, attributes)
     7// This function can take optional child elements, which might be a result of createShadowRoot(), as arguments[2:].
     8function createDOM(tagName, attributes)
    169{
    1710    var element = document.createElement(tagName);
     
    1912        element.setAttribute(name, attributes[name]);
    2013    var childElements = Array.prototype.slice.call(arguments, 2);
    21     for (var i = 0; i < childElements.length; ++i)
    22         element.appendChild(childElements[i]);
     14    for (var i = 0; i < childElements.length; ++i) {
     15        var child = childElements[i];
     16        if (child.isShadowRoot) {
     17            var shadowRoot;
     18            if (window.WebKitShadowRoot)
     19              shadowRoot = new WebKitShadowRoot(element);
     20            else
     21              shadowRoot = new internals.ensureShadowRoot(element);
     22            for (var j = 0; j < child.children.length; ++j)
     23                shadowRoot.appendChild(child.children[j]);
     24        } else
     25            element.appendChild(child);
     26    }
    2327    return element;
    2428}
  • trunk/LayoutTests/fast/dom/shadow/shadow-boundary-events.html

    r108034 r109191  
    7676}
    7777
    78 function prepareDomTree(parent)
     78function prepareDOMTree(parent)
    7979{
    8080    parent.appendChild(
    81         createDom('div', {'id': 'divA', 'style': 'padding-top: 40px'},
    82                   createDom('div', {'id': 'divB', 'style': 'width: 40px; height: 40px', 'tabindex': 0}),
    83                   createDom('div', {'id': 'divC', 'style': 'width: 40px; height: 40px', 'tabindex': 0}),
    84                   createShadow('div', {'id': 'shadowD', 'style': 'padding-top: 40px'},
    85                                createDom('div', {'id': 'divE', 'style': 'padding-top: 40px'},
    86                                          createShadow('div', {'id': 'shadowF', 'style': 'padding-top: 40px'},
    87                                                       createShadow('div', {'id': 'shadowG', 'style': 'padding-top: 40px'},
    88                                                                    createDom('div', {'id': 'divH', 'style': 'width: 40px; height: 40px', 'tabindex': 0}),
    89                                                                    createDom('div', {'id': 'divI', 'style': 'width: 40px; height: 40px', 'tabindex': 0})))),
    90                                createDom('div', {'id': 'divJ', 'style': 'padding-top: 40px'},
    91                                          createShadow('div', {'id': 'shadowK', 'style': 'padding-top: 40px'},
    92                                                       createDom('div', {'id': 'divL', 'style': 'width: 40px; height: 40px', 'tabindex': 0}))))));
     81        createDOM('div', {'id': 'divA', 'style': 'padding-top: 40px'},
     82                  createDOM('div', {'id': 'divB', 'style': 'width: 40px; height: 40px', 'tabindex': 0}),
     83                  createDOM('div', {'id': 'divC', 'style': 'width: 40px; height: 40px', 'tabindex': 0}),
     84                  createDOM('div', {'id': 'shadowD', 'style': 'padding-top: 40px'},
     85                            createShadowRoot(
     86                                createDOM('div', {'id': 'divE', 'style': 'padding-top: 40px'},
     87                                          createDOM('div', {'id': 'shadowF', 'style': 'padding-top: 40px'},
     88                                                    createShadowRoot(
     89                                                        createDOM('div', {'id': 'shadowG', 'style': 'padding-top: 40px'},
     90                                                                  createShadowRoot(
     91                                                                      createDOM('div', {'id': 'divH', 'style': 'width: 40px; height: 40px', 'tabindex': 0}),
     92                                                                      createDOM('div', {'id': 'divI', 'style': 'width: 40px; height: 40px', 'tabindex': 0})))))),
     93                                createDOM('div', {'id': 'divJ', 'style': 'padding-top: 40px'},
     94                                          createDOM('div', {'id': 'shadowK', 'style': 'padding-top: 40px'},
     95                                                    createShadowRoot(
     96                                                        createDOM('div', {'id': 'divL', 'style': 'width: 40px; height: 40px', 'tabindex': 0}))))))));
    9397
    9498    var ids = ['divA', 'divB', 'divC',
     
    127131    if (window.layoutTestController)
    128132        layoutTestController.dumpAsText();
    129     prepareDomTree(document.getElementById('sandbox'));
     133    prepareDOMTree(document.getElementById('sandbox'));
    130134
    131135    // Test for mouseover/mouseout events.
Note: See TracChangeset for help on using the changeset viewer.