Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: third_party/WebKit/LayoutTests/mojo/connection.html

Issue 2891193002: Mojo JS bindings: switch all mojo/ layout tests to use the new mode. (Closed)
Patch Set: . Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/mojo/connection.html
diff --git a/third_party/WebKit/LayoutTests/mojo/connection.html b/third_party/WebKit/LayoutTests/mojo/connection.html
index 1e41f471f2052f3a4b5b21766655a81cc9ae25c6..156a5416c25d57beee4cbfe85dca0c26a36e8bf0 100644
--- a/third_party/WebKit/LayoutTests/mojo/connection.html
+++ b/third_party/WebKit/LayoutTests/mojo/connection.html
@@ -1,95 +1,83 @@
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
-<script src="../resources/mojo-helpers.js"></script>
+<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
+<script src="file:///gen/mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.js"></script>
+<script src="file:///gen/mojo/public/interfaces/bindings/tests/sample_service.mojom.js"></script>
<script>
'use strict';
-setup({ explicit_done: true });
-
-define([
- 'mojo/public/js/bindings',
- 'mojo/public/js/core',
- 'mojo/public/interfaces/bindings/tests/sample_interfaces.mojom',
- 'mojo/public/interfaces/bindings/tests/sample_service.mojom',
-], function(bindings, core, sample_interfaces, sample_service) {
-
- promise_test(async () => {
- function ServiceImpl() {
- }
-
- ServiceImpl.prototype.frobinate = function(foo, baz, port) {
- assert_equals(foo.name, "Example name");
- assert_equals(baz, sample_service.Service.BazOptions.REGULAR);
- assert_true(port.ptr.isBound());
- port.ptr.reset();
-
- return Promise.resolve({result: 42});
- };
-
- var service = new sample_service.ServicePtr();
- var serviceBinding = new bindings.Binding(sample_service.Service,
- new ServiceImpl(),
- bindings.makeRequest(service));
- var sourcePipe = core.createMessagePipe();
- var port = new sample_service.PortPtr();
- var portRequest = bindings.makeRequest(port);
-
- var foo = new sample_service.Foo();
- foo.bar = new sample_service.Bar();
- foo.name = "Example name";
- foo.source = sourcePipe.handle0;
-
- assert_equals((await service.frobinate(
- foo, sample_service.Service.BazOptions.REGULAR, port)).result, 42);
-
- service.ptr.reset();
- serviceBinding.close();
-
- // sourcePipe.handle1 hasn't been closed yet.
- assert_equals(core.close(sourcePipe.handle1), core.RESULT_OK);
-
- // portRequest.handle hasn't been closed yet.
- assert_equals(core.close(portRequest.handle), core.RESULT_OK);
- }, 'client server');
-
- promise_test(async () => {
- var service = new sample_service.ServicePtr();
- // Discard the interface request.
- var interfaceRequest = bindings.makeRequest(service);
- interfaceRequest.close();
-
- try {
- await service.frobinate(
- null, sample_service.Service.BazOptions.REGULAR, null);
- assert_unreached();
- } catch (e) {
- assert_not_equals(e, null);
- }
- }, 'write to closed pipe');
-
- promise_test(async () => {
- function ProviderImpl() {
- }
-
- ProviderImpl.prototype.echoString = function(a) {
- return Promise.resolve({a: a});
- };
-
- ProviderImpl.prototype.echoStrings = function(a, b) {
- return Promise.resolve({a: a, b: b});
- };
-
- var provider = new sample_interfaces.ProviderPtr();
- var providerBinding = new bindings.Binding(sample_interfaces.Provider,
- new ProviderImpl(),
- bindings.makeRequest(provider));
- assert_equals((await provider.echoString("hello")).a, "hello");
- var response = await provider.echoStrings("hello", "world");
- assert_equals(response.a, "hello");
- assert_equals(response.b, "world");
- }, 'request response');
-
- done();
-});
+promise_test(async () => {
+ function ServiceImpl() {
+ }
+
+ ServiceImpl.prototype.frobinate = function(foo, baz, port) {
+ assert_equals(foo.name, "Example name");
+ assert_equals(baz, sample.Service.BazOptions.REGULAR);
+ assert_true(port.ptr.isBound());
+ port.ptr.reset();
+
+ return Promise.resolve({result: 42});
+ };
+
+ var service = new sample.ServicePtr();
+ var serviceBinding = new mojo.Binding(
+ sample.Service, new ServiceImpl(), mojo.makeRequest(service));
+ var sourcePipe = Mojo.createMessagePipe();
+ var port = new sample.PortPtr();
+ var portRequest = mojo.makeRequest(port);
+
+ var foo = new sample.Foo();
+ foo.bar = new sample.Bar();
+ foo.name = "Example name";
+ foo.source = sourcePipe.handle0;
+
+ assert_equals((await service.frobinate(
+ foo, sample.Service.BazOptions.REGULAR, port)).result, 42);
+
+ service.ptr.reset();
+ serviceBinding.close();
+
+ // sourcePipe.handle1 hasn't been closed yet.
+ sourcePipe.handle1.close();
+
+ // portRequest.handle hasn't been closed yet.
+ portRequest.handle.close();
+}, 'client server');
+
+promise_test(async () => {
+ var service = new sample.ServicePtr();
+ // Discard the interface request.
+ var interfaceRequest = mojo.makeRequest(service);
+ interfaceRequest.close();
+
+ try {
+ await service.frobinate(null, sample.Service.BazOptions.REGULAR, null);
+ assert_unreached();
+ } catch (e) {
+ assert_not_equals(e, null);
+ }
+}, 'write to closed pipe');
+
+promise_test(async () => {
+ function ProviderImpl() {
+ }
+
+ ProviderImpl.prototype.echoString = function(a) {
+ return Promise.resolve({a: a});
+ };
+
+ ProviderImpl.prototype.echoStrings = function(a, b) {
+ return Promise.resolve({a: a, b: b});
+ };
+
+ var provider = new sample.ProviderPtr();
+ var providerBinding = new mojo.Binding(
+ sample.Provider, new ProviderImpl(), mojo.makeRequest(provider));
+ assert_equals((await provider.echoString("hello")).a, "hello");
+ var response = await provider.echoStrings("hello", "world");
+ assert_equals(response.a, "hello");
+ assert_equals(response.b, "world");
+}, 'request response');
+
</script>
« no previous file with comments | « third_party/WebKit/LayoutTests/mojo/codec.html ('k') | third_party/WebKit/LayoutTests/mojo/interface_ptr.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698