| Index: 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
|
| index b6e6d33d49279bee457170ccba8a63fa75b9e705..9c0fc0bf70c647a75c7c64a49051b7608608de55 100644
|
| --- a/chrome/browser/resources/chromeos/chromevox/testing/common.js
|
| +++ b/chrome/browser/resources/chromeos/chromevox/testing/common.js
|
| @@ -42,6 +42,28 @@ TestUtils.extractHtmlFromCommentEncodedString =
|
| return stringified.replace(/^[^\/]+\/\*!?/, '').replace(/\*\/[^\/]+$/, '');
|
| };
|
|
|
| +
|
| + /**
|
| + * Creates a data url for a document.
|
| + * @param {function() : void} doc Snippet wrapped inside of a function.
|
| + * @return {string}
|
| + */
|
| +TestUtils.createUrlForDoc = function(doc) {
|
| + var docString = TestUtils.extractHtmlFromCommentEncodedString(doc);
|
| + return TestUtils.collapseWhitespace('data:text/html,<!doctype html>' +
|
| + docString.replace(/[\n\r]/g, '')
|
| + .trim());
|
| +};
|
| +
|
| +/**
|
| + * Collapses inner whitespace.
|
| + * @param {string} str
|
| + * @return {string}
|
| + */
|
| +TestUtils.collapseWhitespace = function(str) {
|
| + return str.replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, '');
|
| +};
|
| +
|
| /**
|
| * Similar to |TEST_F|. Generates a test for the given |testFixture|,
|
| * |testName|, and |testFunction|.
|
|
|