Web Inspector: Agent commands do not actually return a promise when expected
authorburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Aug 2015 20:15:16 +0000 (20:15 +0000)
committerburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Aug 2015 20:15:16 +0000 (20:15 +0000)
commit24d431f6c070b365d78aef95c863fe7e6684e225
treef4f3446048d150e1e4f5c1726ea070b166d67e74
parentc1e4c0d25b9d26df66988722b87492d04c89b691
Web Inspector: Agent commands do not actually return a promise when expected
https://bugs.webkit.org/show_bug.cgi?id=138665

Reviewed by Timothy Hatcher.

Source/WebInspectorUI:

This patch unifies the handling of different invocation and dispatch modes in the
InspectorBackend protocol system. Command responses are dispatched to a provided
callback function; if no function was provided, then the command returns a promise.

Rather than awkwardly converting between promises and callbacks at invocation and
response dispatch time, the backend now stores the callback or promise thunks and
knows how to invoke each when the response comes. This mirrors how response handling
works in ProtocolTestStub.js. InspectorBackend includes more machinery to support Agent
objects and various debug flags.

Performanace impact is expected to be negligible, because there are relatively
few commands issued by the inspector frontend and returned promises are short-lived.

Remove all uses of Command.prototype.promise, since it is no longer necessary.

* UserInterface/Base/Test.js:
(InspectorTest.reloadPage):
* UserInterface/Controllers/ReplayManager.js:
(WebInspector.ReplayManager.prototype.getSession.get var):
(WebInspector.ReplayManager.getSegment.get var):
* UserInterface/Models/ReplaySession.js:
(WebInspector.ReplaySession.prototype.segmentsChanged):
* UserInterface/Models/Resource.js:
(WebInspector.Resource.prototype.requestContentFromBackend):
* UserInterface/Models/Script.js:
(WebInspector.Script.prototype.requestContentFromBackend):
* UserInterface/Models/SourceMapResource.js:
(WebInspector.SourceMapResource.prototype.requestContentFromBackend):
* UserInterface/Protocol/InspectorBackend.js:
(InspectorBackendClass):
(InspectorBackendClass.prototype.dispatch):
(InspectorBackendClass.prototype.runAfterPendingDispatches):
(InspectorBackendClass.prototype._sendCommandToBackendWithCallback.set this):
(InspectorBackendClass.set this):
(InspectorBackendClass.prototype._sendCommandToBackendWithCallback):
(InspectorBackendClass.prototype._dispatchResponseToCallback):
(InspectorBackendClass.prototype._dispatchResponseToPromise):
(InspectorBackendClass.prototype._flushPendingScripts):
(InspectorBackend.Command.prototype.invoke):
(InspectorBackend.Command.prototype._invokeWithArguments):
(InspectorBackendClass.prototype._willSendMessageToBackend.set return): Deleted.
(InspectorBackendClass._dispatchCallback.get if): Deleted.
(InspectorBackendClass.prototype._willSendMessageToBackend): Deleted.
(InspectorBackendClass.prototype._invokeCommand): Deleted.
(.callable): Deleted.
(InspectorBackend.Command.create): Deleted.
(InspectorBackend.Command.prototype.promise): Deleted.

LayoutTests:

Add a new test that only checks for proper invocation return values.
Once the async test suite infrastructure is available for frontend tests,
more thorough tests of promises and callbacks will be added.

* inspector/protocol/inspector-backend-invocation-return-value-expected.txt: Added.
* inspector/protocol/inspector-backend-invocation-return-value.html: Added.
* inspector/protocol/protocol-promise-result-expected.txt: Removed.
* inspector/protocol/protocol-promise-result.html: Removed.
* platform/win/TestExpectations: Remove deleted test.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188283 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/protocol/inspector-backend-invocation-return-value-expected.txt [new file with mode: 0644]
LayoutTests/inspector/protocol/inspector-backend-invocation-return-value.html [new file with mode: 0644]
LayoutTests/inspector/protocol/protocol-promise-result-expected.txt [deleted file]
LayoutTests/inspector/protocol/protocol-promise-result.html [deleted file]
LayoutTests/platform/win/TestExpectations
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Test.js
Source/WebInspectorUI/UserInterface/Controllers/ReplayManager.js
Source/WebInspectorUI/UserInterface/Models/ReplaySession.js
Source/WebInspectorUI/UserInterface/Models/Resource.js
Source/WebInspectorUI/UserInterface/Models/Script.js
Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js
Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js