Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: LayoutTests/fast/html/details-open-toggle-event.html

Issue 249573002: HTMLDetailsElement should fire a 'toggle' event (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename detail to details Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/html/details-open-toggle-event-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/html/details-open-toggle-event.html
diff --git a/LayoutTests/fast/html/details-open-toggle-event.html b/LayoutTests/fast/html/details-open-toggle-event.html
new file mode 100644
index 0000000000000000000000000000000000000000..f086cb8ae6bc8cd40201f0d29331ffd131d84a12
--- /dev/null
+++ b/LayoutTests/fast/html/details-open-toggle-event.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="help" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#attr-details-open">
+<script src="../../resources/js-test.js"></script>
+</head>
+<body>
+<details id="details">
+ <summary>details</summary>
+ <input>
+</details>
+<script>
+description("Tests that a 'toggle' event is fired asynchronously whenever the open attribute is added to or removed from a details element.");
+window.jsTestIsAsync = true;
+
+var toggleEventCount = 0;
+var testEvent;
+
+function handleToggleEvent(ev) {
+ testEvent = ev;
+ shouldBe("testEvent.__proto__", "Event.prototype");
+ shouldBeEqualToString("testEvent.type", "toggle");
+ ++toggleEventCount;
+}
+
+function checkSingleToggleEvent() {
+ shouldBe("toggleEventCount", "1");
+ shouldBeTrue("details.open");
+ testEventsCoalesced();
+}
+
+function testToogleEventFired() {
+ shouldBe("toggleEventCount", "0");
+ details.open = true;
+ shouldBe("toggleEventCount", "0");
+ setTimeout(checkSingleToggleEvent, 0);
+}
+
+function checkEventsCoalesced() {
+ shouldBe("toggleEventCount", "2");
+ shouldBeFalse("details.open");
+ finishJSTest();
+}
+
+function testEventsCoalesced() {
+ // When the open attribute is toggled several times in succession,
+ // these steps essentially get coalesced so that only one event is
+ // fired.
+ details.open = false;
+ details.open = true;
+ details.open = false;
+ setTimeout(checkEventsCoalesced, 0);
+}
+
+var details = document.getElementById("details");
+details.addEventListener("toggle", handleToggleEvent);
+shouldBeFalse("details.open");
+testToogleEventFired();
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/html/details-open-toggle-event-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698