Bug 1245424 Part 3 - Add reftest for click events with actions in capturing phase. r=bz
authorTing-Yu Lin <tlin@mozilla.com>
Thu, 24 Mar 2016 15:05:29 +0800
changeset 290238 777d18c1f5215a72666d4e3fb7a1daeaf354de50
parent 290237 0e7a2d01c65f1b6c76c0063bdaa66608e355d4d3
child 290239 e8e55ed9453a904bf65c30ab080a3f6aa2811f88
push id30117
push userryanvm@gmail.com
push dateFri, 25 Mar 2016 15:36:00 +0000
treeherdermozilla-central@b45ee3e065b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1245424
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1245424 Part 3 - Add reftest for click events with actions in capturing phase. r=bz These tests modify details or summary elements in the 'click' event listener in capturing phase higher up in the DOM tree. MozReview-Commit-ID: Lp5OzXnNgL4
layout/reftests/details-summary/mouse-click-change-details-to-display-none.html
layout/reftests/details-summary/mouse-click-change-summary-to-display-none-ref.html
layout/reftests/details-summary/mouse-click-change-summary-to-display-none.html
layout/reftests/details-summary/mouse-click-move-summary-to-different-details-ref.html
layout/reftests/details-summary/mouse-click-move-summary-to-different-details.html
layout/reftests/details-summary/reftest.list
new file mode 100644
--- /dev/null
+++ b/layout/reftests/details-summary/mouse-click-change-details-to-display-none.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+
+<html class="reftest-wait">
+  <script>
+  function runTest() {
+    // Both Chrome and Safari add the 'open' attribute to the details element.
+    var details = document.getElementById("details");
+    var summary = document.getElementById("summary");
+
+    document.body.addEventListener("click", function () {
+      // Change details to display: none in capturing phase.
+      details.style.display = "none";
+    }, true);
+
+    summary.dispatchEvent(new MouseEvent("click"));
+
+    details.style.display = "block";
+    document.documentElement.removeAttribute("class");
+  }
+  </script>
+  <body onload="runTest();">
+    <details id="details">
+      <summary id="summary">Summary</summary>
+      <p>This is the details.</p>
+    </details>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/details-summary/mouse-click-change-summary-to-display-none-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+
+<html>
+  <body>
+    <div>
+      <p>This is the details.</p>
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/details-summary/mouse-click-change-summary-to-display-none.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+
+<html class="reftest-wait">
+  <script>
+  function runTest() {
+    // Both Chrome and Safari add the 'open' attribute to the details element.
+    // Firefox has the same behavior.
+    var details = document.getElementById("details");
+    var summary = document.getElementById("summary");
+
+    document.body.addEventListener("click", function () {
+      // Change summary to display: none in capturing phase.
+      summary.style.display = "none";
+    }, true);
+
+    summary.dispatchEvent(new MouseEvent("click"));
+
+    document.documentElement.removeAttribute("class");
+  }
+  </script>
+  <body onload="runTest();">
+    <details id="details">
+      <summary id="summary">Summary</summary>
+      <p>This is the details.</p>
+    </details>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/details-summary/mouse-click-move-summary-to-different-details-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+
+<html>
+  <body>
+    <details open>
+      <summary>Summary 2</summary>
+      <summary>Summary 1</summary>
+      <p>This is the details 1.</p>
+    </details>
+    <details>
+      <p>This is the details 2.</p>
+    </details>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/details-summary/mouse-click-move-summary-to-different-details.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+
+<html class="reftest-wait">
+  <script>
+  function runTest() {
+    // Both Chrome and Safari do not add the 'open' attribute to details1
+    // element, but Firefox does add 'open' to details1 since summary2 had been
+    // moved to details1 before receiving the 'click' event.
+    var details1 = document.getElementById("details1");
+    var summary2 = document.getElementById("summary2");
+
+    document.body.addEventListener("click", function () {
+      // Move summary2 into details1 at capture phase, and summary2 will be the
+      // main summary of details1 at target phase.
+      details1.insertBefore(summary2, details1.children[0]);
+    }, true);
+
+    summary2.dispatchEvent(new MouseEvent("click"));
+
+    document.documentElement.removeAttribute("class");
+  }
+  </script>
+  <body onload="runTest();">
+    <details id="details1">
+      <summary id="summary1">Summary 1</summary>
+      <p>This is the details 1.</p>
+    </details>
+    <details>
+      <summary id="summary2">Summary 2</summary>
+      <p>This is the details 2.</p>
+    </details>
+  </body>
+</html>
--- a/layout/reftests/details-summary/reftest.list
+++ b/layout/reftests/details-summary/reftest.list
@@ -61,16 +61,19 @@ pref(dom.details_element.enabled,true) =
 pref(dom.details_element.enabled,true) == mouse-click-open-single-summary.html single-summary.html
 pref(dom.details_element.enabled,true) == mouse-click-twice-open-single-summary.html open-single-summary.html
 pref(dom.details_element.enabled,true) == mouse-click-open-second-summary.html open-multiple-summary.html
 pref(dom.details_element.enabled,true) == mouse-click-overflow-hidden-details.html overflow-hidden-open-details.html
 pref(dom.details_element.enabled,true) == mouse-click-twice-overflow-hidden-details.html overflow-hidden-details.html
 pref(dom.details_element.enabled,true) == mouse-click-overflow-auto-details.html overflow-auto-open-details.html
 pref(dom.details_element.enabled,true) == mouse-click-twice-overflow-auto-details.html overflow-auto-details.html
 pref(dom.details_element.enabled,true) == mouse-click-display-none-details.html open-single-summary.html
+pref(dom.details_element.enabled,true) == mouse-click-change-details-to-display-none.html open-single-summary.html
+pref(dom.details_element.enabled,true) == mouse-click-change-summary-to-display-none.html mouse-click-change-summary-to-display-none-ref.html
+pref(dom.details_element.enabled,true) == mouse-click-move-summary-to-different-details.html mouse-click-move-summary-to-different-details-ref.html
 
 # Dispatch mouse click to out-of-flow details or summary
 pref(dom.details_element.enabled,true) == mouse-click-fixed-summary.html open-fixed-summary.html
 pref(dom.details_element.enabled,true) == mouse-click-twice-fixed-summary.html fixed-summary.html
 pref(dom.details_element.enabled,true) == mouse-click-float-details.html open-float-details.html
 pref(dom.details_element.enabled,true) == mouse-click-twice-float-details.html float-details.html
 
 # Dispatch keyboard event to summary