tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / inspector / extensions / extensions-sidebar.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_extensionsSidebarTest()
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_testSidebarSetPage(nextTest)
22 {
23     function onSidebarCreated(sidebar)
24     {
25         output("Sidebar created");
26         dumpObject(sidebar);
27         function onShown()
28         {
29             sidebar.onShown.removeListener(onShown);
30             nextTest();
31         }
32         sidebar.onShown.addListener(onShown);
33         var basePath = location.pathname.replace(/\/[^/]*$/, "/");
34         sidebar.setPage(basePath + "extension-sidebar.html");
35         extension_showPanel("elements");
36     }
37     webInspector.panels.elements.createSidebarPane("Test Sidebar", onSidebarCreated);
38 }
39
40 function extension_dumpSidebarContent(nextTest)
41 {
42     evaluateOnFrontend("InspectorTest.dumpSidebarContent(reply);", nextTest);
43 }
44
45 function extension_testSidebarSetObject(nextTest)
46 {
47     function onSidebarCreated(sidebar)
48     {
49         output("Watch sidebar created, callback arguments dump follows:");
50         dumpObject(Array.prototype.slice.call(arguments));
51         sidebar.setObject({
52             f0: "object",
53             f1: undefined,
54             f2: null,
55             f3: {},
56             f4: [],
57             f5: ["aa", "bb", "cc"],
58             f6: { f60: 42, f61: "foo", f62: [] },
59             f7: 42
60         }, null, extension_dumpSidebarContent.bind(this, nextTest));
61     }
62     webInspector.panels.elements.createSidebarPane("Watch Test: Object", onSidebarCreated);
63 }
64
65 function extension_testSidebarSetExpression(nextTest)
66 {
67     function onSidebarCreated(sidebar)
68     {
69         function expression()
70         {
71             document.body.testProperty = 'foo';
72             return {
73                 f0: 'expression',
74                 f1: undefined,
75                 f2: null,
76                 f3: {},
77                 f4: [],
78                 f5: ["aa", "bb", "cc"],
79                 f6: { f60: 42, f61: "foo", f62: [] },
80                 f7: 42,
81                 f8: window.location,
82                 f9: document.body.children,
83                 f10: function() {},
84                 f11: $0.testProperty
85             };
86         }
87         // Do an extra round-trip to the inspected page to assure inspect()'s round-trip to
88         // front-end is complete and $0 is properly updated with currently inspected node.
89         webInspector.inspectedWindow.eval("", function() {
90             sidebar.setExpression("(" + expression.toString() + ")();", "title", extension_dumpSidebarContent.bind(this, nextTest));
91         });
92     }
93     webInspector.inspectedWindow.eval("inspect(document.body)", function() {
94         webInspector.panels.elements.createSidebarPane("Watch Test: Expression", onSidebarCreated);
95     });
96 }
97
98 function extension_testSidebarPageReplacedWithObject(nextTest)
99 {
100      var basePath = location.pathname.replace(/\/[^/]*$/, "/");
101      var sidebar;
102
103      function onSidebarCreated(aSidebar)
104      {
105          sidebar = aSidebar;
106          sidebar.onShown.addListener(onShown);
107          sidebar.setPage(basePath + "extension-sidebar.html");
108          extension_showPanel("elements");
109      }
110      var didSetObject = false;
111      function onShown(frame)
112      {
113          output("Got onShown(), frame " + (frame ? "defined" : "not defined"));
114          if (!didSetObject) {
115              didSetObject = true;
116              sidebar.setObject({ foo: 'bar' });
117          } else {
118             sidebar.onShown.removeListener(onShown);
119             nextTest();
120          }
121      }
122      webInspector.panels.elements.createSidebarPane("Sidebar Test: replace page with object", onSidebarCreated);
123 }
124
125 </script>
126 </head>
127 <body onload="runTest()">
128 <p>Tests sidebars in WebInspector extensions API</p>
129 </body>
130 </html>