Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: LayoutTests/imported/web-platform-tests/html/semantics/forms/the-button-element/button-events.html

Issue 1144143009: W3C Test: Import web-platform-tests/html/semantics (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset="utf-8">
3 <title>HTML Test: Button - events</title>
4 <link rel="author" title="Intel" href="http://www.intel.com/">
5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-button-elemen t">
6 <script src="../../../../../../resources/testharness.js"></script>
7 <script src="../../../../../../resources/testharnessreport.js"></script>
8 <div id="log"></div>
9 <form name="fm1" style="display:none">
10 <button id="btn">BUTTON</button>
11 <button id="menu_btn" type="menu" menu="menu">MENU BUTTON</button>
12 <menu id="menu" label="MENU">
13 <li>Menu item</li>
14 </menu>
15 </form>
16 <script>
17
18 var btn = document.getElementById("btn"),
19 menu_btn = document.getElementById("menu_btn"),
20 t1 = async_test("The submit event must be fired when click a button in submi t status"),
21 t2 = async_test("The reset event must be fired when click a button in reset status"),
22 t3 = async_test("The show event must be fired when click a button in menu st atus");
23
24 document.forms.fm1.onsubmit = t1.step_func(function (evt) {
25 evt.preventDefault();
26 assert_true(evt.isTrusted, "The isTrusted attribute of the submit event shoud be true.");
27 assert_true(evt.bubbles, "The bubbles attribute of the submit event shoud be t rue.");
28 assert_true(evt.cancelable, "The cancelable attribute of the submit event shou d be true.");
29 assert_true(evt instanceof Event, "The submit event is an instance of Event in terface.");
30 t1.done();
31 });
32
33 document.forms.fm1.onreset = t2.step_func(function (evt) {
34 assert_true(evt.isTrusted, "The isTrusted attribute of the reset event shoud b e true.");
35 assert_true(evt.bubbles, "The bubbles attribute of the reset event shoud be tr ue.");
36 assert_true(evt.cancelable, "The cancelable attribute of the reset event shoud be true.");
37 assert_true(evt instanceof Event, "The reset event is an instance of Event int erface.");
38 t2.done();
39 });
40
41 document.getElementById("menu").onshow = t3.step_func(function (evt) {
42 assert_true(evt.isTrusted, "The isTrusted attribute of the show event shoud be true.");
43 assert_equals(evt.relatedTarget, menu_btn, "The relatedTarget attribute should be initialized to the related button element.");
44 assert_true(evt.cancelable, "The cancelable attribute of the show event shoud be true.");
45 assert_true(evt instanceof RelatedEvent, "The show event is an instance of Rel atedEvent interface.");
46 t3.done();
47 });
48
49 t1.step(function () {
50 btn.type = "submit";
51 assert_equals(btn.type, "submit", "The button type should be 'submit'.");
52 btn.click();
53 });
54
55 t2.step(function () {
56 btn.type = "reset";
57 assert_equals(btn.type, "reset", "The button type should be 'reset'.");
58 btn.click();
59 });
60
61 t3.step(function () {
62 assert_equals(menu_btn.type, "menu", "The button type should be 'menu'.");
63 menu_btn.click();
64 });
65
66 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698