Introduce IDL files for runtime-enabled UndoManager and UndoItem JavaScript API
[WebKit-https.git] / LayoutTests / editing / undo-manager / undo-manager-interfaces.html
1 <!DOCTYPE html> <!-- webkit-test-runner [ enableUndoManagerAPI=true ] -->
2 <html>
3     <head>
4         <script src="../../resources/js-test.js"></script>
5     </head>
6     <script>
7         function emptyFunction() { }
8
9         function runTest()
10         {
11             description("Verifies that, when the UndoManager API is enabled, UndoManager and UndoItem interfaces behave as expected.");
12
13             debug("\nTesting UndoManager:");
14             shouldBeTrue("UndoManager instanceof Function");
15             shouldBeEqualToString("typeof UndoManager", "function");
16             shouldBeTrue("document.undoManager instanceof UndoManager");
17             shouldBeTrue("Object.getPrototypeOf(document.undoManager) === UndoManager.prototype");
18             shouldBeTrue("UndoManager.prototype.addItem instanceof Function");
19             shouldThrow("UndoManager()");
20             shouldThrow("new UndoManager()");
21             shouldThrow("document.undoManager.addItem()");
22             shouldThrow("document.undoManager.addItem('foo')");
23             shouldBeEqualToString("UndoManager.toString()", "function UndoManager() {\n    [native code]\n}");
24             shouldBeEqualToString("document.undoManager.toString()", "[object UndoManager]");
25
26             debug("\nTesting UndoItem:");
27             shouldBeTrue("UndoItem instanceof Function");
28             shouldBeEqualToString("typeof UndoItem", "function");
29             shouldThrow("UndoItem()");
30             shouldThrow("new UndoItem()");
31             shouldThrow("new UndoItem('foo')");
32             shouldThrow("new UndoItem({ })");
33             shouldThrow("new UndoItem({ label: null, undo: null })");
34             shouldThrow("new UndoItem({ redo: null })");
35             shouldThrow("new UndoItem({ label: '', undo: emptyFunction })");
36             shouldThrow("new UndoItem({ label: 'hello', redo: emptyFunction })");
37             shouldThrow("new UndoItem({ label: 3, undo: null, redo: null })");
38             shouldThrow("new UndoItem({ label: '', undo: '', redo: emptyFunction })");
39             shouldThrow("new UndoItem({ label: '', undo: emptyFunction, redo: 10 })");
40             shouldBeTrue("new UndoItem({ label: '', undo: emptyFunction, redo: emptyFunction, foo: 'hi' }) instanceof UndoItem");
41             shouldBeTrue("Object.getPrototypeOf(new UndoItem({ label: '', undo: emptyFunction, redo: emptyFunction })) === UndoItem.prototype");
42             shouldBeEqualToString("new UndoItem({ label: 'foo', undo: emptyFunction, redo: emptyFunction }).label", "foo");
43             shouldBeEqualToString("UndoItem.toString()", "function UndoItem() {\n    [native code]\n}");
44             shouldBeEqualToString("new UndoItem({ label: '', undo: emptyFunction, redo: emptyFunction }).toString()", "[object UndoItem]");
45             shouldNotThrow("document.undoManager.addItem(new UndoItem({ label: '', undo: emptyFunction, redo: emptyFunction }))");
46         }
47     </script>
48     <body onload=runTest()></body>
49 </html>