From 930fcbcccbb7a4c0c8892acf175503555099e29c Mon Sep 17 00:00:00 2001 From: dtseng Date: Mon, 29 Sep 2014 12:36:32 -0700 Subject: ImplementChromeVox next/previous line, link, and heading. Review URL: https://codereview.chromium.org/586103004 Cr-Commit-Position: refs/heads/master@{#297234} --- .../resources/chromeos/chromevox/testing/common.js | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 chrome/browser/resources/chromeos/chromevox/testing/common.js (limited to 'chrome/browser/resources/chromeos/chromevox/testing/common.js') diff --git a/chrome/browser/resources/chromeos/chromevox/testing/common.js b/chrome/browser/resources/chromeos/chromevox/testing/common.js new file mode 100644 index 0000000..38f2d59 --- /dev/null +++ b/chrome/browser/resources/chromeos/chromevox/testing/common.js @@ -0,0 +1,37 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Common testing utilities. + +/** + * Shortcut for document.getElementById. + * @param {string} id of the element. + * @return {HTMLElement} with the id. + */ +function $(id) { + return document.getElementById(id); +} + +/** + * @constructor + */ +var TestUtils = function() {}; + +/** + * Extracts some inlined html encoded as a comment inside a function, + * so you can use it like this: + * + * this.appendDoc(function() {/*! + *

Html goes here

+ * * /}); + * + * @param {Function} commentEncodedHtml The html , embedded as a + * comment inside an anonymous function - see example, above. + * @return {string} The html text. +*/ +TestUtils.extractHtmlFromCommentEncodedString = function(commentEncodedHtml) { + return commentEncodedHtml.toString(). + replace(/^[^\/]+\/\*!?/, ''). + replace(/\*\/[^\/]+$/, ''); +}; -- cgit v1.1