-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix the typo issues - Resolve issues 1. The assertion of cancelable attribute. 2. The assertion of assertion descriptions. 3. The event handle pattern and etc. - Update the last assertion of the show event test - Resolve issues 1. Remove the trailing ws 2. Move evt.preventDefault() into the test 3. Add a test to check the button type, and put the click() method into it. 4. Remove the reset-form.html, etc - Fix a typo issue in the assertion description - Use t.step to check the button type - Update the event registeration method as review sugguestion Signed-off-by: xiaojunwu <xiaojunx.a.wu@intel.com>
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
html/semantics/forms/the-button-element/button-events.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML Test: Button - events</title> | ||
<link rel="author" title="Intel" href="http://www.intel.com/"> | ||
<link rel="help" href="http://www.w3.org/TR/html51/forms.html#the-button-element"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<form name="fm1" style="display:none"> | ||
<button id="btn">BUTTON</button> | ||
<button id="menu_btn" type="menu" menu="menu">MENU BUTTON</button> | ||
<menu id="menu" label="MENU"> | ||
<li>Menu item</li> | ||
</menu> | ||
</form> | ||
<script> | ||
|
||
var btn = document.getElementById("btn"), | ||
menu_btn = document.getElementById("menu_btn"), | ||
t1 = async_test("The submit event must be fired when click a button in submit status"), | ||
t2 = async_test("The reset event must be fired when click a button in reset status"), | ||
t3 = async_test("The show event must be fired when click a button in menu status"); | ||
|
||
document.forms.fm1.onsubmit = t1.step_func(function (evt) { | ||
evt.preventDefault(); | ||
assert_true(evt.isTrusted, "The isTrusted attribute of the submit event shoud be true."); | ||
assert_true(evt.bubbles, "The bubbles attribute of the submit event shoud be true."); | ||
assert_true(evt.cancelable, "The cancelable attribute of the submit event shoud be true."); | ||
assert_true(evt instanceof Event, "The submit event is an instance of Event interface."); | ||
t1.done(); | ||
}); | ||
|
||
document.forms.fm1.onreset = t2.step_func(function (evt) { | ||
assert_true(evt.isTrusted, "The isTrusted attribute of the reset event shoud be true."); | ||
assert_true(evt.bubbles, "The bubbles attribute of the reset event shoud be true."); | ||
assert_true(evt.cancelable, "The cancelable attribute of the reset event shoud be true."); | ||
assert_true(evt instanceof Event, "The reset event is an instance of Event interface."); | ||
t2.done(); | ||
}); | ||
|
||
document.getElementById("menu").onshow = t3.step_func(function (evt) { | ||
assert_true(evt.isTrusted, "The isTrusted attribute of the show event shoud be true."); | ||
assert_equals(evt.relatedTarget, menu_btn, "The relatedTarget attribute should be initialized to the related button element."); | ||
assert_true(evt.cancelable, "The cancelable attribute of the show event shoud be true."); | ||
assert_true(evt instanceof RelatedEvent, "The show event is an instance of RelatedEvent interface."); | ||
t3.done(); | ||
}); | ||
|
||
t1.step(function () { | ||
btn.type = "submit"; | ||
assert_equals(btn.type, "submit", "The button type should be 'submit'."); | ||
btn.click(); | ||
}); | ||
|
||
t2.step(function () { | ||
btn.type = "reset"; | ||
assert_equals(btn.type, "reset", "The button type should be 'reset'."); | ||
btn.click(); | ||
}); | ||
|
||
t3.step(function () { | ||
assert_equals(menu_btn.type, "menu", "The button type should be 'menu'."); | ||
menu_btn.click(); | ||
}); | ||
|
||
</script> |