Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / inspector / extensions-test.js
blobb5d0b0431d7ad51c885e10c779eef1beb5b1b692
1 function extensionFunctions()
3 var functions = "";
5 for (symbol in window) {
6 if (/^extension_/.exec(symbol) && typeof window[symbol] === "function")
7 functions += window[symbol].toString();
9 return functions;
12 var initialize_ExtensionsTest = function()
15 WebInspector.extensionServer._overridePlatformExtensionAPIForTest = function(extensionInfo, inspectedTabId)
17 WebInspector.extensionServer._registerHandler("evaluateForTestInFrontEnd", onEvaluate);
19 function platformExtensionAPI(coreAPI)
21 window.webInspector = coreAPI;
22 window._extensionServerForTests = extensionServer;
24 return platformExtensionAPI.toString();
27 InspectorTest._replyToExtension = function(requestId, port)
29 WebInspector.extensionServer._dispatchCallback(requestId, port);
32 function onEvaluate(message, port)
34 function reply(param)
36 WebInspector.extensionServer._dispatchCallback(message.requestId, port, param);
39 try {
40 eval(message.expression);
41 } catch (e) {
42 InspectorTest.addResult("Exception while running: " + message.expression + "\n" + (e.stack || e));
43 InspectorTest.completeTest();
47 InspectorTest.showPanel = function(panelId)
49 if (panelId === "extension")
50 panelId = WebInspector.inspectorView._tabbedPane._tabs[WebInspector.inspectorView._tabbedPane._tabs.length - 1].id;
51 return WebInspector.inspectorView.showPanel(panelId);
54 InspectorTest.runExtensionTests = function()
56 InspectorTest.RuntimeAgent.evaluate("location.href", "console", false, function(error, result) {
57 if (error)
58 return;
59 var pageURL = result.value;
60 var extensionURL = (/^https?:/.test(pageURL) ?
61 pageURL.replace(/^(https?:\/\/[^/]*\/).*$/,"$1") :
62 pageURL.replace(/\/inspector\/extensions\/[^/]*$/, "/http/tests")) +
63 "/inspector/resources/extension-main.html";
64 InspectorFrontendAPI.addExtensions([{ startPage: extensionURL, name: "test extension", exposeWebInspectorNamespace: true }]);
65 WebInspector.extensionServer.initializeExtensions();
66 });
71 function extension_showPanel(panelId, callback)
73 evaluateOnFrontend("InspectorTest.showPanel(unescape('" + escape(panelId) + "')).then(function() { reply(); });", callback);
76 var test = function()
78 InspectorTest.runExtensionTests();