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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/forms/color/input-color-onchange-event.html

Issue 2447653002: INPUT element: Do not dispatch events in detachLayoutTree(). (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../../resources/js-test.js"></script> 4 <script src="../../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <p id="description"></p> 7 <p id="description"></p>
8 <div id="console"></div> 8 <div id="console"></div>
9 <script> 9 <script>
10 description('Test if change event fires properly when color chooser changes. Bug 66848 <br> To manually test this, click on the input color element in the top l eft corner and change the value from the color chooser. See if the number of "va lue changed" messages matches the number of times you changed the color.'); 10 description('Test if change event fires properly when color chooser changes. Bug 66848 <br> To manually test this, click on the input color element in the top l eft corner and change the value from the color chooser. See if the number of "va lue changed" messages matches the number of times you changed the color.');
11 jsTestIsAsync = true;
11 12
12 var input = document.createElement('input'); 13 var input = document.createElement('input');
13 input.type = 'color'; 14 input.type = 'color';
14 input.value = '#000000'; 15 input.value = '#000000';
15 document.body.appendChild(input); 16 document.body.appendChild(input);
16 17
17 input.style.position = 'absolute'; 18 input.style.position = 'absolute';
18 input.style.left = '0'; 19 input.style.left = '0';
19 input.style.top = '0'; 20 input.style.top = '0';
20 input.style.width = '20px'; 21 input.style.width = '20px';
21 input.style.height = '20px'; 22 input.style.height = '20px';
22 23
23 var onChange = 0; 24 var onChange = 0;
24 25
25 input.onchange = function() {
26 debug("change event dispatched - value changed to " + input.value);
27 onChange++;
28 };
29
30 input.oninput = function() { 26 input.oninput = function() {
31 debug("input event dispatched - value is: " + input.value); 27 debug("input event dispatched - value is: " + input.value);
32 }; 28 };
33 29
34 eventSender.mouseMoveTo(10, 10); 30 eventSender.mouseMoveTo(10, 10);
35 eventSender.mouseDown(); 31 eventSender.mouseDown();
36 eventSender.mouseUp(); 32 eventSender.mouseUp();
37 33
38 // Test that incorrect element arguments are (not) handled. 34 // Test that incorrect element arguments are (not) handled.
39 shouldThrow("internals.selectColorInColorChooser({}, '#ff0000');"); 35 shouldThrow("internals.selectColorInColorChooser({}, '#ff0000');");
40 shouldThrow("internals.selectColorInColorChooser(document, '#ff0000');"); 36 shouldThrow("internals.selectColorInColorChooser(document, '#ff0000');");
41 37
42 // input.onchange should be called 38 function step1() {
43 internals.selectColorInColorChooser(input, '#ff0000'); 39 // input.onchange should be called
44 internals.endColorChooser(input); 40 input.onchange = step2;
45 // input.onchange should not be called 41 internals.selectColorInColorChooser(input, '#ff0000');
46 internals.selectColorInColorChooser(input, '#ff0000'); 42 internals.endColorChooser(input);
47 internals.endColorChooser(input); 43 shouldBe('input.value', '"#ff0000"');
48 shouldBe('input.value', '"#ff0000"'); 44 }
49 45
50 debug('Change event is only dispatched, when color chooser is closed'); 46 function step2() {
51 onChange = 0; 47 debug("change event dispatched - value changed to " + input.value);
52 internals.selectColorInColorChooser(input, '#ff0002'); 48 // input.onchange should not be called
53 shouldBe('onChange', '0'); 49 input.onchange = () => {
54 internals.endColorChooser(input); 50 testFailed("Change event should not be dispatched.");
55 shouldBe('onChange', '1'); 51 };
52 internals.selectColorInColorChooser(input, '#ff0000');
53 internals.endColorChooser(input);
54 shouldBe('input.value', '"#ff0000"');
55 step3();
56 }
56 57
58 function step3() {
59 debug('Change event is only dispatched, when color chooser is closed');
60 input.onchange = step4;
61 internals.selectColorInColorChooser(input, '#ff0002');
62 internals.endColorChooser(input);
63 }
64
65 function step4() {
66 testPassed('Change event was dispatched.');
67 finishJSTest();
68 }
69
70 step1();
57 </script> 71 </script>
58 </body> 72 </body>
59 </html> 73 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698