Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../resources/js-test.js"></script> | 3 <script src="../resources/js-test.js"></script> |
| 4 </head> | 4 </head> |
| 5 <body> | 5 <body> |
| 6 | 6 |
| 7 <p>Before</p> | 7 <p>Before</p> |
| 8 | 8 |
| 9 <iframe id="iframe" title="InnerFrame"></iframe> | 9 <iframe id="iframe" title="InnerFrame"></iframe> |
| 10 | 10 |
| 11 <p>After</p> | 11 <p>After</p> |
| 12 | 12 |
| 13 <p>End of test</p> | 13 <p>End of test</p> |
| 14 | 14 |
| 15 <p id="description"></p> | 15 <p id="description"></p> |
| 16 <div id="console"></div> | 16 <div id="console"></div> |
| 17 | 17 |
| 18 <script> | 18 <script> |
| 19 description("This tests that when an iframe finishes loading, it sends a not ification."); | 19 description("This tests that when an iframe finishes loading, it sends a not ification."); |
| 20 | 20 |
| 21 if (window.testRunner) | 21 if (window.testRunner) |
| 22 testRunner.waitUntilDone(); | 22 testRunner.waitUntilDone(); |
| 23 else | |
| 24 debug("This test requires window.accessibilityController and must be run in content_shell with --dump-render-tree.") | |
| 23 | 25 |
| 24 window.jsTestIsAsync = true; | 26 window.jsTestIsAsync = true; |
| 25 | 27 |
| 26 function runTest() | 28 function runTest() |
| 27 { | 29 { |
| 28 window.gotIframeNotification = false; | |
| 29 | |
| 30 if (window.accessibilityController) { | 30 if (window.accessibilityController) { |
| 31 // Initially, the iframe should not be loaded, so we shouldn't be ab le to find this button. | 31 // Initially, the iframe should not be loaded, so we shouldn't be ab le to find this button. |
| 32 shouldBeFalse("accessibilityController.accessibleElementById('innerb utton') != null"); | 32 shouldBeUndefined("accessibilityController.accessibleElementById('in nerbutton')"); |
| 33 | 33 |
| 34 window.accessibilityController.addNotificationListener(function (tar get, notification) { | 34 window.accessibilityController.addNotificationListener(function (tar get, notification) { |
| 35 // Ignore this notification if it's not on the iframe. | 35 if (!target.parentElement() || !target.parentElement().parentEle ment()) |
| 36 if (target.description.indexOf("InnerFrame") == -1) | |
| 37 return; | 36 return; |
| 38 | 37 |
| 39 debug("Got notification on iframe."); | 38 var frameTarget = target.parentElement().parentElement(); |
| 40 gotIframeNotification = true; | 39 // Ignore this notification if it's not on the iframe. |
|
dmazzoni
2014/04/22 20:41:24
This should probably say: "Ignore this notificatio
| |
| 40 if (frameTarget.description.indexOf("InnerFrame") == -1) | |
| 41 return; | |
| 42 debug("Got notification: " + notification + " on grand child of InnerFrame."); | |
| 41 | 43 |
| 42 // Check that the button within the iframe is now reachable from the root. | 44 // Check that the button within the iframe is now reachable from the root. |
| 43 shouldBeTrue("accessibilityController.accessibleElementById('inn erbutton') != null"); | 45 shouldNotBe("accessibilityController.accessibleElementById('inne rbutton')", "null"); |
|
dmazzoni
2014/04/22 20:41:24
I guess it should not be undefined, but in the wor
| |
| 44 }); | |
| 45 } | |
| 46 | |
| 47 window.iframeElement = document.getElementById("iframe"); | |
| 48 iframeElement.addEventListener("load", function() { | |
| 49 window.setTimeout(function() { | |
| 50 shouldBeTrue("gotIframeNotification"); | |
| 51 if (window.accessibilityController) | 46 if (window.accessibilityController) |
| 52 accessibilityController.removeNotificationListener(); | 47 accessibilityController.removeNotificationListener(); |
| 53 | 48 |
| 54 finishJSTest(); | 49 finishJSTest(); |
| 55 }, 10); | 50 }); |
| 56 }, false); | 51 } |
| 57 | 52 |
| 58 // Load content into the iframe. This will trigger the event | 53 // Load content into the iframe. This will trigger the event |
| 59 // handler above, which will check that the accessibility tree | 54 // handler above, which will check that the accessibility tree |
| 60 // was updated with new content. | 55 // was updated with new content. |
| 61 window.iframeElement.src = "data:text/html,<body><button id='innerbutton '>InnerButton</button></body>"; | 56 document.getElementById("iframe").src = "data:text/html,<body><button id ='innerbutton'>InnerButton</button></body>"; |
| 62 } | 57 } |
| 63 | 58 window.addEventListener('load', runTest); |
| 64 window.addEventListener('load', function() { | |
| 65 setTimeout(runTest, 10); | |
| 66 }, false); | |
| 67 | |
| 68 </script> | 59 </script> |
| 69 | 60 |
| 70 </body> | 61 </body> |
| 71 </html> | 62 </html> |
| OLD | NEW |