Commit caae5e54 authored by Reilly Grant's avatar Reilly Grant Committed by Commit Bot

Revert "Dispatch interfacerequest event in a new microtask"

This reverts commit fe5c2f3d.

Reason for revert: This appears to be causing flake in the WebUSB layout tests.

Original change's description:
> Dispatch interfacerequest event in a new microtask
> 
> This change modifies the MojoInterfaceInterceptor so that the
> 'interfacerequest' event, fired when a request for the intercepted
> interface is made, is dispatched in a new microtask instead of
> synchronously.
> 
> This has the benefit of not reentering JavaScript to execute event
> handlers synchronously which is both different from the usual case for
> binding interfaces that are provided by other processes and avoids the
> possibilty of attempting to dispatch this event to JavaScript from a
> scope where script is forbidden.
> 
> Change-Id: I08b8c25a04da047381a3786af08b62979ca7b837
> Reviewed-on: https://chromium-review.googlesource.com/594716
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: Yuzhu Shen <yzshen@chromium.org>
> Commit-Queue: Reilly Grant <reillyg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#491552}

TBR=dcheng@chromium.org,yzshen@chromium.org,reillyg@chromium.org

Change-Id: Ibc179e1313fceba9a6e8da37e5220ccb6aa7c204
Bug: 751955
Reviewed-on: https://chromium-review.googlesource.com/601007
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491864}
parent 0a22294f
...@@ -3097,6 +3097,3 @@ crbug.com/749738 [ Win7 Debug ] http/tests/devtools/console/console-format-es6-2 ...@@ -3097,6 +3097,3 @@ crbug.com/749738 [ Win7 Debug ] http/tests/devtools/console/console-format-es6-2
crbug.com/749738 [ Win7 Debug ] virtual/mojo-loading/http/tests/devtools/console/console-format-es6-2.js [ Timeout ] crbug.com/749738 [ Win7 Debug ] virtual/mojo-loading/http/tests/devtools/console/console-format-es6-2.js [ Timeout ]
crbug.com/749965 [ Win7 Debug ] media/controls/controls-video-keynav.html [ Failure ] crbug.com/749965 [ Win7 Debug ] media/controls/controls-video-keynav.html [ Failure ]
crbug.com/750310 [ Win7 Debug ] virtual/off-main-thread-fetch/http/tests/inspector/network/network-blocked-reason.html [ Timeout ] crbug.com/750310 [ Win7 Debug ] virtual/off-main-thread-fetch/http/tests/inspector/network/network-blocked-reason.html [ Timeout ]
# Sheriff failures 2017-08-03
crbug.com/751955 external/wpt/webusb/idlharness.https.html [ Timeout Pass ]
...@@ -77,41 +77,25 @@ promise_test(() => { ...@@ -77,41 +77,25 @@ promise_test(() => {
return Promise.reject(); return Promise.reject();
}, "interface interceptors are mutually exclusive"); }, "interface interceptors are mutually exclusive");
test(async t => { test(() => {
const kTestInterfaceName = "foo::mojom::Bar"; const kTestInterfaceName = "foo::mojom::Bar";
let interceptedHandle = null;
// First check that the interceptor can be started and intercepts requests.
let interceptor = new MojoInterfaceInterceptor(kTestInterfaceName); let interceptor = new MojoInterfaceInterceptor(kTestInterfaceName);
let promise = new Promise(resolve => { interceptor.oninterfacerequest = e => { interceptedHandle = e.handle; };
interceptor.oninterfacerequest = e => {
resolve(e.handle);
};
});
interceptor.start(); interceptor.start();
let pipe = Mojo.createMessagePipe(); let {handle0, handle1} = Mojo.createMessagePipe();
Mojo.bindInterface(kTestInterfaceName, pipe.handle0); Mojo.bindInterface(kTestInterfaceName, handle0);
let interceptedHandle = await promise; interceptor.stop();
assert_true(interceptedHandle instanceof MojoHandle); assert_true(interceptedHandle instanceof MojoHandle);
interceptedHandle.close(); interceptedHandle.close();
pipe.handle1.close(); interceptedHandle = null;
// Stop the interceptor and make another request. Mojo.bindInterface(kTestInterfaceName, handle1);
interceptor.stop(); assert_equals(interceptedHandle, null);
handle1.close();
pipe = Mojo.createMessagePipe();
interceptor.oninterfacerequest = t.step_func(() => {
assert_unreached("unexpected 'interfacerequest' event after stop");
});
promise = new Promise(resolve => {
let watcher = pipe.handle1.watch({peerClosed: true}, () => {
watcher.cancel(); // Necessary to avoid a DCHECK when handle1 is closed.
resolve();
});
});
Mojo.bindInterface(kTestInterfaceName, pipe.handle0);
await promise;
pipe.handle1.close();
interceptor = new MojoInterfaceInterceptor(kTestInterfaceName); interceptor = new MojoInterfaceInterceptor(kTestInterfaceName);
interceptor.oninterfacerequest = e => {}; interceptor.oninterfacerequest = e => {};
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/ExceptionState.h"
#include "core/dom/Document.h" #include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h" #include "core/dom/ExecutionContext.h"
#include "core/dom/TaskRunnerHelper.h"
#include "core/frame/LocalDOMWindow.h" #include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "core/frame/LocalFrameClient.h" #include "core/frame/LocalFrameClient.h"
...@@ -15,7 +14,6 @@ ...@@ -15,7 +14,6 @@
#include "core/mojo/test/MojoInterfaceRequestEvent.h" #include "core/mojo/test/MojoInterfaceRequestEvent.h"
#include "core/workers/WorkerGlobalScope.h" #include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerThread.h" #include "core/workers/WorkerThread.h"
#include "platform/WebTaskRunner.h"
#include "platform/bindings/ScriptState.h" #include "platform/bindings/ScriptState.h"
#include "platform/wtf/text/StringUTF8Adaptor.h" #include "platform/wtf/text/StringUTF8Adaptor.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
...@@ -120,20 +118,6 @@ MojoInterfaceInterceptor::GetInterfaceProvider() const { ...@@ -120,20 +118,6 @@ MojoInterfaceInterceptor::GetInterfaceProvider() const {
void MojoInterfaceInterceptor::OnInterfaceRequest( void MojoInterfaceInterceptor::OnInterfaceRequest(
mojo::ScopedMessagePipeHandle handle) { mojo::ScopedMessagePipeHandle handle) {
// Execution of JavaScript may be forbidden in this context as this method is
// called synchronously by the InterfaceProvider. Dispatching of the
// 'interfacerequest' event is therefore scheduled to take place in the next
// microtask. This also more closely mirrors the behavior when an interface
// request is being satisfied by another process.
TaskRunnerHelper::Get(TaskType::kMicrotask, GetExecutionContext())
->PostTask(
BLINK_FROM_HERE,
WTF::Bind(&MojoInterfaceInterceptor::DispatchInterfaceRequestEvent,
WrapPersistent(this), WTF::Passed(std::move(handle))));
}
void MojoInterfaceInterceptor::DispatchInterfaceRequestEvent(
mojo::ScopedMessagePipeHandle handle) {
DispatchEvent(MojoInterfaceRequestEvent::Create( DispatchEvent(MojoInterfaceRequestEvent::Create(
MojoHandle::Create(mojo::ScopedHandle::From(std::move(handle))))); MojoHandle::Create(mojo::ScopedHandle::From(std::move(handle)))));
} }
......
...@@ -65,7 +65,6 @@ class MojoInterfaceInterceptor final ...@@ -65,7 +65,6 @@ class MojoInterfaceInterceptor final
service_manager::InterfaceProvider* GetInterfaceProvider() const; service_manager::InterfaceProvider* GetInterfaceProvider() const;
void OnInterfaceRequest(mojo::ScopedMessagePipeHandle); void OnInterfaceRequest(mojo::ScopedMessagePipeHandle);
void DispatchInterfaceRequestEvent(mojo::ScopedMessagePipeHandle);
const String interface_name_; const String interface_name_;
bool started_ = false; bool started_ = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment