3 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
4 <script src="../fast/js/resources/js-test-pre.js"></script>
10 <iframe id="iframe" title="InnerFrame"></iframe>
16 <p id="description"></p>
17 <div id="console"></div>
20 description("This tests that when an iframe finishes loading, it sends a notification.");
22 if (window.testRunner)
23 testRunner.waitUntilDone();
25 window.jsTestIsAsync = true;
27 // Recursively search the entire accessibility tree starting at the given
28 // AccessibilityUIElement (inclusive) and return the element whose title
29 // contains the given string. This makes it possible to find a node even
30 // when there are platform differences in the tree, i.e. due to different
31 // nodes being ignored.
32 function findByAccessibleTitleSubstring(startElement, titleSubstring)
34 if (startElement.title.indexOf(titleSubstring) >= 0)
37 for (var i = 0; i < startElement.childrenCount; i++) {
38 var found = findByAccessibleTitleSubstring(startElement.childAtIndex(i), titleSubstring);
48 window.gotIframeNotification = false;
50 if (window.accessibilityController) {
51 window.root = accessibilityController.rootElement;
53 // Initially, the iframe should not be loaded, so we shouldn't be able to find this button.
54 shouldBeFalse("findByAccessibleTitleSubstring(root, 'InnerButton') != null");
56 window.accessibilityController.addNotificationListener(function (target, notification) {
57 // Ignore this notification if it's not on the iframe.
58 if (target.description.indexOf("InnerFrame") == -1)
61 debug("Got notification on iframe.");
62 gotIframeNotification = true;
64 // Check that the button within the iframe is now reachable from the root.
65 shouldBeTrue("findByAccessibleTitleSubstring(root, 'InnerButton') != null");
69 window.iframeElement = document.getElementById("iframe");
70 iframeElement.addEventListener("load", function() {
71 window.setTimeout(function() {
72 shouldBeTrue("gotIframeNotification");
73 if (window.accessibilityController)
74 accessibilityController.removeNotificationListener();
80 // Load content into the iframe. This will trigger the event
81 // handler above, which will check that the accessibility tree
82 // was updated with new content.
83 window.iframeElement.src = "data:text/html,<body><button>InnerButton</button></body>";
86 window.addEventListener('load', function() {
87 setTimeout(runTest, 10);
92 <script src="../fast/js/resources/js-test-post.js"></script>