Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / accessibility / loading-iframe-sends-notification.html
blob5dec56bc1028b939159eb22fd7c60bf49e921604
1 <html>
2 <head>
3 <script src="../resources/js-test.js"></script>
4 </head>
5 <body>
7 <p>Before</p>
9 <iframe id="iframe" title="InnerFrame"></iframe>
11 <p>After</p>
13 <p>End of test</p>
15 <p id="description"></p>
16 <div id="console"></div>
18 <script>
19 description("This tests that when an iframe finishes loading, it sends a notification.");
21 if (window.testRunner)
22 testRunner.waitUntilDone();
23 else
24 debug("This test requires window.accessibilityController and must be run in content_shell with --run-layout-test.")
26 window.jsTestIsAsync = true;
28 function runTest()
30 if (window.accessibilityController) {
31 // Initially, the iframe should not be loaded, so we shouldn't be able to find this button.
32 shouldBeUndefined("accessibilityController.accessibleElementById('innerbutton')");
34 window.accessibilityController.addNotificationListener(function (target, notification) {
35 if (!target.parentElement() || !target.parentElement().parentElement())
36 return;
38 // Ignore this notification if it's not within the subtree of the iframe.
39 var frameTarget = target.parentElement().parentElement();
40 if (frameTarget.deprecatedDescription.indexOf("InnerFrame") == -1)
41 return;
43 // Even still we'll get LayoutComplete notifications sooner than we want.
44 if (!accessibilityController.accessibleElementById('innerbutton'))
45 return;
47 // Check that the button within the iframe is now reachable from the root.
48 shouldBeDefined("accessibilityController.accessibleElementById('innerbutton')");
49 if (window.accessibilityController)
50 accessibilityController.removeNotificationListener();
52 finishJSTest();
53 });
56 // Load content into the iframe. This will trigger the event
57 // handler above, which will check that the accessibility tree
58 // was updated with new content.
59 document.getElementById("iframe").src = "data:text/html,<body><button id='innerbutton'>InnerButton</button></body>";
61 window.addEventListener('load', runTest);
62 </script>
64 </body>
65 </html>