bug 321000 - search bar should strip newlines from pasted text, browser chrome test. r=gavin
authorted.mielczarek@gmail.com
Wed, 19 Sep 2007 05:47:51 -0700
changeset 6108 f5cd8c69aba208e3399c205fae1cb89de275f0fa
parent 6107 b7fdd4333584cca06488b2bfd16c1d536964a615
child 6109 9ecc601e9c7623da6235bf8a7dd5d15de8285c49
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs321000
milestone1.9a8pre
bug 321000 - search bar should strip newlines from pasted text, browser chrome test. r=gavin
browser/base/content/test/Makefile.in
browser/base/content/test/browser_bug321000.js
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -42,10 +42,16 @@ relativesrcdir  = browser/base/content/t
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _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)
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/browser_bug321000.js
@@ -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'));
+}