Home | History | Annotate | Download | only in base
      1 <!DOCTYPE html>
      2 <!--
      3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
      4 Use of this source code is governed by a BSD-style license that can be
      5 found in the LICENSE file.
      6 -->
      7 
      8 <link rel="import" href="/tracing/ui/base/deep_utils.html">
      9 
     10 <script>
     11 'use strict';
     12 
     13 tr.b.unittest.testSuite(function() {
     14   function createElement(tagName, opt_class) {
     15     var el = document.createElement(tagName);
     16     if (opt_class)
     17       el.className = opt_class;
     18     return el;
     19   }
     20 
     21   test('testFindDeepElementMatching', function() {
     22     var a = createElement('a');
     23     var a_ = a.createShadowRoot();
     24 
     25     var b = createElement('b');
     26     a_.appendChild(b);
     27 
     28     var b_ = b.createShadowRoot();
     29     b_.appendChild(createElement('c', 'x'));
     30 
     31     var m = tr.b.findDeepElementMatching(a, 'c.x');
     32     assert.equal(m, b_.children[0]);
     33   });
     34 
     35   test('testFindDeepElementsMatching', function() {
     36     var a = createElement('a');
     37     var a_ = a.createShadowRoot();
     38 
     39     var b = createElement('b');
     40     a_.appendChild(b);
     41 
     42     var b_ = b.createShadowRoot();
     43     b_.appendChild(createElement('c', 'x'));
     44     b_.appendChild(createElement('c', 'x'));
     45 
     46     var m = tr.b.findDeepElementsMatching(a, 'c.x');
     47     assert.equal(m[0], b_.children[0]);
     48     assert.equal(m[1], b_.children[1]);
     49   });
     50 });
     51 </script>
     52