3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
12 <meta charset=
"UTF-8">
13 <title>paper-dropdown-menu basic tests
</title>
14 <meta name=
"viewport" content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0">
16 <script src=
"../../webcomponentsjs/webcomponents.js"></script>
17 <script src=
"../../web-component-tester/browser.js"></script>
19 <link href=
"../core-dropdown.html" rel=
"import">
31 <div relative
id=
"trigger1">
33 <core-dropdown id=
"dropdown1">Hello World!
</core-dropdown>
36 <div relative
id=
"trigger2">
38 <core-dropdown id=
"dropdown2">Hello World!
</core-dropdown>
41 <div relative
id=
"trigger3">
43 <core-dropdown id=
"dropdown3">Hello World!
</core-dropdown>
48 function assertPosition(dropdown
, trigger
) {
49 var dr
= dropdown
.getBoundingClientRect();
50 var tr
= trigger
.getBoundingClientRect();
52 if (dropdown
.halign
=== 'left') {
53 assert
.equal(dr
.left
, tr
.left
);
55 assert
.equal(dr
.right
, tr
.right
);
58 if (dropdown
.valign
=== 'top') {
59 assert
.equal(dr
.top
, tr
.top
);
61 assert
.equal(dr
.bottom
, tr
.bottom
);
65 function flushLayoutAndRender(callback
) {
67 document
.body
.offsetTop
;
68 requestAnimationFrame(function() {
74 var d1
= document
.getElementById('dropdown1');
75 var t1
= document
.getElementById('trigger1');
76 d1
.relatedTarget
= t1
;
78 var d2
= document
.getElementById('dropdown2');
79 var t2
= document
.getElementById('trigger2');
80 d2
.relatedTarget
= t2
;
82 var d3
= document
.getElementById('dropdown3');
83 var t3
= document
.getElementById('trigger3');
84 d3
.relatedTarget
= t3
;
86 test('default', function(done
) {
88 flushLayoutAndRender(function() {
89 assertPosition(d1
, t1
);
94 test('bottom alignment', function(done
) {
97 flushLayoutAndRender(function() {
98 assertPosition(d2
, t2
);
103 test('right alignment', function(done
) {
106 flushLayoutAndRender(function() {
107 assertPosition(d3
, t3
);