Chromium Code Reviews| 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..d268c0291dad497d94da67183a56195ca387a80c |
| --- /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; |
| + |
| +function handleToggleEvent(ev) { |
| + testEvent = ev; |
|
arv (Not doing code reviews)
2014/04/23 17:03:32
Please add a global var for this too.
Inactive
2014/04/23 19:19:29
Done.
|
| + 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", "1"); |
| + shouldBeFalse("details.open"); |
| + finishJSTest(); |
| +} |
| + |
| +function testEventsCoalesced() { |
| + toggleEventCount = 0; |
|
arv (Not doing code reviews)
2014/04/23 17:03:32
I think this might read clearer if this was not re
Inactive
2014/04/23 19:19:29
Done.
|
| + // 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); |
| +} |
| + |
| +details = document.getElementById("details"); |
|
arv (Not doing code reviews)
2014/04/23 17:03:32
missing var
Inactive
2014/04/23 19:19:29
Done.
|
| +details.addEventListener("toggle", handleToggleEvent); |
| +shouldBeFalse("details.open"); |
| +testToogleEventFired(); |
| +</script> |
| +</body> |
| +</html> |