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">
7 function initialize_extensionsSidebarTest()
9 InspectorTest.dumpSidebarContent = function(callback)
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);
21 function extension_testSidebarSetPage(nextTest)
23 function onSidebarCreated(sidebar)
25 output("Sidebar created");
29 sidebar.onShown.removeListener(onShown);
32 sidebar.onShown.addListener(onShown);
33 var basePath = location.pathname.replace(/\/[^/]*$/, "/");
34 sidebar.setPage(basePath + "extension-sidebar.html");
35 extension_showPanel("elements");
37 webInspector.panels.elements.createSidebarPane("Test Sidebar", onSidebarCreated);
40 function extension_dumpSidebarContent(nextTest)
42 evaluateOnFrontend("InspectorTest.dumpSidebarContent(reply);", nextTest);
45 function extension_testSidebarSetObject(nextTest)
47 function onSidebarCreated(sidebar)
49 output("Watch sidebar created, callback arguments dump follows:");
50 dumpObject(Array.prototype.slice.call(arguments));
57 f5: ["aa", "bb", "cc"],
58 f6: { f60: 42, f61: "foo", f62: [] },
60 }, null, extension_dumpSidebarContent.bind(this, nextTest));
62 webInspector.panels.elements.createSidebarPane("Watch Test: Object", onSidebarCreated);
65 function extension_testSidebarSetExpression(nextTest)
67 function onSidebarCreated(sidebar)
71 document.body.testProperty = 'foo';
78 f5: ["aa", "bb", "cc"],
79 f6: { f60: 42, f61: "foo", f62: [] },
82 f9: document.body.children,
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));
93 webInspector.inspectedWindow.eval("inspect(document.body)", function() {
94 webInspector.panels.elements.createSidebarPane("Watch Test: Expression", onSidebarCreated);
98 function extension_testSidebarPageReplacedWithObject(nextTest)
100 var basePath = location.pathname.replace(/\/[^/]*$/, "/");
103 function onSidebarCreated(aSidebar)
106 sidebar.onShown.addListener(onShown);
107 sidebar.setPage(basePath + "extension-sidebar.html");
108 extension_showPanel("elements");
110 var didSetObject = false;
111 function onShown(frame)
113 output("Got onShown(), frame " + (frame ? "defined" : "not defined"));
116 sidebar.setObject({ foo: 'bar' });
118 sidebar.onShown.removeListener(onShown);
122 webInspector.panels.elements.createSidebarPane("Sidebar Test: replace page with object", onSidebarCreated);
127 <body onload="runTest()">
128 <p>Tests sidebars in WebInspector extensions API</p>