Bug 1266575 - Regression test. r=Felipe, a=sylvestre
authorMike Conley <mconley@mozilla.com>
Mon, 16 May 2016 10:41:25 -0400
changeset 333283 7e4d77c786f9dafd1413f8e99ce176f74626c14c
parent 333282 9c547e1686c8275f34171e0c4a0156c1a183bb06
child 333284 8f2c9241267a2b73f55eb366ad20e25c305623e8
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe, sylvestre
bugs1266575
milestone48.0a2
Bug 1266575 - Regression test. r=Felipe, a=sylvestre MozReview-Commit-ID: 7mOVDXFqozL
browser/base/content/test/general/browser_selectpopup.js
--- a/browser/base/content/test/general/browser_selectpopup.js
+++ b/browser/base/content/test/general/browser_selectpopup.js
@@ -270,8 +270,75 @@ add_task(function*() {
     is(rect.left, expectedX, "step " + (stepIndex + 1) + " x");
     is(rect.top, expectedY, "step " + (stepIndex + 1) + " y");
 
     yield hideSelectPopup(selectPopup);
   }
 
   yield BrowserTestUtils.removeTab(tab);
 });
+
+// Test that we get the right events when a select popup is changed.
+add_task(function* test_event_order() {
+  const URL = "data:text/html," + escape(PAGECONTENT_SMALL);
+  yield BrowserTestUtils.withNewTab({
+    gBrowser,
+    url: URL,
+  }, function*(browser) {
+    let menulist = document.getElementById("ContentSelectDropdown");
+    let selectPopup = menulist.menupopup;
+
+    yield openSelectPopup(selectPopup, true, "#one");
+
+    let eventsPromise = ContentTask.spawn(browser, null, function*() {
+      // According to https://html.spec.whatwg.org/#the-select-element,
+      // we want to fire input, change, and then click events on the
+      // <select> (in that order) when it has changed.
+      let expected = [
+        {
+          type: "input",
+          cancelable: false,
+        },
+        {
+          type: "change",
+          cancelable: false,
+        },
+        {
+          type: "mousedown",
+          cancelable: true,
+        },
+        {
+          type: "mouseup",
+          cancelable: true,
+        },
+        {
+          type: "click",
+          cancelable: true,
+        },
+      ];
+
+      return new Promise((resolve) => {
+        function onEvent(event) {
+          select.removeEventListener(event.type, onEvent);
+          let expectation = expected.shift();
+          Assert.equal(event.type, expectation.type,
+                       "Expected the right event order");
+          Assert.ok(event.bubbles, "All of these events should bubble");
+          Assert.equal(event.cancelable, expectation.cancelable,
+                       "Cancellation property should match");
+          if (!expected.length) {
+            resolve();
+          }
+        }
+
+        let select = content.document.getElementById("one");
+        for (let expectation of expected) {
+          select.addEventListener(expectation.type, onEvent);
+        }
+      });
+    });
+
+    EventUtils.synthesizeKey("KEY_ArrowDown", { code: "ArrowDown" });
+    yield hideSelectPopup(selectPopup, false);
+    yield eventsPromise;
+  });
+});
+