OLD | NEW |
1 function extensionFunctions() | 1 function extensionFunctions() |
2 { | 2 { |
3 var functions = ""; | 3 var functions = ""; |
4 | 4 |
5 for (symbol in window) { | 5 for (symbol in window) { |
6 if (/^extension_/.exec(symbol) && typeof window[symbol] === "function") | 6 if (/^extension_/.exec(symbol) && typeof window[symbol] === "function") |
7 functions += window[symbol].toString(); | 7 functions += window[symbol].toString(); |
8 } | 8 } |
9 return functions; | 9 return functions; |
10 } | 10 } |
11 | 11 |
12 var initialize_ExtensionsTest = function() | 12 var initialize_ExtensionsTest = function() |
13 { | 13 { |
14 | 14 |
15 WebInspector.extensionServerProxy._overridePlatformExtensionAPIForTest = functio
n(extensionInfo) | 15 WebInspector.extensionServer._overridePlatformExtensionAPIForTest = function(ext
ensionInfo) |
16 { | 16 { |
17 WebInspector.extensionServerProxy._extensionServer._registerHandler("evaluat
eForTestInFrontEnd", onEvaluate); | 17 WebInspector.extensionServer._registerHandler("evaluateForTestInFrontEnd", o
nEvaluate); |
18 | 18 |
19 function platformExtensionAPI(coreAPI) | 19 function platformExtensionAPI(coreAPI) |
20 { | 20 { |
21 window.webInspector = coreAPI; | 21 window.webInspector = coreAPI; |
22 window._extensionServerForTests = extensionServer; | 22 window._extensionServerForTests = extensionServer; |
23 } | 23 } |
24 return platformExtensionAPI.toString(); | 24 return platformExtensionAPI.toString(); |
25 } | 25 } |
26 | 26 |
27 InspectorTest._replyToExtension = function(requestId, port) | 27 InspectorTest._replyToExtension = function(requestId, port) |
28 { | 28 { |
29 WebInspector.extensionServer._dispatchCallback(requestId, port); | 29 WebInspector.extensionServer._dispatchCallback(requestId, port); |
30 } | 30 } |
31 | 31 |
32 function onEvaluate(message, port) | 32 function onEvaluate(message, port) |
33 { | 33 { |
34 function reply(param) | 34 function reply(param) |
35 { | 35 { |
36 WebInspector.extensionServerProxy._extensionServer._dispatchCallback(mes
sage.requestId, port, param); | 36 WebInspector.extensionServer._dispatchCallback(message.requestId, port,
param); |
37 } | 37 } |
38 | 38 |
39 try { | 39 try { |
40 eval(message.expression); | 40 eval(message.expression); |
41 } catch (e) { | 41 } catch (e) { |
42 InspectorTest.addResult("Exception while running: " + message.expression
+ "\n" + (e.stack || e)); | 42 InspectorTest.addResult("Exception while running: " + message.expression
+ "\n" + (e.stack || e)); |
43 InspectorTest.completeTest(); | 43 InspectorTest.completeTest(); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 InspectorTest.showPanel = function(panelId) | 47 InspectorTest.showPanel = function(panelId) |
48 { | 48 { |
49 if (panelId === "extension") | 49 if (panelId === "extension") |
50 panelId = WebInspector.inspectorView._tabbedPane._tabs[WebInspector.insp
ectorView._tabbedPane._tabs.length - 1].id; | 50 panelId = WebInspector.inspectorView._tabbedPane._tabs[WebInspector.insp
ectorView._tabbedPane._tabs.length - 1].id; |
51 return WebInspector.inspectorView.showPanel(panelId); | 51 return WebInspector.inspectorView.showPanel(panelId); |
52 } | 52 } |
53 | 53 |
54 InspectorTest.runExtensionTests = function() | 54 InspectorTest.runExtensionTests = function() |
55 { | 55 { |
56 WebInspector.extensionServerProxy.setFrontendReady(); | |
57 RuntimeAgent.evaluate("location.href", "console", false, function(error, res
ult) { | 56 RuntimeAgent.evaluate("location.href", "console", false, function(error, res
ult) { |
58 if (error) | 57 if (error) |
59 return; | 58 return; |
60 var pageURL = result.value; | 59 var pageURL = result.value; |
61 var extensionURL = (/^https?:/.test(pageURL) ? | 60 var extensionURL = (/^https?:/.test(pageURL) ? |
62 pageURL.replace(/^(https?:\/\/[^/]*\/).*$/,"$1") : | 61 pageURL.replace(/^(https?:\/\/[^/]*\/).*$/,"$1") : |
63 pageURL.replace(/\/inspector\/extensions\/[^/]*$/, "/http/tests")) + | 62 pageURL.replace(/\/inspector\/extensions\/[^/]*$/, "/http/tests")) + |
64 "/inspector/resources/extension-main.html"; | 63 "/inspector/resources/extension-main.html"; |
65 WebInspector.addExtensions([{ startPage: extensionURL, name: "test exten
sion", exposeWebInspectorNamespace: true }]); | 64 WebInspector.addExtensions([{ startPage: extensionURL, name: "test exten
sion", exposeWebInspectorNamespace: true }]); |
66 }); | 65 }); |
67 } | 66 } |
68 | 67 |
69 } | 68 } |
70 | 69 |
71 function extension_showPanel(panelId, callback) | 70 function extension_showPanel(panelId, callback) |
72 { | 71 { |
73 evaluateOnFrontend("InspectorTest.showPanel(unescape('" + escape(panelId) +
"')).then(function() { reply(); });", callback); | 72 evaluateOnFrontend("InspectorTest.showPanel(unescape('" + escape(panelId) +
"')).then(function() { reply(); });", callback); |
74 } | 73 } |
75 | 74 |
76 var test = function() | 75 var test = function() |
77 { | 76 { |
78 InspectorTest.runExtensionTests(); | 77 InspectorTest.runExtensionTests(); |
79 } | 78 } |
OLD | NEW |