Web Inspector: Add iframe option to inspectedWindow.eval() extension API
https://bugs.webkit.org/show_bug.cgi?id=106811

Patch by John J. Barton <johnjbarton@chromium.org> on 2013-03-19
Reviewed by Vsevolod Vlasov.

Source/WebCore:

Add a new case to the options processing in inspectedWindow.eval(), look
for option.frameURL <string> and/or option.scriptExecutionContext: <string>, find the
matching JS context in the runtimeModel, and call evaluate() in that
context; or error if the context is not found.

Test: http/tests/inspector/extensions-iframe-eval.html

* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer.prototype._onEvaluateOnInspectedPage):
(WebInspector.ExtensionServer.prototype.):
(WebInspector.ExtensionServer.prototype.evaluate):
* inspector/front-end/ResourceTreeModel.js:
(WebInspector.ResourceTreeModel.prototype.frames):
   Added read access to _frames
       * inspector/front-end/RuntimeModel.js:
(WebInspector.RuntimeModel.prototype.contextListByFrame):
   Added access to a frame's contextList, removed contextByFrameAndSecurityOrigin()
(WebInspector.FrameExecutionContextList.prototype.mainWorldContext):
   Added access to frame's mainWorldContext, rather than implicit first context.
   Now we can go from ResourceTreeModel -> frame -> contextList then either
   mainWorldContext() or contextBySecurityOrigin() to access contexts.

* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer.prototype.):
(WebInspector.ExtensionServer.prototype._onEvaluateOnInspectedPage):
(WebInspector.ExtensionServer.prototype.evaluate):
* inspector/front-end/ResourceTreeModel.js:
* inspector/front-end/RuntimeModel.js:
(WebInspector.RuntimeModel.prototype.contextListByFrame):
(WebInspector.FrameExecutionContextList.prototype.mainWorldContext):

* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer.prototype._onReload):
(WebInspector.ExtensionServer.prototype.resolveURLToFrame.hasMatchingURL):
(WebInspector.ExtensionServer.prototype.):
(WebInspector.ExtensionServer.prototype.evaluate):
* inspector/front-end/ResourceTreeModel.js:
(WebInspector.ResourceTreeModel.prototype.frames):
* inspector/front-end/RuntimeModel.js:
(WebInspector.RuntimeModel.prototype.contextListByFrame):
(WebInspector.FrameExecutionContextList.prototype.mainWorldContext):

* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer.prototype.resolveURLToFrame.hasMatchingURL):
(WebInspector.ExtensionServer.prototype.):
(WebInspector.ExtensionServer.prototype.evaluate):
* inspector/front-end/ResourceTreeModel.js:
(WebInspector.ResourceTreeModel.prototype.frames):
* inspector/front-end/RuntimeModel.js:
(WebInspector.RuntimeModel.prototype.contextListByFrame):
(WebInspector.FrameExecutionContextList.prototype.mainWorldContext):

LayoutTests:

New tests for evaluate in iframe options in extension API

* http/tests/inspector/extensions-iframe-eval-expected.txt: Added.
* http/tests/inspector/extensions-iframe-eval.html: Added.
* http/tests/inspector/resources/extensions-frame-eval.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146202 268f45cc-cd09-0410-ab3c-d52691b4dbfc