diff options
author | patrick@chromium.org <patrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-12 01:08:42 +0000 |
---|---|---|
committer | patrick@chromium.org <patrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-12 01:08:42 +0000 |
commit | 71a050a42cdb55b0a9b685b096297b97918312d2 (patch) | |
tree | fba7408b4d762a83db463c9101fb437daf3418a0 /chrome/test/data/dom_checker/extra_utils.js | |
parent | c489b2702caeb985677c0d1ff2a7a1678bbb41a8 (diff) | |
download | chromium_src-71a050a42cdb55b0a9b685b096297b97918312d2.zip chromium_src-71a050a42cdb55b0a9b685b096297b97918312d2.tar.gz chromium_src-71a050a42cdb55b0a9b685b096297b97918312d2.tar.bz2 |
- Add UI test for DOM checker.
- Modify DOM checker to work with the UI test framework.
- Add expected failure list for DOM checker.
Note that this only runs the tests over HTTP, not file:///.
BUG=6274
Review URL: http://codereview.chromium.org/43029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11505 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/data/dom_checker/extra_utils.js')
-rw-r--r-- | chrome/test/data/dom_checker/extra_utils.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/chrome/test/data/dom_checker/extra_utils.js b/chrome/test/data/dom_checker/extra_utils.js new file mode 100644 index 0000000..bf62d7c --- /dev/null +++ b/chrome/test/data/dom_checker/extra_utils.js @@ -0,0 +1,50 @@ +/* + Copyright (c) 2009 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. +*/ + +// Write a cookie with a given name and value. +function writeCookie(name, value) { + document.cookie = name + '=' + value + '; path=/'; +} + +// Convert an array to a string to be stored in a cookie. +// +// Since cookie values are limited in length, this function takes a parameter +// 'max_chars' to indicate the maximum length of the returned string. The +// returned string will be less than or equal to 'max_chars' in length. Values +// from the array are added to the string, in left to right order, until either +// there are no more elements in the array or the next element will cause the +// string to overflow the maximum number of characters allowed. +function convertArrayToCookieValue(arr, max_chars) { + var string_builder = []; + var current_length = 0; + + for (var i = 0; i < arr.length && current_length <= max_chars; ++i) { + var value = arr[i].toString(); + + // Get rid of newline characters. + value = value.replace(/[\r\n]/g, ''); + // Replace reserved characters with spaces. + value = value.replace(/[,;=]/g, ' '); + + // Make sure that the string length doesn't exceed the maximum allowed + // number of characters. + if (current_length + value.length > max_chars) + break; + + string_builder.push(value); + + // Add an extra 1 to factor in the length of the separator (a comma). + current_length += value.length + 1; + } + + return string_builder.toString(); +} + +// Override functions that can spawn dialog boxes. + +window.alert = function() {} +window.confirm = function() {} +window.prompt = function() {} |