| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="UndoTests.js"></script> |
| <script> |
| |
| // Tests that the set of outline items present in a TOC is correctly updated during undo/redo. |
| // |
| // There was previously a bug caused by the fact that the the set of outline items in a TOC |
| // object was not maintained in an undo-compliant manner, and items were only added/removed when |
| // the action was taken directly by the user, and not as part of an undo or redo action. |
| // |
| // Now TOC_addOutlineItem() and TOC_removeOutlineItem() are called within addItemInternal() and |
| // removeItemInternal(), ensuring undo compliance. |
| |
| function performTest() |
| { |
| Outline_init(); |
| PostponedActions_perform(); |
| |
| UndoManager_newGroup(); |
| |
| var first = DOM_createElement(document,"H1"); |
| DOM_appendChild(first,DOM_createTextNode(document,"First section")); |
| DOM_appendChild(document.body,first); |
| |
| PostponedActions_perform(); |
| UndoManager_newGroup(); |
| |
| var firstOffset = DOM_nodeOffset(first); |
| Selection_set(first.parentNode,firstOffset,first.parentNode,firstOffset+1); |
| Selection_deleteContents(); |
| |
| PostponedActions_perform(); |
| UndoManager_newGroup(); |
| |
| UndoManager_undo(); |
| |
| var second = DOM_createElement(document,"H1"); |
| DOM_appendChild(second,DOM_createTextNode(document,"Second section")); |
| DOM_appendChild(document.body,second); |
| |
| PostponedActions_perform(); |
| } |
| </script> |
| </head> |
| <body> |
| <nav class="tableofcontents"></nav> |
| <h1>Test[]</h1> |
| </body> |
| </html> |