Changeset 116957 in webkit
- Timestamp:
- May 14, 2012 9:34:15 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r116955 r116957 1 2012-05-14 Andrey Kosyakov <caseq@chromium.org> 2 3 Web Inspector: [Extensions API] allow extensions to evaluate in the context of their content scripts 4 https://bugs.webkit.org/show_bug.cgi?id=86361 5 6 Reviewed by Yury Semikhatsky. 7 8 * inspector/extensions/extensions-eval-content-script-expected.txt: Added. 9 * inspector/extensions/extensions-eval-content-script.html: Added. 10 * platform/gtk/test_expectations.txt: 11 * platform/mac/Skipped: 12 * platform/qt/Skipped: 13 * platform/win/Skipped: 14 * platform/wk2/Skipped: 15 1 16 2012-05-14 Mihnea Ovidenie <mihnea@adobe.com> 2 17 -
trunk/LayoutTests/platform/gtk/test_expectations.txt
r116928 r116957 784 784 BUGWK50868 SKIP : inspector/debugger/debugger-step-out.html = FAIL 785 785 BUGWK50868 SKIP : inspector/styles/styles-source-lines-inline.html = FAIL 786 BUGWK85709 SKIP : inspector/extensions/extensions-eval-content-script.html = FAIL 786 787 787 788 // These inspector tests fell out of the radar after the transition to NRWT -
trunk/LayoutTests/platform/mac/Skipped
r116847 r116957 840 840 # Hits assert https://bugs.webkit.org/show_bug.cgi?id=86208 841 841 ietestcenter/css3/valuesandunits/units-000.htm 842 843 # Inspector only supports evaluation in content script world with v8, see https://bugs.webkit.org/show_bug.cgi?id=85709 844 inspector/extensions/extensions-eval-content-script.html -
trunk/LayoutTests/platform/qt/Skipped
r116940 r116957 2562 2562 fast/frames/seamless/seamless-inherited-document-style.html 2563 2563 2564 # Inspector only supports evaluation in content script world with v8, see https://bugs.webkit.org/show_bug.cgi?id=85709 2565 inspector/extensions/extensions-eval-content-script.html -
trunk/LayoutTests/platform/win/Skipped
r116847 r116957 1745 1745 # https://bugs.webkit.org/show_bug.cgi?id=86000 1746 1746 http/tests/security/referrer-policy-redirect-link.html 1747 1748 # Inspector only supports evaluation in content script world with v8, see https://bugs.webkit.org/show_bug.cgi?id=85709 1749 inspector/extensions/extensions-eval-content-script.html 1750 -
trunk/LayoutTests/platform/wk2/Skipped
r116563 r116957 71 71 http/tests/inspector/extensions-headers.html 72 72 http/tests/inspector/extensions-network-redirect.html 73 74 # Inspector only supports evaluation in content script world with v8, see https://bugs.webkit.org/show_bug.cgi?id=85709 75 inspector/extensions/extensions-eval-content-script.html 73 76 74 77 # A bunch of inspector tests time out on Lion Intel Debug WebKit2 testers. -
trunk/Source/WebCore/ChangeLog
r116954 r116957 1 2012-05-14 Andrey Kosyakov <caseq@chromium.org> 2 3 Web Inspector: [Extensions API] allow extensions to evaluate in the context of their content scripts 4 https://bugs.webkit.org/show_bug.cgi?id=86361 5 6 Reviewed by Yury Semikhatsky. 7 8 Test: inspector/extensions/extensions-eval-content-script.html 9 10 * inspector/front-end/ExtensionAPI.js: 11 (injectedExtensionAPI.ExtensionSidebarPaneImpl.prototype.setExpression): Added evaluateOptions optional parameter. 12 (injectedExtensionAPI.InspectedWindow.prototype.eval): 13 (injectedExtensionAPI.extractCallbackArgument): A helper to extract callback function from last argument. 14 * inspector/front-end/ExtensionPanel.js: 15 (WebInspector.ExtensionSidebarPane.prototype.setExpression): Added evaluateOptions optional parameter. 16 * inspector/front-end/ExtensionServer.js: 17 (WebInspector.ExtensionServer.prototype._onSetSidebarContent): Use ExtensionServer.evaluate() wrapper. 18 (WebInspector.ExtensionServer.prototype._onEvaluateOnInspectedPage): Ditto. 19 (WebInspector.ExtensionServer.prototype._normalizePath): 20 (WebInspector.ExtensionServer.prototype.evaluate): A wrapper for PageAgent.evaluate() that handles evaluateOptions. 21 * inspector/front-end/JavaScriptContextManager.js: 22 (WebInspector.JavaScriptContextManager.prototype.contextByFrameAndSecurityOrigin): Expose interface to locate context id by frame and content script security origin. 23 (WebInspector.FrameEvaluationContext.prototype._addExecutionContext): Maintain contexts sorted by name. 24 (WebInspector.FrameEvaluationContext.prototype.isolatedContexts): ditto (skip sorting when returning contexts) 25 (WebInspector.FrameEvaluationContext.prototype.contextBySecurityOrigin): 26 * inspector/front-end/inspector.js: Hold/expose javaScriptContextManager. 27 1 28 2012-05-14 Pavel Feldman <pfeldman@chromium.org> 2 29 -
trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js
r116739 r116957 415 415 }, 416 416 417 setExpression: function(expression, rootTitle, callback) 418 { 419 extensionServer.sendRequest({ command: commands.SetSidebarContent, id: this._id, expression: expression, rootTitle: rootTitle, evaluateOnPage: true }, callback); 417 setExpression: function(expression, rootTitle, evaluateOptions) 418 { 419 var callback = extractCallbackArgument(arguments); 420 var request = { 421 command: commands.SetSidebarContent, 422 id: this._id, 423 expression: expression, 424 rootTitle: rootTitle, 425 evaluateOnPage: true, 426 }; 427 if (typeof evaluateOptions === "object") 428 request.evaluateOptions = evaluateOptions; 429 extensionServer.sendRequest(request, callback); 420 430 }, 421 431 … … 603 613 }, 604 614 605 eval: function(expression, callback) 606 { 615 eval: function(expression, evaluateOptions) 616 { 617 var callback = extractCallbackArgument(arguments); 607 618 function callbackWrapper(result) 608 619 { 609 620 callback(result.value, result.isException); 610 621 } 611 return extensionServer.sendRequest({ command: commands.EvaluateOnInspectedPage, expression: expression }, callback && callbackWrapper); 622 var request = { 623 command: commands.EvaluateOnInspectedPage, 624 expression: expression 625 }; 626 if (typeof evaluateOptions === "object") 627 request.evaluateOptions = evaluateOptions; 628 return extensionServer.sendRequest(request, callback && callbackWrapper); 612 629 }, 613 630 … … 787 804 } 788 805 806 function extractCallbackArgument(args) 807 { 808 var lastArgument = args[args.length - 1]; 809 return typeof lastArgument === "function" ? lastArgument : undefined; 810 } 811 789 812 var AuditCategory = declareInterfaceClass(AuditCategoryImpl); 790 813 var AuditResult = declareInterfaceClass(AuditResultImpl); -
trunk/Source/WebCore/inspector/front-end/ExtensionPanel.js
r114740 r116957 246 246 * @param {function(?string=)} callback 247 247 */ 248 setExpression: function(expression, title, callback)248 setExpression: function(expression, title, evaluateOptions, securityOrigin, callback) 249 249 { 250 250 this._createObjectPropertiesView(); 251 RuntimeAgent.evaluate(expression, "extension-watch", true, undefined, undefined, undefined, this._onEvaluate.bind(this, title, callback));251 return WebInspector.extensionServer.evaluate(expression, true, false, evaluateOptions, securityOrigin, this._onEvaluate.bind(this, title, callback)); 252 252 }, 253 253 -
trunk/Source/WebCore/inspector/front-end/ExtensionServer.js
r114241 r116957 261 261 } 262 262 if (message.evaluateOnPage) 263 sidebar.setExpression(message.expression, message.rootTitle, callback.bind(this)); 264 else 265 sidebar.setObject(message.expression, message.rootTitle, callback.bind(this)); 263 return sidebar.setExpression(message.expression, message.rootTitle, message.evaluateOptions, port._extensionOrigin, callback.bind(this)); 264 sidebar.setObject(message.expression, message.rootTitle, callback.bind(this)); 266 265 }, 267 266 … … 339 338 this._dispatchCallback(message.requestId, port, result); 340 339 } 341 RuntimeAgent.evaluate(message.expression, "", true, undefined, undefined, true, callback.bind(this));340 return this.evaluate(message.expression, true, true, message.evaluateOptions, port._extensionOrigin, callback.bind(this)); 342 341 }, 343 342 … … 724 723 } 725 724 return "/" + result.join("/"); 725 }, 726 727 /** 728 * @param {string} expression 729 * @param {boolean} exposeCommandLineAPI 730 * @param {boolean} returnByValue 731 * @param {Object} options 732 * @param {string} securityOrigin 733 * @param {function(?string, ?RuntimeAgent.RemoteObject, boolean=)} callback 734 */ 735 evaluate: function(expression, exposeCommandLineAPI, returnByValue, options, securityOrigin, callback) 736 { 737 var contextId; 738 if (typeof options === "object" && options["useContentScriptContext"]) { 739 var mainFrame = WebInspector.resourceTreeModel.mainFrame; 740 if (!mainFrame) 741 return this._status.E_FAILED("main frame not available yet"); 742 var context = WebInspector.javaScriptContextManager.contextByFrameAndSecurityOrigin(mainFrame, securityOrigin); 743 if (!context) 744 return this._status.E_NOTFOUND(securityOrigin); 745 contextId = context.id; 746 } 747 RuntimeAgent.evaluate(expression, "extension", exposeCommandLineAPI, true, contextId, returnByValue, callback); 726 748 } 727 749 } -
trunk/Source/WebCore/inspector/front-end/JavaScriptContextManager.js
r116744 r116957 1 1 /* 2 * Copyright (C) 201 1Google Inc. All rights reserved.2 * Copyright (C) 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 44 44 45 45 WebInspector.JavaScriptContextManager.prototype = { 46 /** 47 * @param {WebInspector.ResourceTreeFrame} frame 48 * @param {string} securityOrigin 49 */ 50 contextByFrameAndSecurityOrigin: function(frame, securityOrigin) 51 { 52 var frameContext = this._frameIdToContext[frame.id]; 53 return frameContext && frameContext.contextBySecurityOrigin(securityOrigin); 54 }, 55 46 56 _frameAdded: function(event) 47 57 { … … 88 98 WebInspector.JavaScriptContextManager.prototype.__proto__ = WebInspector.Object.prototype; 89 99 100 /** 101 * @type {WebInspector.JavaScriptContextManager} 102 */ 103 WebInspector.javaScriptContextManager = null; 90 104 91 105 /** … … 118 132 119 133 /** 120 * @param {WebInspector.ExecutionContext} a 121 * @param {WebInspector.ExecutionContext} b 134 * @param {*} a 135 * @param {*} b 136 * @return {number} 122 137 */ 123 138 WebInspector.ExecutionContext.comparator = function(a, b) … … 164 179 if (context.isMainWorldContext) 165 180 this._mainWorldContext = context; 166 else 167 this._isolatedContexts.push(context); 181 else { 182 var insertAt = insertionIndexForObjectInListSortedByFunction(context, this._isolatedContexts, WebInspector.ExecutionContext.comparator); 183 this._isolatedContexts.splice(insertAt, 0, context); 184 } 168 185 this.dispatchEventToListeners(WebInspector.FrameEvaluationContext.EventTypes.AddedExecutionContext, this); 169 186 }, … … 176 193 isolatedContexts: function() 177 194 { 178 if (this._isolatedContexts.length)179 this._isolatedContexts.sort(WebInspector.ExecutionContext.comparator);180 195 return this._isolatedContexts; 196 }, 197 198 /** 199 * @param {string} securityOrigin 200 */ 201 contextBySecurityOrigin: function(securityOrigin) 202 { 203 for (var i = 0; i < this._isolatedContexts.length; ++i) { 204 var context = this._isolatedContexts[i]; 205 if (!context.isMainWorldContext && context.name === securityOrigin) 206 return context; 207 } 181 208 }, 182 209 -
trunk/Source/WebCore/inspector/front-end/inspector.js
r116854 r116957 393 393 this.networkLog = new WebInspector.NetworkLog(); 394 394 this.domAgent = new WebInspector.DOMAgent(); 395 new WebInspector.JavaScriptContextManager(this.resourceTreeModel, this.consoleView);395 this.javaScriptContextManager = new WebInspector.JavaScriptContextManager(this.resourceTreeModel, this.consoleView); 396 396 397 397 InspectorBackend.registerInspectorDispatcher(this);
Note: See TracChangeset
for help on using the changeset viewer.