2011-06-24 Andrey Kosyakov <caseq@chromium.org>
[WebKit-https.git] / LayoutTests / inspector / extensions / extensions.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/extensions-test.js"></script>
5 <script type="text/javascript">
6
7 function initialize_extensionsUITest()
8 {
9     InspectorTest.dumpSidebarContent = function(callback)
10     {
11         var sidebarPanes = WebInspector.panels.elements.sidebarPanes;
12         // the sidebar of interest is presumed to always be last.
13         var sidebar = sidebarPanes[Object.keys(sidebarPanes).pop()];
14         InspectorTest.runAfterPendingDispatches(function() {
15             InspectorTest.addResult("Sidebar content: " + sidebar.bodyElement.textContent);
16             callback();
17         });
18     }
19 }
20
21 function extension_testCreatePanel(nextTest)
22 {
23     function onPanelCreated(panel)
24     {
25         output("Panel created");
26         dumpObject(panel);
27     }
28     webInspector.panels.create("Test Panel", "extension-panel.png", "extension-panel.html", callbackAndNextTest(onPanelCreated, nextTest));
29     output("done createPanel");
30 }
31
32 function extension_testSidebarPage(nextTest)
33 {
34     function onSidebarCreated(sidebar)
35     {
36         output("Sidebar created");
37         dumpObject(sidebar);
38         sidebar.onUpdated.addListener(nextTest);
39         sidebar.setPage("extension-sidebar.html");
40     }
41     webInspector.panels.elements.createSidebarPane("Test Sidebar", onSidebarCreated);
42 }
43
44 function extension_dumpSidebarContent(nextTest)
45 {
46     evaluateOnFrontend("InspectorTest.dumpSidebarContent(reply);", nextTest);
47 }
48
49 function extension_testSidebarWatchObject(nextTest)
50 {
51     function onSidebarCreated(sidebar)
52     {
53         output("Watch sidebar created, callback arguments dump follows:");
54         dumpObject(Array.prototype.slice.call(arguments));
55         sidebar.onUpdated.addListener(bind(extension_dumpSidebarContent, this, nextTest));
56         sidebar.setObject({
57             f0: "object",
58             f1: undefined,
59             f2: null,
60             f3: {},
61             f4: [],
62             f5: ["aa", "bb", "cc"],
63             f6: { f60: 42, f61: "foo", f62: [] },
64             f7: 42
65         });
66     }
67     webInspector.panels.elements.createSidebarPane("Watch Test: Object", onSidebarCreated);
68 }
69
70 function extension_testSidebarWatchExpression(nextTest)
71 {
72     function onSidebarCreated(sidebar)
73     {
74         sidebar.onUpdated.addListener(bind(extension_dumpSidebarContent, this, nextTest));
75         function expression()
76         {
77             document.body.testProperty = 'foo';
78             return {
79                 f0: 'expression',
80                 f1: undefined,
81                 f2: null,
82                 f3: {},
83                 f4: [],
84                 f5: ["aa", "bb", "cc"],
85                 f6: { f60: 42, f61: "foo", f62: [] },
86                 f7: 42,
87                 f8: window.location,
88                 f9: document.body.children,
89                 f10: function() {},
90                 f11: $0.testProperty
91             };
92         }
93         // Do an extra round-trip to the inspected page to assure inspect()'s round-trip to
94         // front-end is complete and $0 is properly updated with currently inspected node.
95         webInspector.inspectedWindow.eval("", function() {
96             sidebar.setExpression("(" + expression.toString() + ")();", "title");
97         });
98     }
99     webInspector.inspectedWindow.eval("inspect(document.body)", function() {
100         webInspector.panels.elements.createSidebarPane("Watch Test: Expression", onSidebarCreated);
101     });
102 }
103
104 </script>
105 </head>
106 <body onload="runTest()">
107 <p>Tests WebInspector extension API</p>
108 </body>
109 </html>