1 description('Blurring and focusing the window should blur and focus the focused element');
3 var divElement = document.createElement('div');
4 divElement.tabIndex = 0;
5 divElement.textContent = 'Outer';
6 document.body.appendChild(divElement);
8 var iframeElement = document.createElement('iframe');
9 document.body.appendChild(iframeElement);
10 var iframe = window.frames[0];
11 var innerDiv = iframeElement.contentDocument.createElement('div');
12 innerDiv.textContent = 'Inner';
13 innerDiv.tabIndex = 0;
14 iframeElement.contentDocument.body.appendChild(innerDiv);
20 // Focus before setting up event listeners.
23 divElement.onfocus = divElement.onblur = window.onfocus = window.onblur =
24 innerDiv.onfocus = innerDiv.onblur = iframe.onfocus = iframe.onblur = function(e)
26 thisObjects.push(this);
28 targets.push(e.target);
31 if (window.testRunner) {
32 window.testRunner.setWindowIsKey(false);
33 window.testRunner.setWindowIsKey(true);
40 function testNextEvent(target, eventType)
42 shouldBe('thisObjects[' + i + ']', target);
43 shouldBeEqualToString('events[' + i + ']', eventType);
44 shouldBe('targets[' + i + ']', target);
48 testNextEvent('divElement', 'blur');
49 testNextEvent('window', 'blur');
50 testNextEvent('window', 'focus');
51 testNextEvent('divElement', 'focus');
53 testNextEvent('divElement', 'blur');
54 testNextEvent('window', 'blur');
55 testNextEvent('iframe', 'focus');
56 testNextEvent('innerDiv', 'focus');
58 testNextEvent('innerDiv', 'blur');
59 testNextEvent('iframe', 'blur');
60 testNextEvent('window', 'focus');
61 testNextEvent('divElement', 'focus');
63 document.body.removeChild(divElement);
64 document.body.removeChild(iframeElement);