| Index: third_party/WebKit/LayoutTests/mojo/interface_ptr.html
|
| diff --git a/third_party/WebKit/LayoutTests/mojo/interface_ptr.html b/third_party/WebKit/LayoutTests/mojo/interface_ptr.html
|
| index 295461ac0c7cf486c4236572d14d35d5abac0bea..3dbe6520c070ff6c759cca9abe46d44d5c5fb381 100644
|
| --- a/third_party/WebKit/LayoutTests/mojo/interface_ptr.html
|
| +++ b/third_party/WebKit/LayoutTests/mojo/interface_ptr.html
|
| @@ -1,192 +1,174 @@
|
| <!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/math_calculator.mojom.js"></script>
|
| +<script src="file:///gen/mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.js"></script>
|
| <script>
|
| 'use strict';
|
|
|
| -setup({ explicit_done: true });
|
| -
|
| -define([
|
| - "mojo/public/js/bindings",
|
| - "mojo/public/js/core",
|
| - "mojo/public/interfaces/bindings/tests/math_calculator.mojom",
|
| - "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom",
|
| -], function(bindings, core, math, sampleInterfaces) {
|
| -
|
| - function CalculatorImpl() {
|
| - this.total = 0;
|
| - }
|
| -
|
| - CalculatorImpl.prototype.clear = function() {
|
| - this.total = 0;
|
| - return Promise.resolve({value: this.total});
|
| - };
|
| -
|
| - CalculatorImpl.prototype.add = function(value) {
|
| - this.total += value;
|
| - return Promise.resolve({value: this.total});
|
| - };
|
| -
|
| - CalculatorImpl.prototype.multiply = function(value) {
|
| - this.total *= value;
|
| - return Promise.resolve({value: this.total});
|
| - };
|
| -
|
| - function IntegerAccessorImpl() {
|
| - this.integer = 0;
|
| - }
|
| -
|
| - IntegerAccessorImpl.prototype.getInteger = function() {
|
| - return Promise.resolve({data: this.integer});
|
| - };
|
| -
|
| - IntegerAccessorImpl.prototype.setInteger = function(value) {
|
| - this.integer = value;
|
| - };
|
| -
|
| - test(() => {
|
| - var calc = new math.CalculatorPtr();
|
| - assert_false(calc.ptr.isBound());
|
| -
|
| - var request = bindings.makeRequest(calc);
|
| - assert_true(calc.ptr.isBound());
|
| -
|
| - calc.ptr.reset();
|
| - assert_false(calc.ptr.isBound());
|
| - }, 'is bound');
|
| -
|
| - promise_test(async () => {
|
| - var calc = new math.CalculatorPtr();
|
| - var calcBinding = new bindings.Binding(math.Calculator,
|
| - new CalculatorImpl(),
|
| - bindings.makeRequest(calc));
|
| -
|
| - assert_equals((await calc.add(2)).value, 2);
|
| - assert_equals((await calc.multiply(5)).value, 10);
|
| - assert_equals((await calc.clear()).value, 0);
|
| - }, 'end to end');
|
| -
|
| - promise_test(async () => {
|
| - var calc = new math.CalculatorPtr();
|
| - var calcImpl1 = new CalculatorImpl();
|
| - var calcBinding1 = new bindings.Binding(math.Calculator,
|
| - calcImpl1,
|
| - bindings.makeRequest(calc));
|
| - var calcImpl2 = new CalculatorImpl();
|
| - var calcBinding2 = new bindings.Binding(math.Calculator, calcImpl2);
|
| -
|
| - assert_equals((await calc.add(2)).value, 2);
|
| - calcBinding2.bind(bindings.makeRequest(calc));
|
| - assert_equals((await calc.add(2)).value, 2);
|
| - assert_equals(calcImpl1.total, 2);
|
| - assert_equals(calcImpl2.total, 2);
|
| - }, 'reusable');
|
| -
|
| - promise_test(async () => {
|
| - var calc = new math.CalculatorPtr();
|
| - var calcBinding = new bindings.Binding(math.Calculator,
|
| - new CalculatorImpl(),
|
| - bindings.makeRequest(calc));
|
| -
|
| - await new Promise((resolve, reject) => {
|
| - calc.ptr.setConnectionErrorHandler(() => { resolve(); });
|
| - calcBinding.close();
|
| +function CalculatorImpl() {
|
| + this.total = 0;
|
| +}
|
| +
|
| +CalculatorImpl.prototype.clear = function() {
|
| + this.total = 0;
|
| + return Promise.resolve({value: this.total});
|
| +};
|
| +
|
| +CalculatorImpl.prototype.add = function(value) {
|
| + this.total += value;
|
| + return Promise.resolve({value: this.total});
|
| +};
|
| +
|
| +CalculatorImpl.prototype.multiply = function(value) {
|
| + this.total *= value;
|
| + return Promise.resolve({value: this.total});
|
| +};
|
| +
|
| +function IntegerAccessorImpl() {
|
| + this.integer = 0;
|
| +}
|
| +
|
| +IntegerAccessorImpl.prototype.getInteger = function() {
|
| + return Promise.resolve({data: this.integer});
|
| +};
|
| +
|
| +IntegerAccessorImpl.prototype.setInteger = function(value) {
|
| + this.integer = value;
|
| +};
|
| +
|
| +test(() => {
|
| + var calc = new math.CalculatorPtr();
|
| + assert_false(calc.ptr.isBound());
|
| +
|
| + var request = mojo.makeRequest(calc);
|
| + assert_true(calc.ptr.isBound());
|
| +
|
| + calc.ptr.reset();
|
| + assert_false(calc.ptr.isBound());
|
| +}, 'is bound');
|
| +
|
| +promise_test(async () => {
|
| + var calc = new math.CalculatorPtr();
|
| + var calcBinding = new mojo.Binding(
|
| + math.Calculator, new CalculatorImpl(), mojo.makeRequest(calc));
|
| +
|
| + assert_equals((await calc.add(2)).value, 2);
|
| + assert_equals((await calc.multiply(5)).value, 10);
|
| + assert_equals((await calc.clear()).value, 0);
|
| +}, 'end to end');
|
| +
|
| +promise_test(async () => {
|
| + var calc = new math.CalculatorPtr();
|
| + var calcImpl1 = new CalculatorImpl();
|
| + var calcBinding1 = new mojo.Binding(math.Calculator, calcImpl1,
|
| + mojo.makeRequest(calc));
|
| + var calcImpl2 = new CalculatorImpl();
|
| + var calcBinding2 = new mojo.Binding(math.Calculator, calcImpl2);
|
| +
|
| + assert_equals((await calc.add(2)).value, 2);
|
| + calcBinding2.bind(mojo.makeRequest(calc));
|
| + assert_equals((await calc.add(2)).value, 2);
|
| + assert_equals(calcImpl1.total, 2);
|
| + assert_equals(calcImpl2.total, 2);
|
| +}, 'reusable');
|
| +
|
| +promise_test(async () => {
|
| + var calc = new math.CalculatorPtr();
|
| + var calcBinding = new mojo.Binding(math.Calculator, new CalculatorImpl(),
|
| + mojo.makeRequest(calc));
|
| +
|
| + await new Promise((resolve, reject) => {
|
| + calc.ptr.setConnectionErrorHandler(() => { resolve(); });
|
| + calcBinding.close();
|
| + });
|
| +}, 'connection error');
|
| +
|
| +promise_test(async () => {
|
| + var calc = new math.CalculatorPtr();
|
| + var calcBinding = new mojo.Binding(math.Calculator, new CalculatorImpl(),
|
| + mojo.makeRequest(calc));
|
| +
|
| + await new Promise((resolve, reject) => {
|
| + calc.ptr.setConnectionErrorHandler(({customReason, description}) => {
|
| + assert_equals(customReason, 42);
|
| + assert_equals(description, 'hey');
|
| + resolve();
|
| });
|
| - }, 'connection error');
|
| -
|
| - promise_test(async () => {
|
| - var calc = new math.CalculatorPtr();
|
| - var calcBinding = new bindings.Binding(math.Calculator,
|
| - new CalculatorImpl(),
|
| - bindings.makeRequest(calc));
|
| -
|
| - await new Promise((resolve, reject) => {
|
| - calc.ptr.setConnectionErrorHandler(({custom_reason, description}) => {
|
| - assert_equals(custom_reason, 42);
|
| - assert_equals(description, 'hey');
|
| - resolve();
|
| - });
|
| - calcBinding.closeWithReason({custom_reason: 42, description: 'hey'});
|
| + calcBinding.closeWithReason({customReason: 42, description: 'hey'});
|
| + });
|
| +}, 'connection error with reason');
|
| +
|
| +promise_test(async () => {
|
| + var calc = new math.CalculatorPtr();
|
| + var newCalc = null;
|
| + var calcBinding = new mojo.Binding(math.Calculator, new CalculatorImpl(),
|
| + mojo.makeRequest(calc));
|
| +
|
| + assert_equals((await calc.add(2)).value, 2);
|
| + newCalc = new math.CalculatorPtr();
|
| + newCalc.ptr.bind(calc.ptr.passInterface());
|
| + assert_false(calc.ptr.isBound());
|
| + assert_equals((await newCalc.add(2)).value, 4);
|
| +
|
| +}, 'pass interface');
|
| +
|
| +promise_test(async () => {
|
| + var pipe = Mojo.createMessagePipe();
|
| + var calc = new math.CalculatorPtr(pipe.handle0);
|
| + var newCalc = null;
|
| + var calcBinding = new mojo.Binding(math.Calculator, new CalculatorImpl(),
|
| + pipe.handle1);
|
| +
|
| + assert_equals((await calc.add(2)).value, 2);
|
| +
|
| +}, 'bind raw handle');
|
| +
|
| +promise_test(async () => {
|
| + var integerAccessorPtr = new sample.IntegerAccessorPtr();
|
| +
|
| + var integerAccessorBinding = new mojo.Binding(
|
| + sample.IntegerAccessor, new IntegerAccessorImpl(),
|
| + mojo.makeRequest(integerAccessorPtr));
|
| + assert_equals(integerAccessorPtr.ptr.version, 0);
|
| +
|
| + assert_equals(await integerAccessorPtr.ptr.queryVersion(), 3);
|
| + assert_equals(integerAccessorPtr.ptr.version, 3);
|
| +}, 'query version');
|
| +
|
| +promise_test(async () => {
|
| + var integerAccessorImpl = new IntegerAccessorImpl();
|
| + var integerAccessorPtr = new sample.IntegerAccessorPtr();
|
| + var integerAccessorBinding = new mojo.Binding(
|
| + sample.IntegerAccessor, integerAccessorImpl,
|
| + mojo.makeRequest(integerAccessorPtr));
|
| +
|
| + // Inital version is 0.
|
| + assert_equals(integerAccessorPtr.ptr.version, 0);
|
| +
|
| + integerAccessorPtr.ptr.requireVersion(1);
|
| + assert_equals(integerAccessorPtr.ptr.version, 1);
|
| + integerAccessorPtr.setInteger(123, sample.Enum.VALUE);
|
| + assert_equals((await integerAccessorPtr.getInteger()).data, 123);
|
| +
|
| + integerAccessorPtr.ptr.requireVersion(3);
|
| + assert_equals(integerAccessorPtr.ptr.version, 3);
|
| + integerAccessorPtr.setInteger(456, sample.Enum.VALUE);
|
| + assert_equals((await integerAccessorPtr.getInteger()).data, 456);
|
| +
|
| + // Require a version that is not supported by the impl side.
|
| + integerAccessorPtr.ptr.requireVersion(4);
|
| + assert_equals(integerAccessorPtr.ptr.version, 4);
|
| + integerAccessorPtr.setInteger(789, sample.Enum.VALUE);
|
| +
|
| + await new Promise((resolve, reject) => {
|
| + integerAccessorPtr.ptr.setConnectionErrorHandler(() => {
|
| + resolve();
|
| });
|
| - }, 'connection error with reason');
|
| -
|
| - promise_test(async () => {
|
| - var calc = new math.CalculatorPtr();
|
| - var newCalc = null;
|
| - var calcBinding = new bindings.Binding(math.Calculator,
|
| - new CalculatorImpl(),
|
| - bindings.makeRequest(calc));
|
| -
|
| - assert_equals((await calc.add(2)).value, 2);
|
| - newCalc = new math.CalculatorPtr();
|
| - newCalc.ptr.bind(calc.ptr.passInterface());
|
| - assert_false(calc.ptr.isBound());
|
| - assert_equals((await newCalc.add(2)).value, 4);
|
| -
|
| - }, 'pass interface');
|
| -
|
| - promise_test(async () => {
|
| - var pipe = core.createMessagePipe();
|
| - var calc = new math.CalculatorPtr(pipe.handle0);
|
| - var newCalc = null;
|
| - var calcBinding = new bindings.Binding(math.Calculator,
|
| - new CalculatorImpl(),
|
| - pipe.handle1);
|
| -
|
| - assert_equals((await calc.add(2)).value, 2);
|
| -
|
| - }, 'bind raw handle');
|
| -
|
| - promise_test(async () => {
|
| - var integerAccessorPtr = new sampleInterfaces.IntegerAccessorPtr();
|
| -
|
| - var integerAccessorBinding = new bindings.Binding(
|
| - sampleInterfaces.IntegerAccessor,
|
| - new IntegerAccessorImpl(),
|
| - bindings.makeRequest(integerAccessorPtr));
|
| - assert_equals(integerAccessorPtr.ptr.version, 0);
|
| -
|
| - assert_equals(await integerAccessorPtr.ptr.queryVersion(), 3);
|
| - assert_equals(integerAccessorPtr.ptr.version, 3);
|
| - }, 'query version');
|
| -
|
| - promise_test(async () => {
|
| - var integerAccessorImpl = new IntegerAccessorImpl();
|
| - var integerAccessorPtr = new sampleInterfaces.IntegerAccessorPtr();
|
| - var integerAccessorBinding = new bindings.Binding(
|
| - sampleInterfaces.IntegerAccessor,
|
| - integerAccessorImpl,
|
| - bindings.makeRequest(integerAccessorPtr));
|
| -
|
| - // Inital version is 0.
|
| - assert_equals(integerAccessorPtr.ptr.version, 0);
|
| -
|
| - integerAccessorPtr.ptr.requireVersion(1);
|
| - assert_equals(integerAccessorPtr.ptr.version, 1);
|
| - integerAccessorPtr.setInteger(123, sampleInterfaces.Enum.VALUE);
|
| - assert_equals((await integerAccessorPtr.getInteger()).data, 123);
|
| -
|
| - integerAccessorPtr.ptr.requireVersion(3);
|
| - assert_equals(integerAccessorPtr.ptr.version, 3);
|
| - integerAccessorPtr.setInteger(456, sampleInterfaces.Enum.VALUE);
|
| - assert_equals((await integerAccessorPtr.getInteger()).data, 456);
|
| -
|
| - // Require a version that is not supported by the impl side.
|
| - integerAccessorPtr.ptr.requireVersion(4);
|
| - assert_equals(integerAccessorPtr.ptr.version, 4);
|
| - integerAccessorPtr.setInteger(789, sampleInterfaces.Enum.VALUE);
|
| -
|
| - await new Promise((resolve, reject) => {
|
| - integerAccessorPtr.ptr.setConnectionErrorHandler(() => {
|
| - resolve();
|
| - });
|
| - });
|
| - assert_equals(integerAccessorImpl.integer, 456);
|
| -
|
| - }, 'require version');
|
| + });
|
| + assert_equals(integerAccessorImpl.integer, 456);
|
|
|
| - done();
|
| -});
|
| +}, 'require version');
|
|
|
| </script>
|
|
|