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