Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / text / text-window-lost-focus-change-event.html
blob28c7829ccc981d96476613c41fadfb3e059ef96d
1 <html>
2 <head>
3 <script src = "../../../resources/js-test.js"> </script>
4 </head>
5 <body onload="runTest()">
6 <input type="text" id="text"/>
7 <script>
9 var blurEventCounter = 0;
10 var changeEventCounter = 0;
12 function runTest() {
13 description('Test when window out of focus, should dispatch both blur and change event');
14 var text = document.getElementById('text');
15 text.addEventListener('change', function() {
16 changeEventCounter++;
17 });
18 text.addEventListener('blur', function() {
19 blurEventCounter++;
20 shouldEvaluateTo('blurEventCounter', 1);
21 shouldEvaluateTo('changeEventCounter', 1);
22 finishJSTest();
23 });
24 text.focus();
25 document.execCommand('InsertText', false, 'hello world');
26 shouldEvaluateTo('blurEventCounter', 0);
27 shouldEvaluateTo('changeEventCounter', 0);
28 window.testRunner.setMainFrameIsFirstResponder(true);
29 window.testRunner.setWindowIsKey(false);
31 if (window.testRunner)
32 window.jsTestIsAsync = true;
33 </script>
34 </body>
35 </html>