Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Oct 20, 2016
1 parent 6386c5b commit 120a9b9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dom/events/Event-dispatch-click.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@
<div id=dump style=display:none></div>
<script>
var dump = document.getElementById("dump")

async_test((t) => {
var input = document.createElement("input")
input.type = "checkbox"
dump.appendChild(input)
input.onclick = t.step_func_done(() => assert_true(input.checked))
input.click()
}, "basic with click()")

async_test((t) => {
var input = document.createElement("input")
input.type = "checkbox"
dump.appendChild(input)
input.onclick = t.step_func_done(() => assert_true(input.checked))
input.dispatchEvent(new MouseEvent("click", {bubbles:true})) // equivalent to the above
}, "basic with dispatchEvent()")

async_test((t) => {
var input = document.createElement("input")
input.type = "checkbox"
dump.appendChild(input)
input.onclick = t.step_func_done(() => assert_false(input.checked))
input.dispatchEvent(new Event("click", {bubbles:true})) // no MouseEvent
}, "basic with wrong event class")

async_test((t) => {
var input = document.createElement("input")
input.type = "checkbox"
Expand All @@ -35,7 +39,8 @@
child.dispatchEvent(new MouseEvent("click")) // does not bubble
assert_false(input.checked)
t.done()
}, "only look at parents when event bubbles")
}, "look at parents only when event bubbles")

async_test((t) => {
var input = document.createElement("input")
input.type = "checkbox"
Expand All @@ -44,6 +49,7 @@
var child = input.appendChild(new Text("does not matter"))
child.dispatchEvent(new MouseEvent("click", {bubbles:true}))
}, "look at parents when event bubbles")

async_test((t) => {
var input = document.createElement("input")
input.type = "checkbox"
Expand All @@ -55,6 +61,7 @@
child.dispatchEvent(new MouseEvent("click", {bubbles:true}))
t.done()
}, "pick the first with activation behavior <input type=checkbox>")

var globalCounter = 0 // sorry
async_test((t) => { // as above with <a>
var i = 0
Expand All @@ -67,6 +74,7 @@
assert_equals(globalCounter, 1)
t.done()
}, "pick the first with activation behavior <a href>")

async_test((t) => {
var input = document.createElement("input")
input.type = "checkbox"
Expand All @@ -81,6 +89,7 @@
})
input.dispatchEvent(clickEvent)
}, "event state during post-click handling")

async_test((t) => {
var input = document.createElement("input")
input.type = "checkbox"
Expand Down

0 comments on commit 120a9b9

Please sign in to comment.