| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="../../http/tests/inspector/extensions-test.js"></script> |
| <script type="text/javascript"> |
| |
| function extension_testCreatePanel(nextTest) |
| { |
| function onPanelCreated(panel) |
| { |
| output("Panel created"); |
| dumpObject(panel); |
| } |
| webInspector.panels.create("Test Panel", "extension-panel.png", "extension-panel.html", callbackAndNextTest(onPanelCreated, nextTest)); |
| output("done createPanel"); |
| } |
| |
| function extension_testSidebarPage(nextTest) |
| { |
| function onSidebarCreated(sidebar) |
| { |
| output("Sidebar created"); |
| dumpObject(sidebar); |
| sidebar.onUpdated.addListener(nextTest); |
| sidebar.setPage("extension-sidebar.html"); |
| } |
| webInspector.panels.elements.createSidebarPane("Test Sidebar", onSidebarCreated); |
| } |
| |
| function extension_dumpSidebarContent(nextTest) |
| { |
| dispatchOnFrontend({ command: "dump-sidebar-content" }, nextTest); |
| } |
| |
| function extension_testSidebarWatchObject(nextTest) |
| { |
| function onSidebarCreated(sidebar) |
| { |
| output("Watch sidebar created, callback arguments dump follows:"); |
| dumpObject(Array.prototype.slice.call(arguments)); |
| sidebar.onUpdated.addListener(bind(extension_dumpSidebarContent, this, nextTest)); |
| sidebar.setObject({ |
| f0: "object", |
| f1: undefined, |
| f2: null, |
| f3: {}, |
| f4: [], |
| f5: ["aa", "bb", "cc"], |
| f6: { f60: 42, f61: "foo", f62: [] }, |
| f7: 42 |
| }); |
| } |
| webInspector.panels.elements.createSidebarPane("Watch Test: Object", onSidebarCreated); |
| } |
| |
| function extension_testSidebarWatchExpression(nextTest) |
| { |
| function onSidebarCreated(sidebar) |
| { |
| sidebar.onUpdated.addListener(bind(extension_dumpSidebarContent, this, nextTest)); |
| function expression() |
| { |
| document.body.testProperty = 'foo'; |
| return { |
| f0: 'expression', |
| f1: undefined, |
| f2: null, |
| f3: {}, |
| f4: [], |
| f5: ["aa", "bb", "cc"], |
| f6: { f60: 42, f61: "foo", f62: [] }, |
| f7: 42, |
| f8: window.location, |
| f9: document.body.children, |
| f10: function() {}, |
| f11: $0.testProperty |
| }; |
| } |
| // Do an extra round-trip to the inspected page to assure inspect()'s round-trip to |
| // front-end is complete and $0 is properly updated with currently inspected node. |
| webInspector.inspectedWindow.eval("", function() { |
| sidebar.setExpression("(" + expression.toString() + ")();", "title"); |
| }); |
| } |
| webInspector.inspectedWindow.eval("inspect(document.body)", function() { |
| webInspector.panels.elements.createSidebarPane("Watch Test: Expression", onSidebarCreated); |
| }); |
| } |
| |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>Tests WebInspector extension API</p> |
| </body> |
| </html> |