Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <link rel="help" href="http://www.whatwg.org/specs/web-apps/current-work/multipa ge/interactive-elements.html#attr-details-open"> | |
| 5 <script src="../../resources/js-test.js"></script> | |
| 6 </head> | |
| 7 <body> | |
| 8 <details id="details"> | |
| 9 <summary>details</summary> | |
| 10 <input> | |
| 11 </details> | |
| 12 <script> | |
| 13 description("Tests that a 'toggle' event is fired asynchronously whenever the op en attribute is added to or removed from a details element."); | |
| 14 window.jsTestIsAsync = true; | |
| 15 | |
| 16 var toggleEventCount = 0; | |
| 17 | |
| 18 function handleToggleEvent(ev) { | |
| 19 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.
| |
| 20 shouldBe("testEvent.__proto__", "Event.prototype"); | |
| 21 shouldBeEqualToString("testEvent.type", "toggle"); | |
| 22 ++toggleEventCount; | |
| 23 } | |
| 24 | |
| 25 function checkSingleToggleEvent() { | |
| 26 shouldBe("toggleEventCount", "1"); | |
| 27 shouldBeTrue("details.open"); | |
| 28 testEventsCoalesced(); | |
| 29 } | |
| 30 | |
| 31 function testToogleEventFired() { | |
| 32 shouldBe("toggleEventCount", "0"); | |
| 33 details.open = true; | |
| 34 shouldBe("toggleEventCount", "0"); | |
| 35 setTimeout(checkSingleToggleEvent, 0); | |
| 36 } | |
| 37 | |
| 38 function checkEventsCoalesced() { | |
| 39 shouldBe("toggleEventCount", "1"); | |
| 40 shouldBeFalse("details.open"); | |
| 41 finishJSTest(); | |
| 42 } | |
| 43 | |
| 44 function testEventsCoalesced() { | |
| 45 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.
| |
| 46 // When the open attribute is toggled several times in succession, | |
| 47 // these steps essentially get coalesced so that only one event is | |
| 48 // fired. | |
| 49 details.open = false; | |
| 50 details.open = true; | |
| 51 details.open = false; | |
| 52 setTimeout(checkEventsCoalesced, 0); | |
| 53 } | |
| 54 | |
| 55 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.
| |
| 56 details.addEventListener("toggle", handleToggleEvent); | |
| 57 shouldBeFalse("details.open"); | |
| 58 testToogleEventFired(); | |
| 59 </script> | |
| 60 </body> | |
| 61 </html> | |
| OLD | NEW |