summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/catapult/tracing/tracing/ui/base/utils_test.html
blob: 4ab76e1d221977489b87a4c6568a4755df522984 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<!--
Copyright (c) 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="/tracing/ui/base/utils.html">

<dom-module id='instantiate-template-polymer-element-test'>
  <template></template>
</dom-module>
<script>
'use strict';
Polymer({
  is: 'instantiate-template-polymer-element-test',
  testProperty: 'Test'
});
</script>
<template id="instantiate-template-polymer-test">
  <instantiate-template-polymer-element-test>
  </instantiate-template-polymer-element-test>
</template>

<template id="multiple-template-test">
  <template>
    <instantiate-template-polymer-element-test>
    </instantiate-template-polymer-element-test>
    <span test-attribute='TestAttribute'>Foo</span>
  </template>
  <instantiate-template-polymer-element-test>
  </instantiate-template-polymer-element-test>
</template>
<script>
'use strict';

tr.b.unittest.testSuite(function() {
  const THIS_DOC = document.currentScript.ownerDocument;

  test('instantiateTemplatePolymer', function() {
    const e = tr.ui.b.instantiateTemplate(
        '#instantiate-template-polymer-test',
        THIS_DOC);
    assert.strictEqual(e.children.length, 1);
    assert.strictEqual(e.children[0].testProperty, 'Test');
  });

  test('instantiateTemplateMultipleTemplates', function() {
    const outerElement = tr.ui.b.instantiateTemplate(
        '#multiple-template-test',
        THIS_DOC);
    assert.strictEqual(outerElement.children.length, 2);
    assert.strictEqual(outerElement.children[1].testProperty, 'Test');

    // Make sure we can still instantiate inner templates, if we need them.
    const innerElement = THIS_DOC.importNode(
        outerElement.children[0].content, true);
    assert.strictEqual(innerElement.children.length, 2);
    assert.strictEqual(innerElement.children[0].testProperty, 'Test');
    assert.strictEqual(
        innerElement.children[1].getAttribute('test-attribute'),
        'TestAttribute');
    assert.strictEqual(
        Polymer.dom(innerElement.children[1]).textContent, 'Foo');
  });

  test('extractUrlStringAcceptsBothVersions', function() {
    const oldStyleUrl = 'url(content)';
    const newStyleUrl = 'url("content")';
    const expectedResult = 'content';

    assert.strictEqual(tr.ui.b.extractUrlString(oldStyleUrl), expectedResult);
    assert.strictEqual(tr.ui.b.extractUrlString(newStyleUrl), expectedResult);
  });
});
</script>