OLD | NEW |
1 /** | 1 /** |
2 * @license | 2 * @license |
3 * Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 3 * Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
4 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt | 4 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
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/CON
TRIBUTORS.txt | 6 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
7 * Code distributed by Google as part of the polymer project is also | 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/PA
TENTS.txt | 8 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
9 */ | 9 */ |
10 (function(global) { | 10 (function(global) { |
| 11 'use strict'; |
11 | 12 |
12 global.flushAsynchronousOperations = function() { | 13 global.flushAsynchronousOperations = function() { |
13 // force distribution | 14 // force distribution |
14 Polymer.dom.flush(); | 15 Polymer.dom.flush(); |
15 // force lifecycle callback to fire on polyfill | 16 // force lifecycle callback to fire on polyfill |
16 window.CustomElements && window.CustomElements.takeRecords(); | 17 window.CustomElements && window.CustomElements.takeRecords(); |
17 }; | 18 }; |
18 | 19 |
19 global.forceXIfStamp = function(node) { | 20 global.forceXIfStamp = function(node) { |
20 var templates = Polymer.dom(node.root).querySelectorAll('template[is=dom-if]
'); | 21 var templates = Polymer.dom(node.root).querySelectorAll('template[is=dom-if]
'); |
21 for (var tmpl, i = 0; tmpl = templates[i]; i++) { | 22 for (var tmpl, i = 0; tmpl = templates[i]; i++) { |
22 tmpl.render(); | 23 tmpl.render(); |
23 } | 24 } |
24 | 25 |
25 global.flushAsynchronousOperations(); | 26 global.flushAsynchronousOperations(); |
26 }; | 27 }; |
27 | 28 |
28 global.fireEvent = function(type, props, node) { | 29 global.fireEvent = function(type, props, node) { |
29 var event = new CustomEvent(type, { | 30 var event = new CustomEvent(type, { |
30 bubbles: true, | 31 bubbles: true, |
31 cancelable: true | 32 cancelable: true |
32 }); | 33 }); |
33 for (p in props) { | 34 for (var p in props) { |
34 event[p] = props[p]; | 35 event[p] = props[p]; |
35 } | 36 } |
36 node.dispatchEvent(event); | 37 node.dispatchEvent(event); |
37 }; | 38 }; |
38 | 39 |
| 40 global.skipUnless = function(condition, test) { |
| 41 var isAsyncTest = !!test.length; |
| 42 |
| 43 return function(done) { |
| 44 var testCalledDone = false; |
| 45 |
| 46 if (!condition()) { |
| 47 return done(); |
| 48 } |
| 49 |
| 50 var result = test.call(this, done); |
| 51 |
| 52 if (!isAsyncTest) { |
| 53 done(); |
| 54 } |
| 55 |
| 56 return result; |
| 57 }; |
| 58 }; |
39 })(this); | 59 })(this); |
OLD | NEW |