Bug 295977 - browser-chrome tests + non-multiple select fixup; r=neil@parkwaycc.co.uk
☠☠ backed out by 1e5262ff9eff ☠ ☠
authorArpad Borsos <arpad.borsos@googlemail.com>
Sat, 22 Aug 2009 11:12:31 +0200
changeset 32057 72c1f97df4c6e5c8857d97e004ab7168ef15f399
parent 32056 10119fe2af2b3f3b1df7d585a38becc90ff8d67a
child 32058 9bdc9b27f0062e3f276ec3fcba051d836bee0d39
child 32065 1e5262ff9eff7793dc807ef5de0a438989c34a21
push idunknown
push userunknown
push dateunknown
reviewersneil
bugs295977
milestone1.9.3a1pre
Bug 295977 - browser-chrome tests + non-multiple select fixup; r=neil@parkwaycc.co.uk
toolkit/content/tests/browser/Makefile.in
toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js
toolkit/content/widgets/browser.xml
--- a/toolkit/content/tests/browser/Makefile.in
+++ b/toolkit/content/tests/browser/Makefile.in
@@ -45,20 +45,23 @@ include $(DEPTH)/config/autoconf.mk
 
 DIRS = \
   common \
   data \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
-_BROWSER_FILES = \
+_BROWSER_TEST_FILES = \
   browser_bug471962.js \
   $(NULL)
 
 # browser_keyevents_during_autoscrolling.js cannot start the autoscrolling by
 # synthesizeMouse with middle button on linux, therefore, disable it temporarily
 ifneq ($(MOZ_WIDGET_TOOLKIT),gtk2)
-_BROWSER_FILES += browser_keyevents_during_autoscrolling.js
+_BROWSER_TEST_FILES += \
+  browser_keyevents_during_autoscrolling.js \
+  browser_bug295977_autoscroll_overflow.js \
+  $(NULL)
 endif
 
-libs:: $(_BROWSER_FILES)
+libs:: $(_BROWSER_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js
@@ -0,0 +1,88 @@
+function test()
+{
+  const kPrefName_AutoScroll = "general.autoScroll";
+  var prefSvc = Components.classes["@mozilla.org/preferences-service;1"]
+                          .getService(Components.interfaces.nsIPrefBranch2);
+  var kAutoScrollingEnabled = prefSvc.getBoolPref(kPrefName_AutoScroll);
+  prefSvc.setBoolPref(kPrefName_AutoScroll, true);
+
+  const expectScrollNone = 0;
+  const expectScrollVert = 1;
+  const expectScrollHori = 2;
+  const expectScrollBoth = 3;
+
+  var allTests = [
+    {elem: 'a', expected: expectScrollNone},
+    {elem: 'b', expected: expectScrollBoth},
+    {elem: 'c', expected: expectScrollHori},
+    {elem: 'd', expected: expectScrollVert},
+    {elem: 'e', expected: expectScrollVert},
+    {elem: 'f', expected: expectScrollNone}
+  ];
+
+  var doc;
+
+  function nextTest() {
+    var test = allTests.shift();
+    if(!test) {
+      endTest();
+      return;
+    }
+    var elem = doc.getElementById(test.elem);
+    EventUtils.synthesizeMouse(elem, 10, 10, { button: 1 },
+                               gBrowser.contentWindow);
+    EventUtils.synthesizeMouse(elem, 80, 80,
+                               { type: "mousemove", clickCount: "0" },
+                               gBrowser.contentWindow);
+    // the autoscroll implementation uses a 20ms interval
+    // wait for 40ms to make sure it did autoscroll at least once
+    setTimeout(function () {
+      EventUtils.synthesizeKey("VK_ESCAPE", {}, gBrowser.contentWindow);
+      var scrollVert = test.expected & expectScrollVert;
+      ok((scrollVert && elem.scrollTop > 0) ||
+         (!scrollVert && elem.scrollTop == 0),
+         test.elem+' should'+(scrollVert ? '' : ' not')+' have scrolled vertically');
+      var scrollHori = test.expected & expectScrollHori;
+      ok((scrollHori && elem.scrollLeft > 0) ||
+         (!scrollHori && elem.scrollLeft == 0),
+         test.elem+' should'+(scrollHori ? '' : ' not')+' have scrolled horizontally');
+      nextTest();
+    }, 40);
+  }
+
+  function startTest() {
+    waitForExplicitFinish();
+    gBrowser.addEventListener("load", onLoad, false);
+    var dataUri = 'data:text/html,<body>\
+    <div id="a" style="width: 100px; height: 100px; overflow: hidden;"><div style="width: 200px; height: 200px;"></div></div>\
+    <div id="b" style="width: 100px; height: 100px; overflow: auto;"><div style="width: 200px; height: 200px;"></div></div>\
+    <div id="c" style="width: 100px; height: 100px; overflow-x: auto; overflow-y: hidden;"><div style="width: 200px; height: 200px;"></div></div>\
+    <div id="d" style="width: 100px; height: 100px; overflow-y: auto; overflow-x: hidden;"><div style="width: 200px; height: 200px;"></div></div>\
+    <select id="e" style="width: 100px; height: 100px;" multiple="multiple"><option>a</option><option>a</option><option>a</option>\
+    <option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option>\
+    <option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option></select>\
+    <select id="f" style="width: 100px; height: 100px;"><option>a</option><option>a</option><option>a</option>\
+    <option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option>\
+    <option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option></select>\
+    </body>';
+    gBrowser.loadURI(dataUri);
+  }
+
+  function onLoad() {
+    gBrowser.removeEventListener("load", onLoad, false);
+    gBrowser.contentWindow.focus();
+    doc = gBrowser.contentDocument;
+    nextTest();
+  }
+
+  function endTest() {
+    // restore the changed prefs
+    prefSvc.setBoolPref(kPrefName_AutoScroll, kAutoScrollingEnabled);
+    // cleaning-up
+    gBrowser.loadURI("about:blank");
+
+    finish();
+  }
+
+  startTest();
+}
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -806,18 +806,20 @@
             }
 
             // go upward in the DOM and find any parent element that has a overflow
             // area and can therefore be scrolled
             for (this._scrollable = event.originalTarget; this._scrollable;
                  this._scrollable = this._scrollable.parentNode) {
               // do not use overflow based autoscroll for <html> Elements
               // or non-html elements such as svg or Document nodes
+              // also make sure to skip select elements that are not multiline
               if (!(this._scrollable instanceof HTMLElement) ||
-                  (this._scrollable instanceof HTMLHtmlElement)) {
+                  (this._scrollable instanceof HTMLHtmlElement) ||
+                  ((this._scrollable instanceof HTMLSelectElement) && !this._scrollable.multiple)) {
                 continue;
               }
 
               var overflowx = this._scrollable.ownerDocument.defaultView
                                   .getComputedStyle(this._scrollable, '')
                                   .getPropertyValue('overflow-x');
               var overflowy = this._scrollable.ownerDocument.defaultView
                                   .getComputedStyle(this._scrollable, '')