| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Utilities that are used in multiple tests. | 5 // Utilities that are used in multiple tests. |
| 6 function MockWindow(width, height, sizer) { | 6 function MockWindow(width, height, sizer) { |
| 7 this.innerWidth = width; | 7 this.innerWidth = width; |
| 8 this.innerHeight = height; | 8 this.innerHeight = height; |
| 9 this.addEventListener = function(e, f) { | 9 this.addEventListener = function(e, f) { |
| 10 if (e == 'scroll') | 10 if (e == 'scroll') |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 width: w, | 97 width: w, |
| 98 height: h | 98 height: h |
| 99 }); | 99 }); |
| 100 }; | 100 }; |
| 101 this.reset = function() { | 101 this.reset = function() { |
| 102 this.width = 0; | 102 this.width = 0; |
| 103 this.height = 0; | 103 this.height = 0; |
| 104 this.pageDimensions = []; | 104 this.pageDimensions = []; |
| 105 }; | 105 }; |
| 106 } | 106 } |
| 107 | |
| 108 function importHTML(src) { | |
| 109 var link = document.createElement('link'); | |
| 110 var promise = new Promise(function(resolve, reject) { | |
| 111 link.onload = resolve; | |
| 112 link.onerror = reject; | |
| 113 }); | |
| 114 link.rel = 'import'; | |
| 115 link.href = src; | |
| 116 document.head.appendChild(link); | |
| 117 return promise; | |
| 118 } | |
| 119 | |
| 120 /** | |
| 121 * Import iron-test-helpers into the test document. | |
| 122 * @example | |
| 123 * importTestHelpers().then(function() { | |
| 124 * chrome.test.runTests(...); | |
| 125 * }) | |
| 126 */ | |
| 127 function importTestHelpers() { | |
| 128 return importHTML('chrome://resources/polymer/v1_0/iron-test-helpers/' + | |
| 129 'iron-test-helpers.html'); | |
| 130 } | |
| OLD | NEW |