[Extensions Bindings] Close the message port if no listeners return true

chrome.runtime.sendMessage requires listeners that will reply
asynchronously to return `true` - this allows the bindings to close the
message port if no listeners intend to respond (protecting against
leakage).

Implement this for native bindings. This takes two steps:
- introduce a callback to JSRunner in order to return the result from
  an asynchronous run of JS. This is necessary in order to see the
  result from dispatching the event to listeners, since the event may
  arrive when JS is disabled.
- look at the returned result from dispatching the runtime.onMessage
  event, and close the port if no listener returned `true`.

Add tests for the same.

Bug: 653596

Change-Id: Ifc9fdd376ae6568d1e4382eed0913c5b9d4c65b8
Reviewed-on: https://chromium-review.googlesource.com/786549
Commit-Queue: Devlin <[email protected]>
Reviewed-by: Istiaque Ahmed <[email protected]>
Reviewed-by: Jeremy Roman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#525732}
diff --git a/extensions/renderer/gin_port.cc b/extensions/renderer/gin_port.cc
index 3dee4ac..046b85c 100644
--- a/extensions/renderer/gin_port.cc
+++ b/extensions/renderer/gin_port.cc
@@ -191,7 +191,7 @@
   gin::Converter<EventEmitter*>::FromV8(isolate, on_message, &emitter);
   CHECK(emitter);
 
-  emitter->Fire(context, args, nullptr);
+  emitter->Fire(context, args, nullptr, JSRunner::ResultCallback());
 }
 
 void GinPort::Invalidate(v8::Local<v8::Context> context) {