mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
bug 321000 - search bar should strip newlines from pasted text, browser chrome test. r=gavin
This commit is contained in:
parent
0ca5566a00
commit
1be98ab69e
@ -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)
|
||||
|
25
browser/base/content/test/browser_bug321000.js
Normal file
25
browser/base/content/test/browser_bug321000.js
Normal 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'));
|
||||
}
|
Loading…
Reference in New Issue
Block a user