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 // Common testing utilities. |
| 6 |
| 7 /** |
| 8 * Shortcut for document.getElementById. |
| 9 * @param {string} id of the element. |
| 10 * @return {HTMLElement} with the id. |
| 11 */ |
| 12 function $(id) { |
| 13 return document.getElementById(id); |
| 14 } |
| 15 |
| 16 /** |
| 17 * @constructor |
| 18 */ |
| 19 var TestUtils = function() {}; |
| 20 |
| 21 /** |
| 22 * Extracts some inlined html encoded as a comment inside a function, |
| 23 * so you can use it like this: |
| 24 * |
| 25 * this.appendDoc(function() {/*! |
| 26 * <p>Html goes here</p> |
| 27 * * /}); |
| 28 * |
| 29 * @param {Function} commentEncodedHtml The html , embedded as a |
| 30 * comment inside an anonymous function - see example, above. |
| 31 * @return {string} The html text. |
| 32 */ |
| 33 TestUtils.extractHtmlFromCommentEncodedString = function(commentEncodedHtml) { |
| 34 return commentEncodedHtml.toString(). |
| 35 replace(/^[^\/]+\/\*!?/, ''). |
| 36 replace(/\*\/[^\/]+$/, ''); |
| 37 }; |
OLD | NEW |