Skip to content

Commit

Permalink
WebKit export: Set <details> ToggleEvent oldState correctly for coale…
Browse files Browse the repository at this point in the history
  • Loading branch information
sideshowbarker authored and pull[bot] committed Sep 21, 2023
1 parent 35dddce commit 1410200
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@
</details>
<script>
var t1 = async_test("Adding open to 'details' should fire a toggle event at the 'details' element, with 'oldState: closed' and 'newState: open'"),
t2 = async_test("Removing open from 'details' should fire a toggle event at the 'details' element, with 'oldState: open' and 'newState: closed'"),
t2 = async_test("Adding open to 'details' and then removing open from that 'details' should fire only one toggle event at the 'details' element, with 'oldState: closed' and 'newState: closed'"),
t3 = async_test("Adding open to 'details' (display:none) should fire a toggle event at the 'details' element, with 'oldState: closed' and 'newState: open'"),
t4 = async_test("Adding open to 'details' (no children) should fire a toggle event at the 'details' element, with 'oldState: closed' and 'newState: open'"),
t6 = async_test("Calling open twice on 'details' fires only one toggle event, with 'oldState: closed' and 'newState: open'"),
t7 = async_test("Calling setAttribute('open', '') from 'details' should fire a toggle event at the 'details' element, with 'oldState: closed' and 'newState: open'"),
t8 = async_test("Calling removeAttribute('open') from 'details' should fire a toggle event at the 'details' element, with 'oldState: open' and 'newState: closed'"),
t9 = async_test("Setting open=true to opened 'details' element should not fire a toggle event at the 'details' element"),
t10 = async_test("Setting open=false to closed 'details' element should not fire a toggle event at the 'details' element"),
t6 = async_test("Adding open to 'details' and then removing open from that 'details' and then again adding open to that 'details' should fire only one toggle event at the 'details' element, with 'oldState: closed' and 'newState: closed'"),
t7 = async_test("Adding open to 'details' using setAttribute('open', '') should fire a toggle event at the 'details' element, with 'oldState: closed' and 'newState: open'"),
t8 = async_test("Adding open to 'details' and then calling removeAttribute('open') should fire only one toggle event at the 'details' element, with 'oldState: closed' and 'newState: closed'"),
t9 = async_test("Setting open=true on an opened 'details' element should not fire a toggle event at the 'details' element"),
t10 = async_test("Setting open=false on a closed 'details' element should not fire a toggle event at the 'details' element"),

details1 = document.getElementById('details1'),
details2 = document.getElementById('details2'),
Expand All @@ -76,21 +76,23 @@

details1.ontoggle = t1.step_func_done(function(evt) {
assert_equals(evt.oldState, "closed");
assert_equals(evt.newState, "open");+
assert_equals(evt.newState, "open");
assert_true(details1.open);
testEvent(evt)
});
details1.open = true; // opens details1

details2.ontoggle = t2.step_func_done(function(evt) {
assert_equals(evt.oldState, "closed");
assert_equals(evt.newState, "closed");
assert_false(details2.open);
testEvent(evt);
});
details2.open = false; // closes details2

details3.ontoggle = t3.step_func_done(function(evt) {
assert_equals(evt.oldState, "closed");
assert_equals(evt.newState, "open");+
assert_equals(evt.newState, "open");
assert_true(details3.open);
testEvent(evt);
});
Expand All @@ -107,6 +109,8 @@
async_test(function(t) {
var details5 = document.createElement("details");
details5.ontoggle = t.step_func_done(function(evt) {
assert_equals(evt.oldState, "closed");
assert_equals(evt.newState, "open");
assert_true(details5.open);
testEvent(evt);
})
Expand All @@ -119,6 +123,8 @@
if (loop) {
assert_unreached("toggle event fired twice");
} else {
assert_equals(evt.oldState, "closed");
assert_equals(evt.newState, "closed");
loop = true;
}
});
Expand All @@ -136,6 +142,8 @@
details7.setAttribute('open', ''); // opens details7

details8.ontoggle = t8.step_func_done(function(evt) {
assert_equals(evt.oldState, "closed");
assert_equals(evt.newState, "closed");
assert_false(details8.open);
testEvent(evt)
});
Expand Down

0 comments on commit 1410200

Please sign in to comment.