OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 /** | 5 /** |
6 * Tests that an observation matches the expected value. | 6 * Tests that an observation matches the expected value. |
7 * @param {Object} expected The expected value. | 7 * @param {Object} expected The expected value. |
8 * @param {Object} observed The actual value. | 8 * @param {Object} observed The actual value. |
9 * @param {string=} opt_message Optional message to include with a test | 9 * @param {string=} opt_message Optional message to include with a test |
10 * failure. | 10 * failure. |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 * @type {Function} | 136 * @type {Function} |
137 */ | 137 */ |
138 var pendingTearDown = null; | 138 var pendingTearDown = null; |
139 | 139 |
140 /** | 140 /** |
141 * Runs all functions starting with test and reports success or | 141 * Runs all functions starting with test and reports success or |
142 * failure of the test suite. | 142 * failure of the test suite. |
143 */ | 143 */ |
144 function runTests() { | 144 function runTests() { |
145 for (var name in window) { | 145 for (var name in window) { |
146 if (typeof window[name] == 'function' && /^test/.test(name)) | 146 try { |
147 testCases.push(name); | 147 if (typeof window[name] == 'function' && /^test/.test(name)) |
148 testCases.push(name); | |
149 } catch(e) { | |
150 if (location.protocol == 'data:' && e.name == 'SecurityError') { | |
Dan Beam
2015/07/21 23:37:38
this was fun to track down...
esprehn
2015/07/21 23:42:02
Woah.
| |
151 // Sometimes this file gets loaded as a data: URI. That causes issues | |
152 // when it touches window.caches or window.cookie. | |
153 } else { | |
154 throw e; | |
155 } | |
156 } | |
148 } | 157 } |
149 if (!testCases.length) { | 158 if (!testCases.length) { |
150 console.error('Failed to find test cases.'); | 159 console.error('Failed to find test cases.'); |
151 cleanTestRun = false; | 160 cleanTestRun = false; |
152 } | 161 } |
153 try { | 162 try { |
154 if (window.setUpPage) | 163 if (window.setUpPage) |
155 window.setUpPage(); | 164 window.setUpPage(); |
156 } catch(err) { | 165 } catch(err) { |
157 cleanTestRun = false; | 166 cleanTestRun = false; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 * @param {boolean} success Indicates if the test completed successfully. | 216 * @param {boolean} success Indicates if the test completed successfully. |
208 */ | 217 */ |
209 function endTests(success) { | 218 function endTests(success) { |
210 domAutomationController.setAutomationId(1); | 219 domAutomationController.setAutomationId(1); |
211 domAutomationController.send(success ? 'SUCCESS' : 'FAILURE'); | 220 domAutomationController.send(success ? 'SUCCESS' : 'FAILURE'); |
212 } | 221 } |
213 | 222 |
214 window.onerror = function() { | 223 window.onerror = function() { |
215 endTests(false); | 224 endTests(false); |
216 }; | 225 }; |
OLD | NEW |