bug 321000 - search bar should strip newlines from pasted text, browser chrome test. r=gavin

This commit is contained in:
ted.mielczarek@gmail.com 2007-09-19 05:47:51 -07:00
parent 0ca5566a00
commit 1be98ab69e
2 changed files with 31 additions and 0 deletions

View File

@ -47,5 +47,11 @@ _TEST_FILES = test_feed_discovery.html \
feed_discovery.html \
$(NULL)
_BROWSER_FILES = browser_bug321000.js \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
libs:: $(_BROWSER_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)

View File

@ -0,0 +1,25 @@
const Ci = Components.interfaces;
const Cc = Components.classes;
function testPaste(name, element, expected) {
element.focus();
EventUtils.synthesizeKey("v", { accelKey: true });
is(element.value, expected, name);
}
// test bug 23485 and bug 321000
// urlbar should strip newlines,
// search bar should replace newlines with spaces
function test() {
var testString = " hello hello \n world\nworld ";
// Put a multi-line string in the clipboard
Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper)
.copyString(testString);
testPaste('urlbar strips newlines and surrounding whitespace',
document.getElementById('urlbar'),
testString.replace(/\s*\n\s*/g,''));
testPaste('searchbar replaces newlines with spaces',
document.getElementById('searchbar'),
testString.replace('\n',' ','g'));
}