| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../resources/accessibility-helper.js"></script> |
| <script src="../resources/js-test.js"></script> |
| </head> |
| <body> |
| |
| <div id="grid" role="grid"> |
| <div role="row"> |
| <div role="columnheader">header 1</div> |
| <div role="columnheader">header 2</div> |
| </div> |
| <div role="row"> |
| <div role="gridcell">cell</div> |
| <div role="gridcell">cell</div> |
| </div> |
| </div> |
| |
| <script> |
| var testOutput = "This test ensures that we don't crash when processing attribute changes after a deferred role attribute change.\n\n"; |
| |
| if (window.accessibilityController) { |
| window.jsTestIsAsync = true; |
| |
| const axGrid = accessibilityController.accessibleElementById("grid"); |
| const initialRole = axGrid.role; |
| testOutput += `#grid element's initial role: ${initialRole}\n`; |
| |
| testOutput += "Changing #grid's role attribute to 'presentation', and its class to 'foo'.\n"; |
| // Force dirty layout and style by moving this element and changing its color. This will cause |
| // AXObjectCache::rendererNeedsDeferredUpdate to be true for this element, deferring any |
| // subsequent attribute changes to be processed after a timer elapses. |
| document.getElementById("grid").setAttribute("style", "margin-left: 300px; background-color: red;"); |
| // Change the element's role such that we attempt to remove and re-create the object. |
| document.getElementById("grid").setAttribute("role", "presentation"); |
| // If we behave correctly, processing this 'class' attribute change should not cause a crash. |
| document.getElementById("grid").setAttribute("class", "foo"); |
| setTimeout(async function() { |
| await waitFor(() => axGrid.role !== initialRole); |
| testOutput += `#grid element's new role after DOM changes: ${axGrid.role}\n`; |
| testOutput += `\nNo crash, so test passed.\n`; |
| |
| debug(testOutput); |
| document.getElementById("grid").style.visibility = "hidden"; |
| finishJSTest(); |
| }, 0); |
| } |
| </script> |
| </body> |
| </html> |
| |