3 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 function defineCommonExtensionSymbols(apiPrivate)
34 if (!apiPrivate.audits)
35 apiPrivate.audits = {};
36 apiPrivate.audits.Severity = {
42 if (!apiPrivate.console)
43 apiPrivate.console = {};
44 apiPrivate.console.Severity = {
51 if (!apiPrivate.panels)
52 apiPrivate.panels = {};
53 apiPrivate.panels.SearchAction = {
54 CancelSearch: "cancelSearch",
55 PerformSearch: "performSearch",
56 NextSearchResult: "nextSearchResult",
57 PreviousSearchResult: "previousSearchResult"
61 AuditStarted: "audit-started-",
62 ButtonClicked: "button-clicked-",
63 ConsoleMessageAdded: "console-message-added",
64 PanelObjectSelected: "panel-objectSelected-",
65 NetworkRequestFinished: "network-request-finished",
66 OpenResource: "open-resource",
67 PanelSearch: "panel-search-",
68 ResourceAdded: "resource-added",
69 ResourceContentCommitted: "resource-content-committed",
70 TimelineEventRecorded: "timeline-event-recorded",
71 ViewShown: "view-shown-",
72 ViewHidden: "view-hidden-"
75 apiPrivate.Commands = {
76 AddAuditCategory: "addAuditCategory",
77 AddAuditResult: "addAuditResult",
78 AddConsoleMessage: "addConsoleMessage",
79 AddRequestHeaders: "addRequestHeaders",
80 ApplyStyleSheet: "applyStyleSheet",
81 CreatePanel: "createPanel",
82 CreateSidebarPane: "createSidebarPane",
83 CreateStatusBarButton: "createStatusBarButton",
84 EvaluateOnInspectedPage: "evaluateOnInspectedPage",
85 ForwardKeyboardEvent: "_forwardKeyboardEvent",
86 GetConsoleMessages: "getConsoleMessages",
88 GetPageResources: "getPageResources",
89 GetRequestContent: "getRequestContent",
90 GetResourceContent: "getResourceContent",
91 InspectedURLChanged: "inspectedURLChanged",
92 OpenResource: "openResource",
94 Subscribe: "subscribe",
95 SetOpenResourceHandler: "setOpenResourceHandler",
96 SetResourceContent: "setResourceContent",
97 SetSidebarContent: "setSidebarContent",
98 SetSidebarHeight: "setSidebarHeight",
99 SetSidebarPage: "setSidebarPage",
100 ShowPanel: "showPanel",
101 StopAuditCategoryRun: "stopAuditCategoryRun",
102 Unsubscribe: "unsubscribe",
103 UpdateAuditProgress: "updateAuditProgress",
104 UpdateButton: "updateButton"
109 * @param {number} injectedScriptId
112 function injectedExtensionAPI(injectedScriptId)
117 defineCommonExtensionSymbols(apiPrivate);
119 var commands = apiPrivate.Commands;
120 var events = apiPrivate.Events;
121 var userAction = false;
123 // Here and below, all constructors are private to API implementation.
124 // For a public type Foo, if internal fields are present, these are on
125 // a private FooImpl type, an instance of FooImpl is used in a closure
126 // by Foo consutrctor to re-bind publicly exported members to an instance
132 function EventSinkImpl(type, customDispatch)
135 this._listeners = [];
136 this._customDispatch = customDispatch;
139 EventSinkImpl.prototype = {
140 addListener: function(callback)
142 if (typeof callback !== "function")
143 throw "addListener: callback is not a function";
144 if (this._listeners.length === 0)
145 extensionServer.sendRequest({ command: commands.Subscribe, type: this._type });
146 this._listeners.push(callback);
147 extensionServer.registerHandler("notify-" + this._type, this._dispatch.bind(this));
150 removeListener: function(callback)
152 var listeners = this._listeners;
154 for (var i = 0; i < listeners.length; ++i) {
155 if (listeners[i] === callback) {
156 listeners.splice(i, 1);
160 if (this._listeners.length === 0)
161 extensionServer.sendRequest({ command: commands.Unsubscribe, type: this._type });
165 * @param {...} vararg
167 _fire: function(vararg)
169 var listeners = this._listeners.slice();
170 for (var i = 0; i < listeners.length; ++i)
171 listeners[i].apply(null, arguments);
174 _dispatch: function(request)
176 if (this._customDispatch)
177 this._customDispatch.call(this, request);
179 this._fire.apply(this, request.arguments);
186 function InspectorExtensionAPI()
188 this.audits = new Audits();
189 this.inspectedWindow = new InspectedWindow();
190 this.panels = new Panels();
191 this.network = new Network();
192 defineDeprecatedProperty(this, "webInspector", "resources", "network");
193 this.timeline = new Timeline();
194 this.console = new ConsoleAPI();
200 function ConsoleAPI()
202 this.onMessageAdded = new EventSink(events.ConsoleMessageAdded);
205 ConsoleAPI.prototype = {
206 getMessages: function(callback)
208 extensionServer.sendRequest({ command: commands.GetConsoleMessages }, callback);
211 addMessage: function(severity, text, url, line)
213 extensionServer.sendRequest({ command: commands.AddConsoleMessage, severity: severity, text: text, url: url, line: line });
218 return apiPrivate.console.Severity;
228 * @this {EventSinkImpl}
230 function dispatchRequestEvent(message)
232 var request = message.arguments[1];
233 request.__proto__ = new Request(message.arguments[0]);
236 this.onRequestFinished = new EventSink(events.NetworkRequestFinished, dispatchRequestEvent);
237 defineDeprecatedProperty(this, "network", "onFinished", "onRequestFinished");
238 this.onNavigated = new EventSink(events.InspectedURLChanged);
241 Network.prototype = {
242 getHAR: function(callback)
244 function callbackWrapper(result)
246 var entries = (result && result.entries) || [];
247 for (var i = 0; i < entries.length; ++i) {
248 entries[i].__proto__ = new Request(entries[i]._requestId);
249 delete entries[i]._requestId;
253 extensionServer.sendRequest({ command: commands.GetHAR }, callback && callbackWrapper);
256 addRequestHeaders: function(headers)
258 extensionServer.sendRequest({ command: commands.AddRequestHeaders, headers: headers, extensionId: window.location.hostname });
265 function RequestImpl(id)
270 RequestImpl.prototype = {
271 getContent: function(callback)
273 function callbackWrapper(response)
275 callback(response.content, response.encoding);
277 extensionServer.sendRequest({ command: commands.GetRequestContent, id: this._id }, callback && callbackWrapper);
287 elements: new ElementsPanel(),
288 sources: new SourcesPanel(),
291 function panelGetter(name)
295 for (var panel in panels)
296 this.__defineGetter__(panel, panelGetter.bind(null, panel));
297 this.applyStyleSheet = function(styleSheet) { extensionServer.sendRequest({ command: commands.ApplyStyleSheet, styleSheet: styleSheet }); };
301 create: function(title, icon, page, callback)
303 var id = "extension-panel-" + extensionServer.nextObjectId();
305 command: commands.CreatePanel,
311 extensionServer.sendRequest(request, callback && callback.bind(this, new ExtensionPanel(id)));
314 setOpenResourceHandler: function(callback)
316 var hadHandler = extensionServer.hasHandler(events.OpenResource);
318 function callbackWrapper(message)
320 // Allow the panel to show itself when handling the event.
323 callback.call(null, new Resource(message.resource), message.lineNumber);
330 extensionServer.unregisterHandler(events.OpenResource);
332 extensionServer.registerHandler(events.OpenResource, callbackWrapper);
334 // Only send command if we either removed an existing handler or added handler and had none before.
335 if (hadHandler === !callback)
336 extensionServer.sendRequest({ command: commands.SetOpenResourceHandler, "handlerPresent": !!callback });
339 openResource: function(url, lineNumber, callback)
341 extensionServer.sendRequest({ command: commands.OpenResource, "url": url, "lineNumber": lineNumber }, callback);
346 return apiPrivate.panels.SearchAction;
353 function ExtensionViewImpl(id)
358 * @this {EventSinkImpl}
360 function dispatchShowEvent(message)
362 var frameIndex = message.arguments[0];
363 if (typeof frameIndex === "number")
364 this._fire(window.parent.frames[frameIndex]);
370 this.onShown = new EventSink(events.ViewShown + id, dispatchShowEvent);
371 this.onHidden = new EventSink(events.ViewHidden + id);
377 * @extends {ExtensionViewImpl}
378 * @param {string} hostPanelName
380 function PanelWithSidebarImpl(hostPanelName)
382 ExtensionViewImpl.call(this, null);
383 this._hostPanelName = hostPanelName;
384 this.onSelectionChanged = new EventSink(events.PanelObjectSelected + hostPanelName);
387 PanelWithSidebarImpl.prototype = {
388 createSidebarPane: function(title, callback)
390 var id = "extension-sidebar-" + extensionServer.nextObjectId();
392 command: commands.CreateSidebarPane,
393 panel: this._hostPanelName,
397 function callbackWrapper()
399 callback(new ExtensionSidebarPane(id));
401 extensionServer.sendRequest(request, callback && callbackWrapper);
404 __proto__: ExtensionViewImpl.prototype
407 function declareInterfaceClass(implConstructor)
411 var impl = { __proto__: implConstructor.prototype };
412 implConstructor.apply(impl, arguments);
413 populateInterfaceClass(this, impl);
417 function defineDeprecatedProperty(object, className, oldName, newName)
419 var warningGiven = false;
423 console.warn(className + "." + oldName + " is deprecated. Use " + className + "." + newName + " instead");
426 return object[newName];
428 object.__defineGetter__(oldName, getter);
431 function extractCallbackArgument(args)
433 var lastArgument = args[args.length - 1];
434 return typeof lastArgument === "function" ? lastArgument : undefined;
437 var AuditCategory = declareInterfaceClass(AuditCategoryImpl);
438 var AuditResult = declareInterfaceClass(AuditResultImpl);
439 var Button = declareInterfaceClass(ButtonImpl);
440 var EventSink = declareInterfaceClass(EventSinkImpl);
441 var ExtensionPanel = declareInterfaceClass(ExtensionPanelImpl);
442 var ExtensionSidebarPane = declareInterfaceClass(ExtensionSidebarPaneImpl);
443 var PanelWithSidebar = declareInterfaceClass(PanelWithSidebarImpl);
444 var Request = declareInterfaceClass(RequestImpl);
445 var Resource = declareInterfaceClass(ResourceImpl);
446 var Timeline = declareInterfaceClass(TimelineImpl);
450 * @extends {PanelWithSidebar}
452 function ElementsPanel()
454 PanelWithSidebar.call(this, "elements");
457 ElementsPanel.prototype = {
458 __proto__: PanelWithSidebar.prototype
463 * @extends {PanelWithSidebar}
465 function SourcesPanel()
467 PanelWithSidebar.call(this, "sources");
470 SourcesPanel.prototype = {
471 __proto__: PanelWithSidebar.prototype
476 * @extends {ExtensionViewImpl}
478 function ExtensionPanelImpl(id)
480 ExtensionViewImpl.call(this, id);
481 this.onSearch = new EventSink(events.PanelSearch + id);
484 ExtensionPanelImpl.prototype = {
488 createStatusBarButton: function(iconPath, tooltipText, disabled)
490 var id = "button-" + extensionServer.nextObjectId();
492 command: commands.CreateStatusBarButton,
496 tooltip: tooltipText,
499 extensionServer.sendRequest(request);
500 return new Button(id);
509 command: commands.ShowPanel,
512 extensionServer.sendRequest(request);
515 __proto__: ExtensionViewImpl.prototype
520 * @extends {ExtensionViewImpl}
522 function ExtensionSidebarPaneImpl(id)
524 ExtensionViewImpl.call(this, id);
527 ExtensionSidebarPaneImpl.prototype = {
528 setHeight: function(height)
530 extensionServer.sendRequest({ command: commands.SetSidebarHeight, id: this._id, height: height });
533 setExpression: function(expression, rootTitle, evaluateOptions)
536 command: commands.SetSidebarContent,
538 expression: expression,
539 rootTitle: rootTitle,
540 evaluateOnPage: true,
542 if (typeof evaluateOptions === "object")
543 request.evaluateOptions = evaluateOptions;
544 extensionServer.sendRequest(request, extractCallbackArgument(arguments));
547 setObject: function(jsonObject, rootTitle, callback)
549 extensionServer.sendRequest({ command: commands.SetSidebarContent, id: this._id, expression: jsonObject, rootTitle: rootTitle }, callback);
552 setPage: function(page)
554 extensionServer.sendRequest({ command: commands.SetSidebarPage, id: this._id, page: page });
557 __proto__: ExtensionViewImpl.prototype
563 function ButtonImpl(id)
566 this.onClicked = new EventSink(events.ButtonClicked + id);
569 ButtonImpl.prototype = {
570 update: function(iconPath, tooltipText, disabled)
573 command: commands.UpdateButton,
576 tooltip: tooltipText,
579 extensionServer.sendRequest(request);
592 * @return {!AuditCategory}
594 addCategory: function(displayName, resultCount)
596 var id = "extension-audit-category-" + extensionServer.nextObjectId();
597 if (typeof resultCount !== "undefined")
598 console.warn("Passing resultCount to audits.addCategory() is deprecated. Use AuditResult.updateProgress() instead.");
599 extensionServer.sendRequest({ command: commands.AddAuditCategory, id: id, displayName: displayName, resultCount: resultCount });
600 return new AuditCategory(id);
607 function AuditCategoryImpl(id)
610 * @this {EventSinkImpl}
612 function dispatchAuditEvent(request)
614 var auditResult = new AuditResult(request.arguments[0]);
616 this._fire(auditResult);
618 console.error("Uncaught exception in extension audit event handler: " + e);
623 this.onAuditStarted = new EventSink(events.AuditStarted + id, dispatchAuditEvent);
629 function AuditResultImpl(id)
633 this.createURL = this._nodeFactory.bind(this, "url");
634 this.createSnippet = this._nodeFactory.bind(this, "snippet");
635 this.createText = this._nodeFactory.bind(this, "text");
636 this.createObject = this._nodeFactory.bind(this, "object");
637 this.createNode = this._nodeFactory.bind(this, "node");
640 AuditResultImpl.prototype = {
641 addResult: function(displayName, description, severity, details)
643 // shorthand for specifying details directly in addResult().
644 if (details && !(details instanceof AuditResultNode))
645 details = new AuditResultNode(details instanceof Array ? details : [details]);
648 command: commands.AddAuditResult,
650 displayName: displayName,
651 description: description,
655 extensionServer.sendRequest(request);
661 createResult: function()
663 return new AuditResultNode(Array.prototype.slice.call(arguments));
666 updateProgress: function(worked, totalWork)
668 extensionServer.sendRequest({ command: commands.UpdateAuditProgress, resultId: this._id, progress: worked / totalWork });
673 extensionServer.sendRequest({ command: commands.StopAuditCategoryRun, resultId: this._id });
677 * @type {!Object.<string, string>}
681 return apiPrivate.audits.Severity;
685 * @return {!{type: string, arguments: !Array.<string|number>}}
687 createResourceLink: function(url, lineNumber)
690 type: "resourceLink",
691 arguments: [url, lineNumber && lineNumber - 1]
696 * @return {!{type: string, arguments: !Array.<string|number>}}
698 _nodeFactory: function(type)
702 arguments: Array.prototype.slice.call(arguments, 1)
710 function AuditResultNode(contents)
712 this.contents = contents;
714 this.expanded = false;
717 AuditResultNode.prototype = {
723 var node = new AuditResultNode(Array.prototype.slice.call(arguments));
724 this.children.push(node);
732 function InspectedWindow()
735 * @this {EventSinkImpl}
737 function dispatchResourceEvent(message)
739 this._fire(new Resource(message.arguments[0]));
743 * @this {EventSinkImpl}
745 function dispatchResourceContentEvent(message)
747 this._fire(new Resource(message.arguments[0]), message.arguments[1]);
750 this.onResourceAdded = new EventSink(events.ResourceAdded, dispatchResourceEvent);
751 this.onResourceContentCommitted = new EventSink(events.ResourceContentCommitted, dispatchResourceContentEvent);
754 InspectedWindow.prototype = {
755 reload: function(optionsOrUserAgent)
758 if (typeof optionsOrUserAgent === "object")
759 options = optionsOrUserAgent;
760 else if (typeof optionsOrUserAgent === "string") {
761 options = { userAgent: optionsOrUserAgent };
762 console.warn("Passing userAgent as string parameter to inspectedWindow.reload() is deprecated. " +
763 "Use inspectedWindow.reload({ userAgent: value}) instead.");
765 extensionServer.sendRequest({ command: commands.Reload, options: options });
771 eval: function(expression, evaluateOptions)
773 var callback = extractCallbackArgument(arguments);
774 function callbackWrapper(result)
776 if (result.isError || result.isException)
777 callback(undefined, result);
779 callback(result.value);
782 command: commands.EvaluateOnInspectedPage,
783 expression: expression
785 if (typeof evaluateOptions === "object")
786 request.evaluateOptions = evaluateOptions;
787 extensionServer.sendRequest(request, callback && callbackWrapper);
791 getResources: function(callback)
793 function wrapResource(resourceData)
795 return new Resource(resourceData);
797 function callbackWrapper(resources)
799 callback(resources.map(wrapResource));
801 extensionServer.sendRequest({ command: commands.GetPageResources }, callback && callbackWrapper);
808 function ResourceImpl(resourceData)
810 this._url = resourceData.url
811 this._type = resourceData.type;
814 ResourceImpl.prototype = {
825 getContent: function(callback)
827 function callbackWrapper(response)
829 callback(response.content, response.encoding);
832 extensionServer.sendRequest({ command: commands.GetResourceContent, url: this._url }, callback && callbackWrapper);
835 setContent: function(content, commit, callback)
837 extensionServer.sendRequest({ command: commands.SetResourceContent, url: this._url, content: content, commit: commit }, callback);
844 function TimelineImpl()
846 this.onEventRecorded = new EventSink(events.TimelineEventRecorded);
849 var keyboardEventRequestQueue = [];
850 var forwardTimer = null;
852 function forwardKeyboardEvent(event)
854 const Esc = "U+001B";
855 // We only care about global hotkeys, not about random text
856 if (!event.ctrlKey && !event.altKey && !event.metaKey && !/^F\d+$/.test(event.keyIdentifier) && event.keyIdentifier !== Esc)
858 var requestPayload = {
859 eventType: event.type,
860 ctrlKey: event.ctrlKey,
861 altKey: event.altKey,
862 metaKey: event.metaKey,
863 keyIdentifier: event.keyIdentifier,
864 location: event.location,
865 keyCode: event.keyCode
867 keyboardEventRequestQueue.push(requestPayload);
869 forwardTimer = setTimeout(forwardEventQueue, 0);
872 function forwardEventQueue()
876 command: commands.ForwardKeyboardEvent,
877 entries: keyboardEventRequestQueue
879 extensionServer.sendRequest(request);
880 keyboardEventRequestQueue = [];
883 document.addEventListener("keydown", forwardKeyboardEvent, false);
884 document.addEventListener("keypress", forwardKeyboardEvent, false);
889 function ExtensionServerClient()
891 this._callbacks = {};
893 this._lastRequestId = 0;
894 this._lastObjectId = 0;
896 this.registerHandler("callback", this._onCallback.bind(this));
898 var channel = new MessageChannel();
899 this._port = channel.port1;
900 this._port.addEventListener("message", this._onMessage.bind(this), false);
903 window.parent.postMessage("registerExtension", [ channel.port2 ], "*");
906 ExtensionServerClient.prototype = {
908 * @param {!Object} message
909 * @param {function()=} callback
911 sendRequest: function(message, callback)
913 if (typeof callback === "function")
914 message.requestId = this._registerCallback(callback);
915 this._port.postMessage(message);
921 hasHandler: function(command)
923 return !!this._handlers[command];
926 registerHandler: function(command, handler)
928 this._handlers[command] = handler;
931 unregisterHandler: function(command)
933 delete this._handlers[command];
939 nextObjectId: function()
941 return injectedScriptId + "_" + ++this._lastObjectId;
944 _registerCallback: function(callback)
946 var id = ++this._lastRequestId;
947 this._callbacks[id] = callback;
951 _onCallback: function(request)
953 if (request.requestId in this._callbacks) {
954 var callback = this._callbacks[request.requestId];
955 delete this._callbacks[request.requestId];
956 callback(request.result);
960 _onMessage: function(event)
962 var request = event.data;
963 var handler = this._handlers[request.command];
965 handler.call(this, request);
969 function populateInterfaceClass(interfaze, implementation)
971 for (var member in implementation) {
972 if (member.charAt(0) === "_")
974 var descriptor = null;
975 // Traverse prototype chain until we find the owner.
976 for (var owner = implementation; owner && !descriptor; owner = owner.__proto__)
977 descriptor = Object.getOwnPropertyDescriptor(owner, member);
980 if (typeof descriptor.value === "function")
981 interfaze[member] = descriptor.value.bind(implementation);
982 else if (typeof descriptor.get === "function")
983 interfaze.__defineGetter__(member, descriptor.get.bind(implementation));
985 Object.defineProperty(interfaze, member, descriptor);
989 // extensionServer is a closure variable defined by the glue below -- make sure we fail if it's not there.
990 if (!extensionServer)
991 extensionServer = new ExtensionServerClient();
993 return new InspectorExtensionAPI();
997 * @suppress {checkVars, checkTypes}
999 function platformExtensionAPI(coreAPI)
1005 chrome = window.chrome || {};
1006 // Override chrome.devtools as a workaround for a error-throwing getter being exposed
1007 // in extension pages loaded into a non-extension process (only happens for remote client
1009 var devtools_descriptor = Object.getOwnPropertyDescriptor(chrome, "devtools");
1010 if (!devtools_descriptor || devtools_descriptor.get)
1011 Object.defineProperty(chrome, "devtools", { value: {}, enumerable: true });
1012 // Only expose tabId on chrome.devtools.inspectedWindow, not webInspector.inspectedWindow.
1013 chrome.devtools.inspectedWindow = {};
1014 chrome.devtools.inspectedWindow.__defineGetter__("tabId", getTabId);
1015 chrome.devtools.inspectedWindow.__proto__ = coreAPI.inspectedWindow;
1016 chrome.devtools.network = coreAPI.network;
1017 chrome.devtools.panels = coreAPI.panels;
1019 // default to expose experimental APIs for now.
1020 if (extensionInfo.exposeExperimentalAPIs !== false) {
1021 chrome.experimental = chrome.experimental || {};
1022 chrome.experimental.devtools = chrome.experimental.devtools || {};
1024 var properties = Object.getOwnPropertyNames(coreAPI);
1025 for (var i = 0; i < properties.length; ++i) {
1026 var descriptor = Object.getOwnPropertyDescriptor(coreAPI, properties[i]);
1027 Object.defineProperty(chrome.experimental.devtools, properties[i], descriptor);
1029 chrome.experimental.devtools.inspectedWindow = chrome.devtools.inspectedWindow;
1031 if (extensionInfo.exposeWebInspectorNamespace)
1032 window.webInspector = coreAPI;
1036 * @param {!ExtensionDescriptor} extensionInfo
1039 function buildPlatformExtensionAPI(extensionInfo)
1041 return "var extensionInfo = " + JSON.stringify(extensionInfo) + ";" +
1042 "var tabId = " + WebInspector._inspectedTabId + ";" +
1043 platformExtensionAPI.toString();
1047 * @param {!ExtensionDescriptor} extensionInfo
1050 function buildExtensionAPIInjectedScript(extensionInfo)
1052 return "(function(injectedScriptId){ " +
1053 "var extensionServer;" +
1054 defineCommonExtensionSymbols.toString() + ";" +
1055 injectedExtensionAPI.toString() + ";" +
1056 buildPlatformExtensionAPI(extensionInfo) + ";" +
1057 "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" +
1063 var extensionInfo = {};
1064 var extensionServer;
1065 platformExtensionAPI(injectedExtensionAPI("remote-" + window.parent.frames.length));