Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / frames / sandboxed-iframe-autofocus-denied.html
blob282b6057b481c1c2a17c3976f8264d2d2706d1f5
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script>
5 function fail()
7 console.log("FAIL: The input element is focused.");
10 function finishTest()
12 var activeTag = document.querySelector('iframe').contentDocument.activeElement.tagName;
13 if (activeTag == "INPUT")
14 console.log("FAIL: The input element is focused.");
15 else
16 console.log("PASS: The input element is not focused.");
17 if (window.testRunner)
18 testRunner.notifyDone();
21 function runTest()
23 if (window.testRunner) {
24 testRunner.dumpAsText();
25 testRunner.waitUntilDone();
27 var frameDocument = document.querySelector('iframe').contentDocument;
28 var autofocusInput = frameDocument.createElement('input');
29 autofocusInput.autofocus = true;
30 autofocusInput.onfocus = fail;
31 frameDocument.body.appendChild(autofocusInput);
32 frameDocument.body.offsetTop;
33 window.setTimeout(finishTest, 0);
35 </script>
36 </head>
37 <body onload="runTest()">
38 <p>This test passes if the input element in the sandboxed frame is not
39 automatically focused upon, as it should be blocked by the sandboxed
40 scripts flag. A console warning to that effect should also be present.</p>
41 <iframe sandbox="allow-same-origin"></iframe>
42 </body>
43 </html>