blob: aa2dda65221fad95e2902b9b0de277ef0fee9f15 [file]
<!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 id="body" tabindex="0" role="group">
<iframe id="iframe" width=100 height=100></iframe>
<script>
description("This protects against a crash when a text marker still holds a reference to a node that's been deallocated.");
window.jsTestIsAsync = true;
// Add an element that a text marker can be retrieved from.
var contentDoc = document.getElementById("iframe").contentDocument;
contentDoc.body.innerHTML = "<h1 tabindex='0'>content</h1>";
// Tab to the element.
// Note: If the element has an "id" it won't get de-allocated in time, so .focus() can't be used.
eventSender.keyDown("\t");
// get a marker that will become invalid when the node disappears.
var axDiv = accessibilityController.focusedElement;
var textMarkerRange = axDiv.textMarkerRangeForElement(axDiv);
var invalidMarker = axDiv.startTextMarkerForTextMarkerRange(textMarkerRange);
</script>
<script>
// Write new content to cause all content to disappear.
contentDoc.body.innerHTML = "<h2>new content</h2>";
</script>
<script>
// Access the invalid marker (it should not crash).
setTimeout(async () => {
await waitForFocus("body");
accessibilityController.accessibleElementById("body").accessibilityElementForTextMarker(invalidMarker);
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>