OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * Shortcut for document.getElementById. |
| 7 * @param {string} id of the element. |
| 8 * @return {HTMLElement} with the id. |
| 9 */ |
| 10 function $(id) { |
| 11 return document.getElementById(id); |
| 12 } |
| 13 |
| 14 /** |
| 15 * Base test fixture for ChromeVox unit tests. |
| 16 * |
| 17 * Note that while conceptually these are unit tests, these tests need |
| 18 * to run in a full web page, so they're actually run as WebUI browser |
| 19 * tests. |
| 20 * |
| 21 * @constructor |
| 22 * @extends {testing.Test} |
| 23 */ |
| 24 function ChromeVoxUnitTestBase() {} |
| 25 |
| 26 ChromeVoxUnitTestBase.prototype = { |
| 27 __proto__: testing.Test.prototype, |
| 28 |
| 29 /** @override */ |
| 30 browsePreload: DUMMY_URL, |
| 31 |
| 32 /** |
| 33 * Loads some inlined html into the current document, replacing |
| 34 * whatever was there previously. To use it, call it with the html |
| 35 * inside an inline comment, like this: |
| 36 * |
| 37 * this.loadDoc(function() {/*! |
| 38 * <p>Html goes here</p> |
| 39 * * /}); |
| 40 */ |
| 41 loadDoc: function(commentEncodedHtml) { |
| 42 var html = commentEncodedHtml.toString(). |
| 43 replace(/^[^\/]+\/\*!?/, ''). |
| 44 replace(/\*\/[^\/]+$/, ''); |
| 45 document.open(); |
| 46 document.write(html); |
| 47 document.close(); |
| 48 } |
| 49 }; |
OLD | NEW |